The following parameters must be set to use external position information with EKF2 (these can be set in QGroundControl > Vehicle Setup > Parameters > EKF2).
Parameters | Setting for External Position Estimation |
---|---|
UXRCE_DDS_CFG |
a desired port on your flight controller |
ser_tel1_baud |
921600 |
EKF2_EV_CTRL |
Select horizontal position fusion, vertical vision fusion |
EKF2_HGT_REF |
Set to Vision to use the vision as the reference source for altitude estimation. |
EKF2_EV_POS_X,Y,Z |
Set the position of the vision sensor (or MoCap markers) with respect to the robot's body frame. |
EKF2_GPS_CTRL |
Disable GPS sensor fusion |
EKF2_BARO_CTRL |
Disable Barometer sensor fusion |
EKF2_RNG_CTRL |
Disable range finder sensor fusion |
To perform the simulation with motion capture (external positioning system) you need first to setup the PX4 parameters in QGroundControl. You can load the parameters for the MoCap simulation by opening QGroundControl and loading the parameters present in the folder QGround_parameters. In particular, you can load:
- SITL_indoor_simu.params - to perform Software in the loop simulations
- HITL_indoor_simu.params - to perform Hardware in the loop simulations
- indoor_test.params - to perform experimental simulations
Depending of the type of simulation that you want to perform, you need to setup the enviromnet following in different ways:
- Software in the loop, skip the step where specified (Only for experimental simulations)
- Hardware in the loop, skip the step where specified (Only for experimental simulations)
- Experimental tests: make sure that your drone is in Ready to fly state before lauch the simulation (see next steps)
To perfrom SITL and HITL simulations install first the Position plugin, see section plugin
Remember to install the Qualisys - ros2 bridge plugin before using the Bridge motion capture to PX4 and follow the instructions to set the right frequency rate and the correct ip address.
In order to publish the px4 message with the external positon estimate you have to select the correct topic where qualysis publish is message.
cd ~/PX4-mini-drone/bridge_mocap_px4/src/
nano mocap_bridge.cpp
Modify the line std::string topic_name = "/Drone/pose"
with your topic name.
Before lunch the motion to PX4 bridge make sure the qualysis program is running and that the body is recognised by the motion capture system.
Before lauch the bridge make sure that your external postion reference frame system match the drone reference frame, open mocap_bridge and modify if necessary
On the command prompt enter
cd ~/PX4-mini-drone
ros2 launch launch/mocap_offboard.launch.py
This will start the qualysis plugin and start the bridge in order to fill the message fmu/in/vehicle_visual_odometry which is necessary for the external pose estimation. Without this step the vehicle will not be in ready to fly mode.
Start the simulation, you can choose two different control strategy:
Point target
cd ~/PX4-mini-drone
ros2 run mcoap mocap
Velocity target
cd ~/PX4-mini-drone
ros2 run mcoap mocap_vel
Square trajectory
cd ~/PX4-mini-drone
ros2 run mcoap mocap_square