Building PX4-ROS2 bridge on hardware? (Pixhawk 4)

Hello all,

I’ve had some success with SITL: creating ROS2 bridge listeners and advertisers through px4_sitl_rtps jmavsim. Thanks for your help there!

Next, I’d like to have the ROS2 bridge code running on Pixhawk 4 hardware. I understand that I should upload a custom .px4 firmware file, but I’m not sure how to generate the correct one. I can make px4_fmu-v5_rtps and upload the resulting .px4 file; however, it doesn’t seem to capture the most up-to-date settings on the ROS2 bridge (e.g., the .yaml send and recieve labels, or micrortps_client starting automatically). Messages are not being transmitted or received via the ROS2 bridge using px4_fmu-v5_rtps.px4.

Is there any guidance on the right way to configure the ROS2 bridge in hardware? The tutorials seem to focus on SITL.

(SOLVED) with reference to Micrortps_client does not receive uorb message and Unable to establish FastRTPS connection with pixhawk. #38.

Plug Pixhawk 4 into companion computer via USB, make and upload the firmware from the PX4-Autopilot directory:

make px4_fmu-v5_rtps
make px4_fmu-v5_rtps upload

Enter the nsh> from ~/PX4-Autopilot/Tools$:


Start the micrortps_client over UART instead of UDP (which works for SITL):

nsh>  micrortps_client start -t UART

In a new terminal, source ROS2 and start the micrortps_agent over UART:

micrortps_agent start -t UART

In a new terminal, source ROS2 and echo the desired topic (or run the desired listener):

ros2 topic echo /fmu/vehicle_odometry/out

And the vehicle_odometry topic is printed for the Pixhawk 4 as desired. Hope this helps someone else stuck in the future!