Hello! (First-time poster so please excuse any errors.) I have been following the PX4-ROS 2 Bridge tutorial and am able to get the Sanity Check and Offboard Control examples working with SITL simulation through jMAVSim.
However, I am stuck when it comes to generating a custom RTPS listener (similar to sensor_combined_listener.cpp). To illustrate this, let’s say I want to create a wind_listener.cpp to print the contents of Wind.msg:
Broadly, I am unsure of:
- what files must be created (e.g., wind_listener.cpp, wind_listener.launch.py), and where (e.g., /px4_ros_com_ros2/src/px4_ros_com/src/examples/listeners or elsewhere),
- what edits must be made (e.g., to which CMakeLists.txt),
- what build process must be completed (e.g., build_ros2_workspace.bash)
I have tried several approaches (including
fastrtpsgen -example x64Linux2.6gcc ../micrortps_agent/idl/sensor_combined_.idl) but I think I am missing something higher-level from the tutorial. Any advice is appreciated. Thank you!
I don’t have a ton of experience with ROS2 but this is what I can tell you.
First of all, I greatly recommend you to check this link to learn about writing publishers or subscribers in ROS2.
For your questions:
- You can create wind_listerner.cpp file in the examples folder but you don’t have to.
*You don’t have to make a launch file at first. It is generally used for launching multiple nodes at once.
- You need to add your node to CMakeList as a custom_executable (examples are in that CMakeList)
- If you have any new dependencies you need to add them to CMakeList and package.xml files.
- I believe build_ros2_workspace.bash should be enough.
Thank you so much! This was very helpful. I read through the ROS2 link and was able to write the
wind_listener.cpp and edit
package.xml files and build the workspace as you described.
However, when I run
ros2 run px4_ros_com wind_listener, I only get
Starting wind listener node... but no data.
I presume this has something to do with the fact that
Wind publisher started is not listed under Publishers when I run
micrortps_agent -t UDP.
SensorCombined publisher started is listeed.)
Furthermore, If I check:
ros2 topic echo /Wind_PubSubTopic
WARNING: topic [/Wind_PubSubTopic] does not appear to be published yet
Could not determine the type for the passed topic
Are there any changes that must be made to
micrortps_agent in order to start the publisher?
Update: I am able to get
- Wind publisher started to appear after editing uorb_rtps_message_ids.yaml (on both the PX4-Autopilot and px4_ros_com_ros2 sides.) However, my
make px4_sitl_rtps now fails with an error as described in my reply to another post:
src/modules/micrortps_bridge/micrortps_client/microRTPS_client.cpp:55:10: fatal error: uORB_microcdr/topics/wind.h: No such file or directory
55 | #include <uORB_microcdr/topics/wind.h>
hi @nsimon , have u solved this problem? im facing the same issue. I’ve read the comments on the other post that u linked but there are no update. please let me know, bye.
Hi @FedeUnibo, I am no longer listening to
wind.msg as multicopter platforms do not perform wind estimation. However, I still receive the same error (
<topic>.h: No such file or directory) when writing custom listeners and advertisers to uORB topics not included in the source code. Here are two posts that seem to have helped others:
To make matters a bit more interesting, there were major recent changes to the PX4-Autopilot repository (see microRTPS: more fixes and improvements #18052 ), and some of the tutorial/forum advice has yet to be updated. (For example, urtps_bridge_topics.yaml has replaced uorb_rtps_message_ids.yaml.
Keep me updated of your progress!
Thanks @nsimon, i had a look at the links in your answer and i finally solve my problem deleting also the directory /build/px4_sitl_rtps before issuing the make command. Thanks for your help, best regards.