Skip to content

Latest commit

 

History

History
98 lines (69 loc) · 7.8 KB

px4_setup.md

File metadata and controls

98 lines (69 loc) · 7.8 KB

PX4 Setup for AirSim

The PX4 software stack is an open source very popular flight controller with support for wide variety of boards and sensors as well as built-in capability for higher level tasks such as mission planning. Please visit px4.io for more information.

Warning: While all releases of AirSim are always tested with PX4 to ensure the support, setting up PX4 is not a trivial task. Unless you have at least intermediate level of experience with PX4 stack, we recommend you use simple_flight, which is now a default in AirSim. Due to bugs such as this things haven't been working after PX4 release 1.5.5. With that release, you may still see wobbly drone sometimes. For issues related to PX4 setup please visit PX4 forums.

Supported Hardware

The following pixhawk hardware has been tested with AirSim:

  1. 3DR Pixhawk v2
  2. 3DR Pixhawk mini
  3. Pixhawk PX4 2.4.8
  4. PixFalcon
  5. PixRacer

The 3DR Pixhawk Mini works out of the box, the others you may need to re-flash with the firmware v1.5.5.

Setting up PX4 Hardware-in-Loop

For this you will need one of the supported device listed above. For manual flight you will also need RC + transmitter.

  1. Make sure your RC receiver is bound with its RC transmitter. Connect the RC trasmitter to the flight controller's RC port. Refer to your RC manual and PX4 docs for more information.
  2. Download QGroundControl, launch it and connect your flight controller to the USB port.
  3. Install the PX4 firmware v1.5.5 from github. You likely have v2 device and if so use file nuttx-px4fmu-v2-default.px4. To check if you really have v2 device you can use Nirsoft USBDeview utility. Chris Lovett also has created initial firmware setup video that show how to install new firmware. Note that later releases of PX4 at least up to 1.6.3 has issue where vehicle doesn't takeoff after arming.
  4. In QGroundControl, configure your Pixhawk for HIL simulation by selecting the HIL Quadrocopter X airframe. After PX4 reboots, check that "HIL Quadrocopter X" is indeed selected.
  5. In QGroundControl, go to Radio tab and calibrate (make sure, remote control is on and the receiver is showing the indicator for the binding).
  6. Go to the Flight Mode tab and chose one of the remote control switches as "Mode Channel". Then set (for example) Stabilized and Attitude flight modes for two positions of the switch.
  7. Go to the Tuning section of QGroundControl and set appropriate values. For example, for Fly Sky's FS-TH9X remote control, following settings gives more realistic feel: Hover Throttle = mid+1 mark, Roll and pitch sensitivity = mid-3 mark, Altitude and position control sensitivity = mid-2 mark.
  8. In AirSim settings file, specify PX4 for your vehicle config like this:
{
  "SettingsVersion": 1.0,
  "DefaultVehicleConfig": "PX4"
}

After above setup you should be able to use RC to fly in the AirSim. You can usually arm the vehicle by lowering and bringing two sticks of RC together in-wards. You don't need QGroundControl after the initial setup. Typically the Stabilized (instead of Manual) mode gives better experience for beginners.

See Walkthrough Demo Video and Unreal AirSim Setup Video that shows you all the setup steps in this document.

Setting up PX4 Software-in-Loop

The PX4 SITL mode doesn't require you to have separate device such as Pixhawk or Pixracer. This is in fact the recommended way to use PX4 with simulators by PX4 team. However this is indeed more harder to set up. Please see this dedicated page for setting up PX4 in SITL mode.

FAQ

Drone doesn't fly properly, it just goes "crazy".

There are few reasons that can cause this. First make sure your drone doesn't fall down large distance when starting simulator. This might happen if you have created custom Unreal environment and Player Start is placed too high above ground. It seems that when this happens internal calibration in PX4 gets confused.

Another thing to verify is to make sure you are using PX4 release 1.5.5 as later releases seems to have few issues. You should also use QGroundControl and make sure you can arm and takeoff in QGroundControl properly.

Finally, this also can be a machine performance issue in some rare cases, check your hard drive performance.

Can I use Arducopter or other MavLink implementations?

Our code is tested with the PX4 firmware. We have not tested Arducopter or other mavlink implementations. Some of the flight API's do use the PX4 custom modes in the MAV_CMD_DO_SET_MODE messages (like PX4_CUSTOM_MAIN_MODE_AUTO)

It is not finding my pixhawk hardware

Check your settings.json file for this line "SerialPort":"*,115200". The asterix here means "find any serial port that looks like a Pixhawk device, but this doesn't always work for all types of pixhawk hardware. So on Windows you can find the actual COM port using Device Manager, look under "Ports (COM & LPT), plug the device in and see what new COM port shows up. Let's say you see a new port named "USB Serial Port (COM5)". Well, then change the SerialPort setting to this: "SerialPort":"COM5,115200".

On Linux, the device can be found by running "ls /dev/serial/by-id" if you see a device name listed that looks like this usb-3D_Robotics_PX4_FMU_v2.x_0-if00 then you can use that name to connect, like this: "SerialPort":"/dev/serial/by-id/usb-3D_Robotics_PX4_FMU_v2.x_0-if00". Note this long name is actually a symbolic link to the real name, if you use "ls -l ..." you can find that symbolic link, it is usually something like "/dev/ttyACM0", so this will also work "SerialPort":"/dev/ttyACM0,115200". But that mapping is similar to windows, it is automatically assigned and can change, whereas the long name will work even if the actual tty serial device mapping changes.

WARN [commander] Takeoff denied, disarm and re-try

This happens if you try and take off when PX4 still has not computed the home position. PX4 will report the home position once it is happy with the GPS signal, and you will see these messages:

INFO  [commander] home: 47.6414680, -122.1401672, 119.99
INFO  [tone_alarm] home_set

Up until this point in time, however, the PX4 will reject takeoff commands.

When I tell the drone to do something it always lands

For example, you use DroneShell moveToPosition -z -20 -x 50 -y 0 which it does, but when it gets to the target location the drone starts to land. This is the default behavior of PX4 when offboard mode completes. To set the drone to hover instead set this PX4 parameter:

param set COM_OBL_ACT 1

I get message length mismatches errors

You might need to set MAV_PROTO_VER parameter in QGC to "Always use version 1". Please see this issue more details.