Check for a valid Local Position Estimate - OptiTrack with MAVROS - problems with EKF2

Good morning everyone

I am trying to fly a quadcopter in an indoor environment, the local position is provided by an Optitrack vision system.
My hardware architecture is composed of:

  • Pixhawk 6c, Firmware 1.13.2
  • Raspberry PI 4.
    The RPi4 is connected to the Pixhawk by serial communication over the port TELEM2, where MAVROS is initialized. It gets data from Mocap and, through this port, it sends it to the Pixhawk.
    To edit parameters and check PX4 status, I use QGroundControl.

To fuse vision data with EKF, I didn’t find an official guide for the 1.13 firmware version, so I followed this one: https://dev.px4.io/v1.11_noredirect/en/ros/external_position_estimation.html, to have a match in parameters’ names.
In particular, I configured the EKF as follows:
EKF2_AID_MASK = vision_posion_fusion + vision_yaw_fusion + rotate_external_vision;
EKF2_HGT_MODE = Vision;
EKF2_EV_DELAY = 0;

Problems encountered:

  1. If I want to see ODOMETRY message in the MAVLink Inspector, but setting MAV_ODOM_LP to 1 is not enough, I should set MAV_1_MODE = External Vision. That parameter does not exist, it is the one related to the port where I use MAVROS, so I set MAV_0_MODE and now I can see the output of the EKF2.

  2. when trying to switch to an automatic mode such as “Hold”, I get the message: “Check for a valid Local Position Estimate”. EKF2 seems receiving and fusing the data (see second screenshot, data from ODOMETRY matches with /mavros/vision_pose/pose), but by checking in the MAVLink shell its status, it shows ’ vehicle_visual_odometry messages missed: n events’.
    Even tho, I can listen to the data on vehicle_visual_odometry topic. Could the problem in the 1st question be related (I am sending data to a port that is not configured to receive external vision)?
    From the first screenshot, it shows MAV_1_CONFIG and MAV_2_CONFIG are disabled. This was because initializing MAVLink at boot on these ports that are connected to the RPi4 resulted in problems during boot on the RPi4 side, so MAVROS is initialized manually on the MAVLink shell after boot.

The result is that I cannot fly with any automatic mode. I didn’t try Offboard yet because I would have a solid and functioning solution to backup in case the quadrotor doesn’t behave as expected.
Any ideas on how to fix this?

Thank you for your time, I am linking some screenshots to show the general overview.

Andrea

Screenshot 1: MAV_1_MODE does not exist.

Screenshot 2: /mavros/vehicle_pose/pose and ODOMETRY data correspondancy

Screenshot 3: ekf2 status, vehicle_visual_odometry messagges miss

Screenshot 4: listening to vehicle_visual_odometry topic

Screenshot 5: Overall MAVRos and QGC status

A little update:

starting the MAVLink instance (for MAVROS) on the MAVLink Shell with the flag “-m extvision” solved the problem of EKF2 missing vehicle_visual_odometry messages, probably the -m flag plays the same role as changing the parameter MAV_N_MODE (N = 0,1,2).

Still having the error “Check for a valid Local Position Estimate” when trying to change to Hold and Offboard (I didn’t try to send setpoints yet, but just switching to the mode).
I noticed that Pixhawk asks for the home position repeatedly. Being in an indoor environment doesn’t help, and even if it may get it at the start, it seems to loose the home position after a while when moving the robot around.

Could this give any potential problems?
Thanks

Hi delbesca,

I do not have an answer to your questions. However, i believe i almost have the same setup as you. I also publish to “mavros/vision_pose/pose” and have the same parameters settings as you. I am able to fly autonomously with the drone. I think the requesting home position does not matter much. Do you know how to echo the topic “vehicle_visual_odometry” with ROS? It is not published in my case. I am able to listen to it like you do via QGC but i want to use this information.

Thanks

Hi Stoffijn

Thank you for your answer, I will give it one more try next days.
Actually, I am using ROS2 to use the odometry information, my workspace is there.
I believe in ROS there should be a correspondence of Odometry message, which gives the output from the EKF.
If you want to reuse the data given in input on “mavros/vision_pose/pose”, just use that topic already.
Hope this helps, have a nice day.