This assumes that you have PX4 (posix configuration) and jMAVSim installed and compiled. These can be on the same physical machine or on different machines as long as there is a network between the two. The system has many possible configurations - this README will focus just on one to keep things simple. Namely:
- The controller inputs are coming from a PIXHAWK that has an active connection to an RC controller and is generating the [Mavlink](https://pixhawk.ethz.ch/mavlink/) message RC_CHANNELS(#65) on its serial (USB) port. This Pixhawk's USB is connected to a USB port on the machine running PX4.
- PX4 and jMAVSim communicate over UDP
- qGroundControl is connecting to PX4 over UDP
A diagram of the setup described is shown here. Note that UDP port numbers are only displayed on the socket server and are left blank on the socket client.
1. Connect the RC Controller (PIXHAWK) to the PX4 machine using USB. Verify the `/dev/ttyACM0` device appears. Make sure that the persmissions of this device allow the PX4 app to open the device for read/write (`sudo chmod 777 /dev/ttyACM0`).
NOTE: This is only necessary if you are not using the instructions above.
1. Connect the RC Controller (PIXHAWK) to the PX4 machine using USB. Verify the `/dev/ttyACM0` device appears. Make sure that the persmissions of this device allow the PX4 app to open the device for read/write (`sudo chmod 777 /dev/ttyACM0`).
1. Launch PX4 from the SITL build directory "`./Firmware/Build/posix_sitl.build/`" using the command below. The optional `<startup_file>` can be used to cause a set of commands to be entered into the PX4 shell at startup.
Without the `<startup_file>`, the commands can be entered at the shell prompt one at a time. An example startup file is given below. This example shows that the "mavlink" module has selected port 14556 for its socket server (as shown in the SITL diagram) and will listen for connections on this port.
1. qGroundControl (QGC) can be connected to this instance of PX4 any time after it is started. The instructions for configuring (QGC) are not given here in detail, but you just need to configure a UDP connection with ip_address:`<addressofPX4machine>` and port:14556. (QGC also has a "Listening Port" setting that must be set to another unused port).
1. jMAVSim can now be launched to complete the setup. At the root directory of the jMAVSim code, type the following command, replacing the IP address of the machine that is running PX4. The port 14550 is the default port of the simulator module in PX4.
At this point, you should see the jMAVSim world visualization, and when you increase the throttle on your RC controller, the vehicle will take off. Note that the RC params in the example startup file may not be correct for your controller.