Skip to content

Using Ardupilot in Optitrack

Diego Benjumea edited this page Dec 29, 2021 · 8 revisions

Previous configuration

Tested with Arducopter 4.0.7 and 4.1.2

Dependencies

Install pymavlink needed in set_origin.py script

pip install pymavlink

Parameters required

Set the following parameters in ArduPilot to enable external navigation

Connection

Configure the serial comunication with the onboard flight computer using TELEM2 port:

  • SERIAL2_PROTOCOL = 2 (MAVLink2)
  • SERIAL2_BAUD = 921 (921600 bauds)

Enable data stream over the serial port:

  • SR2_* = 10 (10 Hz)

Estimator

For ArduPilot-4.0 (and earlier):

  • AHRS_EKF_TYPE = 2 (the default) to use EKF2
  • EK2_ENABLE = 1 (the default)
  • EK3_ENABLE = 0 (the default)
  • EK2_GPS_TYPE = 3 to disable the EKF’s use of the GPS
  • EK2_POSNE_M_NSE = 1
  • GPS_TYPE = 0 to disable the GPS
  • COMPASS_USE = 0, COMPASS_USE2 = 0, COMPASS_USE3 = 0 to disable the EKF’s use of the compass and instead rely on the heading from external navigation data

For ArduPilot-4.1 (and later):

  • AHRS_EKF_TYPE = 3 (EKF3)
  • EK2_ENABLE = 0 (disabled)
  • EK3_ENABLE = 1 (enabled)
  • EK3_SRC1_POSXY = 6 (ExternalNav)
  • EK3_SRC1_VELXY = 6 (ExternalNav)
  • EK3_SRC1_POSZ = 6 (ExternalNav)
  • EK3_SRC1_VELZ = 6 (ExternalNav)
  • GPS_TYPE = 0 to disable the GPS
  • VISO_TYPE = 1 (MAVLink)
  • COMPASS_USE = 0 , COMPASS_USE2 = 0, COMPASS_USE3 = 0 to disable all compasses
  • EK3_SRC1_YAW = 6 (ExternalNav)

Running

The easiest way is using the all-included ROS launcher (apm.launch) with:

  • UAL
  • VRPN client - to get data from Optitrack Server (edit to match with your)
  • apm_bridge script - to send position data using the ROS topic mavros/vision/pose . This transmition must be limited to 30Hz as max rate
  • set_origin script - required to init the gps in a faked position

The apm.launch launcher has two arguments. The robot_model argument is the name of the model that is selected in the Motive application. server_ip argument is the IP address of the server running. You can see how to check it here.

Run apm.launch executing the following command:

roslaunch mocap_bridge apm.launch robot_model:=<your_robot_model> server_ip:=<optitrack_pc_ip>