How to use mocap pose directly in PX4

Hello there, I’m using a motion capture system as pose estimation. I’d like to set mocap pose as ground truth for quadrotor, but failed.

First, I relay the mocap pose topic to /mavros/vision_pose/pose.

Second, set EKF2_AID_MASK=24, EKF2_GHT_MODE=vision:

My drone can switch to position mode and takeoff, however, there is still a difference in /mavros/vision_pose/pose and /mavros/local_position/pose, where the vision pose is actually the mocap pose.

I’m using PX4-Autopilot 1.13.0 and Pixhawk 6c mini, QGC 4.4.2.

Thank you for any advice and suggestions.

Hi Jamie,

This is normal. The PX4 fuses the mocap pose that you are relaying with IMU measurements using EKF and estimates a new pose. This is what you see in /mavros/local_position/pose. You can expect some sort of lag and mismatch with the raw mocap pose. You may reduce this lag by setting the standard deviation parameters to low values.

Regards,
Mohan

1 Like

Thanks Mohan,

I tried to set EKF2_EVP_NOISE and EKF2_EVV_NOISE to as low as possible, which is 0.001 and 0.002.

And it still had mismatch, even crash, like this:

Maybe a q estimator is the best choice, but I haven’t figured out how to set it in V1.13.

Also have a chat in discord: Discord

This is unusual. Did you check the flag that you are fusing velocity also? If so, uncheck it. Don’t fuse velocity. Try to do the following

  1. Calibrate the autopilot.
  2. Make sure the MAV_X_MODE is onboard (X is the port you are using).
  3. Increase the MAV_X_RATE to at least 80000.

Thanks Mohan,

I double checked that I only fused position and yaw, which is 24 for EKF2_AID_MASK, and the MAV_X_RATE is higher than 80000.

But that error still happens, I guess maybe only disabling EKF2 and using Q_estimator would work.

Did you calibrate the autopilot?

Check this link to see that you have set all the parameters correctly

https://docs.px4.io/v1.15/en/peripherals/mavlink_peripherals.html

Make sure your MAV_X_MODE is set to onboard and SER_TEL1_BAUD is also high.