PX4-ROS2 VIO navigation in GPS denied condition

HI guys,

I’m trying to replicate what has been already done for ROS with MAVROS, but this time with ROS2, having a pose external source (T265, ecc…) replacing the GPS.
I’ve already configured the system, installing on a RPi, ROS2 and Fast DDS, checking that everithing worked as described in https://docs.px4.io/master/en/ros/ros2_comm.html.

The sw setup is made up by 2 nodes:

  • the offboard node (the same in px4_ros_com package) to set the offboard node, arming and sending position commands
  • the second node simply takes the data coming from the external source and publish on the topic /fmu/vehicle_visual_odometry/in

I’ve also set two parameters:

  • EKF2_AID_MASK: 24 (external position + external yaw)
  • EKF2_HGT_MODE: 3 (vision)
  • CBRK_GPSFAIL: 240024 (ignoring GPS)

Since the controllor does not pass to offboard mode, but remain in stabilize mode, I’m wondering what I am missing.
I remember that the ROS implementation there is also a node (set_origin.py) which sends (through mavros) messages to mavlink, containing the cooridnates of the starting point (MAVLink_set_gps_global_origin_message and MAVLink_set_home_position_message). If this is the problem, there is a way to solve it on ROS2, since apparently there is no topic related to it?

Issue solved, after learning how PX4 works with ROS2

Hey, have you managed to fly using only the topic /fmu/vehicle_visual_odometry/in?

I just ordered a Pixhawk 5x and will try to build on it and try to fly the drone.

Could you describe approximately how you did it with the ROS2-PX4 bridge?

Hi, yes sure, I’ll try to be as clear as possible.
Before starting, you need to follow the official procedure ROS 2 User Guide to correctly set your environment.

Essentially you need these nodes:

  • a node that takes the pose data coming from the external source (like the RealSense T265) and passes to the PX4 topic /fmu/vehicle_visual_odometry/in, with the specific message type px4_msgs::msg::VehicleVisualOdometry which is located in px4_msgs (you have to take a look over it if you want to know how to fill the message fields)
  • a node similar to the example provided by pxf (px4_offboard inside px4_ros_com) which publishes positions (or velocities) commands to the controller; also in this case, I suggest to take a look over the messages definitions if you want to better understand).

Finally you have to set up PX4 parameters in addition of the ones I posted above:

  • NAV_RCL_ACT: 0
  • NAV_DLL_ACT: 0
  • COM_OBL_ACT: 1 (optional)

I’m not sure these parameters are all required, but it worked for me

1 Like

Nice Vince, thanks for your reply!

Could you share with me your code? I’m trying to implement my Drone with a VICON system.

I have managed to do the Bridge, but I do not know how to send the Pixhawk the positions correctly.

I mean, I would like to know how it must look like this node for passing the message obtained by Vicon to VehicleVisualOdometry topic.

My environment is already set.

Hi Vince, I am trying to do the same, but I am new user of ROS2. Can you share the nodes you created to communicate the camera T265 with the Px4? I am trying to read the documentation from realsense and px4, but not making much progress. Maybe you can contribute what you have done here Searching for Auterion VIO bridge (now private repo) alternative · Issue #21498 · PX4/PX4-Autopilot · GitHub. It is an open thread for this problem there

I put together a package that I am using and testing now, Bitbucket

Hi, is there any working code out there or setup? Been testing the pass few days but could not switch to position holding mode even data is seen /fmu/vehicle_visual_odometry/in