Issues Running ROS2-PX4

Hello everybody,
I’e been following the guide to setup up PX4-ROS 2 bridge here: ROS 2 User Guide (PX4-ROS 2 Bridge) | PX4 User Guide .

I’m able to successfully run “make px4_sitl_rtps gazebo”, however when I try to launch the micrortps_client in another terminal (after sourcing my ros distro), I run into the following error:

terminate called after throwing an instance of ‘eprosima::fastcdr::exception::BadParamException’
what(): Unexpected byte value in Cdr::deserialize(bool), expected 0 or 1
Aborted (core dumped)

Has anyone else had the same issue? Thanks in advance

I have the same issue.

I have the following setup: Ubuntu 20.04 & ROS Foxy
openjdk 13.0.7
fastrtpsgen 1.0.4

All other steps are successful and subscribers and publishers seem to be all set up succesfully (u until VehicleTrajectoryWaypointDesired publisher)

Hello Stonkens,

There is an issue with the last release of AutoPilot PX4.

Hello,
Even I’m facing the same issue.
When can we expect a fix?

@RyanDsouza
I ran into the same problem very recently, and reverting back to the earlier version solved the problem.
The issue is currently closed due to the fix being made to the most recent version, but I don’t know if anyone has checked if the change is working or not.
For more details, please visit the links below.

Thank you @hhjj0506 I reverted back to an earlier version and it solved the issue

Hi @RyanDsouza , @hhjj0506 , the issue is almost fixed as the problems on the PX4 side should be now solved. However, the message definitions of px4_msgs are still out of date (something about a broken CI/CD it seems). You can see here how to manually generate the message definitions in order to use the last version of PX4 without having to revert back. Simply run uorb_to_ros_msgs.py with the PX4-Autopilot/msg/ and the px4_msgs/msg/ paths (adapted to your cases) as first and second argument respectively, and then recompile.
If you have time to check this solution, please let us know the outcome in the above mentioned github issue.

1 Like

Hello @Benja !
Thank you for the solution, it did work with the latest version of PX4 using the uorb_to_ros_msgs.py.

2 Likes

Just tried this with the tip of main on PX4-Autopilot, the tip of master on px4_msgs, the tip of master on px4_ros_com, and ROS2 humble, all running on Ubuntu 22.04 LTS… and it works.

1 Like

I cannot get it to run, neither on Ubuntu 20, nor Ubuntu 22. Could you please let me know your exact commits and versions of all involved libraries? That would help me so much.

Hi @maxinho
I use ubuntu 20.04, all repository on the current main branches
PX4: e780a583cd2f3c0c42978ff0e5c010f104443267
px4_ros_com: 3a42a27fcdc4b67c120ee84267d236d558951c18
px4_msgs: 7f89976091235579633935b7ccaab68b2debbe19
after having manually updated the msgs definition everything works just fine.

1 Like

Switched the code to the version you mentioned and followed the tutorial and then everything worked?@Benja

what is “manually updated the msgs definition” mean? @Benja

I mean this:

Yes, to be more precise: I use ubuntu 20.04 and ros foxy (in my case is source installed but it should be the same)

sorry, I don’t know how to manually generate the message definitions, since the tutorial by that link is may me fuse, yes it didn’t work.@Benja

can you get me some detail @Benja

parallels@ubuntu-linux-20-04-desktop:/media/psf/Home/Proj/PX4-Autopilot$ python3 Tools/generate_microRTPS_bridge.py -s msg/sensor_baro.msg -r msg/sensor_combined.msg
python3: can't open file 'Tools/generate_microRTPS_bridge.py': [Errno 2] No such file or directory
parallels@ubuntu-linux-20-04-desktop:/media/psf/Home/Proj/PX4-Autopilot/msg$ python3 Tools/generate_microRTPS_bridge.py  PX4-Autopilot/msg/ px4_msgs/msg/
usage: generate_microRTPS_bridge.py [-h] [-a] [-c] [-i] [-j IDL_DIR] [-m] [-l] [-t MSGDIR] [-b UORB_TEMPLATES]
                                    [-q URTPS_TEMPLATES] [-y YAML_FILE] [-p PACKAGE] [-o AGENTDIR] [-u CLIENTDIR]
                                    [-f [FASTRTPSGEN]] [-g FASTRTPSGEN_INCLUDE] [-r [ROS2_DISTRO]] [--delete-tree]
generate_microRTPS_bridge.py: error: unrecognized arguments: PX4-Autopilot/msg/ px4_msgs/msg/

You don’t have to generate the whole microRTPS_bridge. You only need to generate the message definitions.
You are running the wrong script.
The right one is uorb_to_ros_msgs.py. Please see the link above.

Thx a lot for your support, @Benja.
I have it working now with the Micro XRCE-DDS and microROS. Though, I couldn’t thorougly test it, yet. Maybe, I’ll run into issues with this setup and have to switch back to the micrortps agent. We will see…

1 Like

Thank you @Benja. Your solution solved my issue (Ubuntu 18.04, ROS2 Dashing, latest PX4 main repo).

I have another tips for some other guys who may encounter the same error:
When you guys recompile the ros2 source, you first need to completely delete already built files.
That is,

rm -r /path/to/px4_ros_com_ros2/build
rm -r /path/to/px4_ros_com_ros2/install

Then, recompile the ros2 workspace following the instruction: ROS 2 User Guide (PX4-ROS 2 Bridge) | PX4 User Guide
Otherwise, same errors are reproduced even you recompile the source files.