px4_ros_com
px4_ros_com copied to clipboard
Optical Flow Message Mismatch
Description
There is a message topic mismatch between the px4_ros_com package and the main PX4 firmware UORB topics.
In the default urtps_bridge_topics.yaml found under <PX4-Firmware>/msg/tools, the topic optical_flow is required. In the default urtps_bridge_topics.yaml found under px4_ros_com/src/templates, however, sensor_optical_flow is required by default. If one were to generate the latter yaml file by using the script uorb_to_ros_urtps_topics.py provided (by following directions in the yaml file), the auto_generated yaml file would required a message named OpticalFlow, which is nowhere to be found in the px4_msgs package. This mismatch would result in a build error and prevent micrortps_agent from building.
Procedure to Reproduce
- Use
uorb_to_ros_urtps_topics.pyin the px4 firmware folder to generate a newurtps_bridge_topics.yaml:
./uorb_to_ros_urtps_topics.py -i urtps_bridge_topics.yaml -o updated.yaml
- Replace the default yaml file in px4_ros_com with the auto-generated yaml file
mv updated.yaml <PATH/TO/px4_ros_com/templates> && cd $_
rm urtps_bridge_topics.yaml && mv updated.yaml $_
- Build px4_ros_com package
# either run colcon build or run the build_ros2_workspace.bash script
also running into this issue when using master branches across px4_ros_com, PX4-Autopilot, and px4_msgs
note: if you are not using --verbose argument when running build_ros2_workspace.bash then you will end up with a more vague error output as such...
+ ./src/px4_ros_com/scripts/build_ros2_workspace.bash
openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)
[0.139s] WARNING:colcon.colcon_core.package_selection:ignoring unknown package 'ros1_bridge' in --packages-skip
Starting >>> px4_msgs
[Processing: px4_msgs]
[Processing: px4_msgs]
[Processing: px4_msgs]
[Processing: px4_msgs]
[Processing: px4_msgs]
[Processing: px4_msgs]
Finished <<< px4_msgs [3min 19s]
Starting >>> px4_ros_com
--- stderr: px4_ros_com
openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)
c++: error: /root/ros2_ws/build/px4_ros_com/src/micrortps_agent/microRTPS_agent.cpp: No such file or directory
c++: fatal error: no input files
compilation terminated.
make[2]: *** [CMakeFiles/micrortps_agent.dir/build.make:497: CMakeFiles/micrortps_agent.dir/src/micrortps_agent/microRTPS_agent.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:142: CMakeFiles/micrortps_agent.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:141: all] Error 2
---
Failed <<< px4_ros_com [30.8s, exited with code 2]
Only when running it with --verbose (i.e using args --event-handlers console_direct+ for colcon build) will it become apparent where the root issue lies, which is as @WillWu88 pointed out
[ 6%] Building CXX object CMakeFiles/sensor_combined_listener.dir/src/examples/listeners/sensor_combined_listener.cpp.o
openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)
Traceback (most recent call last):
File "/root/ros2_ws/src/px4_ros_com/scripts/generate_microRTPS_bridge.py", line 449, in <module>
generate_agent(agent_out_dir)
File "/root/ros2_ws/src/px4_ros_com/scripts/generate_microRTPS_bridge.py", line 311, in generate_agent
px_generate_uorb_topic_files.generate_topic_file(msg_file, msg_dir, "", out_dir, urtps_templates_dir,
File "/root/ros2_ws/src/px4_ros_com/scripts/px_generate_uorb_topic_files.py", line 274, in generate_topic_file
em_globals = get_em_globals(
File "/root/ros2_ws/src/px4_ros_com/scripts/px_generate_uorb_topic_files.py", line 296, in get_em_globals
spec = genmsg.msg_loader.load_msg_from_file(
File "/root/.local/lib/python3.8/site-packages/genmsg/msg_loader.py", line 284, in load_msg_from_file
with open(file_path, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/root/ros2_ws/install/px4_msgs/share/px4_msgs/msg/OpticalFlow.msg'