PX4-Autopilot: px4_sitl_rtps doesn't work with px4_ros_com micrortps_bridge
Describe the bug
In the master
branch of this repo (from about a month ago), I could follow the steps described here to get data from the px4_sitl_rtps gazebo
simulator to cross the micrortps bridge and show up in ROS2. I could also run the offboard_mode example with ROS2.
Around July 8, the master
branch of this repo was merged into main
. When that occurred, data from the px4_sitl_rtps gazebo
simulator would be sent over the micrortps bridge, but the micrortps_agent would die with this 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)
I believe the bug is associated with this issue/fix, which was made on the master
branch, but doesn’t appear to be fully integrated into the main
branch. The first file seems fine. The second file doesn’t. I tried editing the second file associated with this MR (which appears to be renamed slightly to msg/templates/uorb_microcdr/msg.cpp.em
), but was unable to get it to work.
When I revert the repo to an earlier version (i.e., right before the master
-> main
merge by using git checkout 10a2b4c9f7d34234459b4d3604b99a33491a9d83
), everything works properly (i.e., data is sent over the micrortps bridge, the micrortps_agent receives it, and you can ros2 topic echo
any of the messages).
I have checked whether the px4_msgs
or px4_ros_com
repos have changed in the previous month. They have not. The source of the miscommunication across the micrortps bridge appears to be associated with recent changes to the PX4-Autopilot repo.
To Reproduce
Steps to reproduce the behavior:
- In terminal 1, get the latest version of this repo and start the simulator:
git clone https://github.com/PX4/PX4-Autopilot --recursive cd ~/PX4-Autopilot make make px4_sitl_rtps make px4_sitl_rtps gazebo
- In terminal 2, follow the steps described here to install Fast-DDS, ROS2, and the px4_ros_com_ros2 workspace. When running the sanity check the installation section, you will run these commands:
which will produce this error:source ~/px4_ros_com_ros2/install/setup.bash micrortps_agent -t UDP
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)
- In terminal 1, revert the PX4-Autopilot to an earlier version and restart the simulator:
cd ~/PX4-Autopilot git checkout 10a2b4c9f7d34234459b4d3604b99a33491a9d83 make make px4_sitl_rtps make px4_sitl_rtps gazebo
- In terminal 2, restart the micrortps_agent (
micrortps_agent -t UDP
). It should not die. - In terminal 3, you can now
ros2 topic echo
any of the fields and it will print out data:ros2 topic echo /fmu/sensor_combined/out --- timestamp: 1657838030351792 gyro_rad: - -0.0005326324608176947 - -0.0007989492150954902 - -0.0007989475270733237 gyro_integral_dt: 4000 accelerometer_timestamp_relative: 0 accelerometer_m_s2: - 0.06823474913835526 - 0.07062912732362747 - -9.889251708984375 accelerometer_integral_dt: 4000 accelerometer_clipping: 0 gyro_clipping: 0 accel_calibration_count: 0 gyro_calibration_count: 1
Expected behavior
There should be no error when performing step 2 above.
Log Files and Screenshots
N/A
Drone:
px4_sitl_rtps (iris rtps)
Additional context
None
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (7 by maintainers)
Commits related to this issue
- msg/position_controller_landing_status.msg: fix constant name conventions - msg constant names now comply with ROS conventions: uppercase alphanumeric characters with underscores for separating words ... — committed to beniaminopozzan/PX4-Autopilot by beniaminopozzan 2 years ago
- msg/position_controller_landing_status.msg: fix constant name conventions - msg constant names now comply with ROS conventions: uppercase alphanumeric characters with underscores for separating words ... — committed to PX4/PX4-Autopilot by beniaminopozzan 2 years ago
I have done a
git pull
to get the latest code (git hash30e2490d5b50c0365052e00d53777b1f4068deab
). This version has @beniaminopozzan’s fix. (I confirmed that the filemsg/position_controller_landing_status.msg
has the correct naming conventions.)In Terminal 1, I ran the following commands:
In Terminal 2, I ran the following commands:
I still get this error (which is the same one I was getting before):
In Terminal 2, I ran the following commands:
The terminal does not die!
In terminal 3, I could now
ros2 topic echo
any of the fields and it will print out data:As far as I understand, the problem has been identified (and then fixed) by @beniaminopozzan.
@dirksavage88, as a tangent, can you share more details about your workaround (perhaps in the thread I am linking below)? There is a separate issue which involves a bottleneck with the fact that PX4-Autopilot automatically starts a single
micrortps_client
daemon. This single instance is responsible for serving data to however manymicrortps_agent
s are running (e.g., if I run./gazebo_sitl_multiple_run.sh -n 5 -t px4_sitl_rtps
… and then start up 5micrortps_agents
, the singlemicrortps_client
is responsible for serving data to all fivemicrortps_agents
). When the-n
argument gets large, themicrortps_client
is unable to service them all in a timely fashion and things do not work. I think that having multiplemicrortps_client
s would solve the problem. Your post seems to indicate that you start themicrortps_client
manually (instead of it being started automatically), which leads me to believe that I may be able to start multiple instances of it. If you could comment on the linked post, I’d appreciate it!I have moved on to use the micro-ROS-Agent instead, and then start the microdds_client on the PX4 side (command line options can be found in the px4 modules list). This (microdds client) works on main btw.
@mrpollo @hamishwillee I find the microdds may be more user friendly to set up than the micrortps installation and setup in the px4 docs.