Open
Description
Describe the bug
- Starting from initial minimal PX4_ROS2 platform and px4_ros2_default build #20689 it should be possible to built px4 msgs directly from the main repo using
colcon
without need of the packagepx4_msgs
. The package is indeed built, all PX4 msgs seems to be available, they can be listed bypx4 interface package px4
and the message definition can be inspected bypx4 interface show ...
. However,px4 interface proto
fails and returnsModuleNotFoundError
as in https://stackoverflow.com/questions/74859379/ros2-throws-modulenotfounderror-when-calling-interface-proto-for-custom-msg
I got this error only on an Ubuntu 22.04 machine running ros humble. On another machine with Ubuntu 20.04 with ros foxy everything works smoothly. - Secondary problem: the package name is
px4
while the usual px4 messages are under the packagepx4_msgs
. Assuming the the compilation works, adapting https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/microdds_client/dds_topics.yaml is required.
To Reproduce
Steps to reproduce the behavior, assuming: ros2 humble installed from binaries, PX4 toolchain configured.
- Create a new
colcon
workspacemkdir -p ~/px4_colcon_ws/src cd ~/px4_colcon_ws/src
- Clone PX4-Autopilot
git clone https://github.com/PX4/PX4-Autopilot.git --recursive
- Modify at least one entry of https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/microdds_client/dds_topics.yaml such that the required message type belongs to
px4
package instead ofpx4_msgs
, for example VehicleOdometrythe diff file adapt-dds_topic.patch.txt can be applied withdiff --git a/src/modules/microdds_client/dds_topics.yaml b/src/modules/microdds_client/dds_topics.yaml index 3a871848bb..90506a5821 100644 --- a/src/modules/microdds_client/dds_topics.yaml +++ b/src/modules/microdds_client/dds_topics.yaml @@ -36,7 +36,7 @@ publications: type: px4_msgs::msg::VehicleLocalPosition - topic: /fmu/out/vehicle_odometry - type: px4_msgs::msg::VehicleOdometry + type: px4::msg::VehicleOdometry - topic: /fmu/out/vehicle_status type: px4_msgs::msg::VehicleStatus
git apply << adapt-dds_topic.patch.txt
- source the ros2 environment
source /opt/ros/humble/setup.bash
- compile the workspace
colcon build --symlink-install
- source the workspace
source install/local_setup.bash
- It is now possible to list all message associated to the newly compiled
px4
packagewhich will return something likeros2 interface package px4
px4/msg/InputRc px4/msg/HeaterStatus px4/msg/QshellRetval px4/msg/VehicleAngularVelocity px4/msg/Airspeed px4/msg/SensorGps . . .
- And it is possible to inspect the message definitions
which will return
ros2 interface show px4/msg/Ping
uint64 timestamp # time since system start (microseconds) uint64 ping_time # Timestamp of the ping packet uint32 ping_sequence # Sequence number of the ping packet uint32 dropped_packets # Number of dropped ping packets float32 rtt_ms # Round trip time (in ms) uint8 system_id # System ID of the remote system uint8 component_id # Component ID of the remote system
- However, when trying to create a prototype of any message
you will get the error
ros2 interface proto px4/msg/Ping
Traceback (most recent call last): File "/opt/ros/humble/bin/ros2", line 33, in <module> sys.exit(load_entry_point('ros2cli==0.18.5', 'console_scripts', 'ros2')()) File "/opt/ros/humble/lib/python3.10/site-packages/ros2cli/cli.py", line 89, in main rc = extension.main(parser=parser, args=args) File "/opt/ros/humble/lib/python3.10/site-packages/ros2interface/command/interface.py", line 35, in main return extension.main(args=args) File "/opt/ros/humble/lib/python3.10/site-packages/ros2interface/verb/proto.py", line 33, in main yaml = interface_to_yaml(args.type) File "/opt/ros/humble/lib/python3.10/site-packages/ros2interface/api/__init__.py", line 46, in interface_to_yaml interface = utilities.get_interface(identifier) File "/opt/ros/humble/lib/python3.10/site-packages/rosidl_runtime_py/utilities.py", line 23, in get_interface return import_message_from_namespaced_type(get_namespaced_type(identifier)) File "/opt/ros/humble/lib/python3.10/site-packages/rosidl_runtime_py/import_message.py", line 30, in import_message_from_namespaced_type module = importlib.import_module( File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked ModuleNotFoundError: No module named 'px4'
- At the same time, if a simulation is started
make px4_sitl gazebo
, the microDDS agent enabledMicroXRCEAgent udp4 -p 8888
, then all topics are available but they cannot be echoed.will return the errorros2 topic echo /fmu/out/vehicle_odometry
The message type 'px4/msg/VehicleOdometry' is invalid
Expected behavior
The expected behavior can be easily seen using px4_msgs
packages are message container and repeating all the above test with it. In particular,
ros2 interface proto px4_msgs/msg/TaskStackInfo
gives
"timestamp: 0
ping_time: 0
ping_sequence: 0
dropped_packets: 0
rtt_ms: 0.0
system_id: 0
component_id: 0
"
while echoing a topic gives the expected echo.