Need some help to use local position from ROS2

Hi all

I have trying to add a slam camera to a pixhawk 6C via ROS2 using the px4_ros2::LocalPositionMeasurementInterface but it does not work as expected. For simplicity I have start using the simulator gazabo and more to verify my setup.

I have followed the guide ROS 2 User Guide | PX4 Guide (main)

I am using the main branch (v1.16) and start the simulater using ‘make px4_sitl gz_500’.

The gazabo simulation starts up and I can communicate to the drone using QGroundControl. I then start the MicroXRCEAgent to connect to the PX4 client up. A connection is made and all seems to work.I then try to run the offboard example from px4_ros_com, ros2 ‘run px4_ros_com offboard_control’ and it does work. The drone takes off in the simulator.

I then try out the example_local_navigation from px4-ros2-interface-lib. It does compile, starts up but nothing happens. What am i missing? I would have expected to find some updated values in the QGroundControl→Analyze tool→MAVLink inspector in the ODOMETRY but the ODOMETRY is not even present. I have set the EKF2_EV_CTRL and other based n the guide Visual Inertial Odometry (VIO) | PX4 Guide (main)

I think I am close, very close. One idea, should the ros2 translation node be started. My gees is no.

Any help/hint is most appriciated.

Yes, I know this is a bit experimental.

Have you turned off the GPS from the parameters?

Sorry for the delay. I have done some further investigation and found some info in two threads.

It is the same problem I try to solve, like in 1 to 1. I also found this thread. Quite a lot off useful information but not a final recipe/hint.

It is a bit different since it is using the mocap method (external vision, not onboard). But there was some hints about various parameters.

What have I done:

Start MicroXRCEAgent udp4 -p 8888
Start make px4_sitl gz_x500
Start QGroundControl
Set
EKF2_EV_CTRL = 11
EKF2_GPS_CTRL = 0 (no GPS fusion
EKF2_HGT_REF = 3 (height reference coming from EV)

and SYS_HAS_GPS = 0

I have then cloned GitHub - Auterion/px4-ros2-interface-lib: Library to interface with PX4 from a companion computer using ROS 2 and build the example_local_navigatio_cpp applicaten and started it using
ros2 run example_local_navigation_cpp example_local_navigation

I inspected listener vehicle_local_position and listener vehicle_local_odometry. The odometry is updated from the example_local_navigation_cpp. I expected that the submitted data would substitute the GPS but it does not. In the QGroundControl the fmu in “Not Ready”.

The data generated in the example_local_navigation_cpp is:

static int count;
count++;
px4_ros2::LocalPositionMeasurement local_position_measurement {};
local_position_measurement.timestamp_sample = _node.get_clock()->now();
local_position_measurement.velocity_xy = Eigen::Vector2f {1.f, 2.f};
local_position_measurement.velocity_xy_variance = Eigen::Vector2f {0.3f, 0.4f};
local_position_measurement.position_z = 12.8f + count / 1000.f;
local_position_measurement.position_z_variance = 0.33F;
local_position_measurement.attitude_quaternion = Eigen::Quaternionf {0.1, -0.2, 0.3, 0.25};
local_position_measurement.attitude_variance = Eigen::Vector3f {0.2, 0.1, 0.05};

I have added count++ to see that “something” is updated in the odometry data in the pxh console. It does update in odometry date. It does not seems to make any change to the TOPIC: vehicle_local_position data.

So, what is missing? I think I am very close.

Minor update. I have tried to use make px4_sitl gz_x500_vision and that works with the settings above. I when tried to run the offboard example and it did take off.
So I assume that the parameters is OK but “something” is missing in the example_local_navigation_cpp. That “something” is set when running the xx_vision. I would assumed that the example_local_navigation_cpp and vision should do the same thing.