Fail to use Visual Inertial Odemtry (VIO) systems in Mavros

Problem Description:
I am able to obtain VIO information (nav_msg/Odometry) from Intel Realsense T265 camera in ROS, but I fail to see the correct message under /mavros/local_position/odom.

System

  1. Flight controller: Pixracer with PX4 firmware
  2. Onboard computer: Nvidia Xavier NX running Ubuntu 18.04 LTS with ROS melodic
  3. remote PC: HP Laptop running Ubuntu 16.04 LTS with ROS kinetic

Communication: PC to Onboard (WIFI), Onboard to FC (serial port)

What I do
I firstly run the Realsense Camera Node in my onboard computer:
roslaunch realsense_camera rs_t265.launch
which gives me /camera/odom/sample (nav_msgs/Odometry).

Then, I use my scripts to subscribe to the above odom topic and re-publish it to mavros/odometry/out as suggested in https://docs.px4.io/master/en/ros/external_position_estimation.html. I set the frame_id and child_frame_id to be odom and base_link, respectively.

After that, I did some tf broadcasting to make the tf like below.

When I check the /mavros/odometry/out and /camera/odom/sample, they are 100% correct. I think I should expect also a correct message from /mavros/local_position/odom, but it looks totally wrong. As you can see blow, the x, y are always zero and z is some random things (always changing and does not start from 0).

My EKF2 parameters are:
EKF2_AID_MASK = 24 (I also tried 280 which is vision pose, orientation and velocity)
EKF2_HGT_MODE: Vision

Question:

  1. Why /mavros/local_position/odom gives nonsense data? (x,y=0, z=random value and always changing)? I think it is purely relying on IMU if there is no external localization, it is true to be inaccurate, but why not making sense?
  2. I think I already follow the instruction, but still cannot use the VIO for pose estimation for my quadcopter. So, which part might I do wrong?

Thanks for any advice and suggestions, I am also very happy to provide further details. THanks in advance!

Your TF looks good. Your EKF doesn’t receive the odometry data. Can you copy what your EKF (ECL) is printing? Do you see something like reset, starting to use EV estimates?

You cannot change the child frame id and frame id fields as you wish. You must do a transformation before you do that. Nevertheless, since your TF is set up properly, PX4 can do the transformation for you. All you need to do is to leave the child frame id and frame id as-is. You can look at this GitHub - Auterion/VIO: Interface PX4 with Realsense T265 to see how the bridge node works.