Open beniaminopozzan opened 1 year ago
This issue has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:
I was able to track down the issue to rosidl_generate_interfaces
.
If
https://github.com/PX4/PX4-Autopilot/blob/fc357921fd69e574a3f596be25faa8f4d9cdcea9/platforms/ros2/CMakeLists.txt#L63-L65
is called from src/PX4-Autopilot/platforms/ros2/CMakeLists.txt
, which in return is called by
https://github.com/PX4/PX4-Autopilot/blob/fc357921fd69e574a3f596be25faa8f4d9cdcea9/CMakeLists.txt#L447-L448
then the issue occurs.
As soon as the content of src/PX4-Autopilot/platforms/ros2/CMakeLists.txt
is copied in the main CMakeLists.txt
file in the root of PX4, then everything works.
I confirmed once again that the issue occurs on Ubuntu 22, ROS Humble while on Ubuntu 20, ROS Foxy it works.
At this point I don't know if this is a ROS issue, CMAKE issue, colcon issue.
My guess is that project definition, and message generation should be performed in the same CMakeLists file. This kind of confirms the guess: https://answers.ros.org/question/361289/ros2-components-registration-from-subdirectory-cmakelists-file/
This is probably because in CMake each call to add_subdirectory() creates a new scope, meaning CMake variables set in the subdirectory are not visible to the parent directory.
I resolved same issue. After applying https://github.com/ament/ament_cmake/pull/431, re-build all and it worked.
Hi @DaesungAn !
You are right, I installed ros rolling
(base version) and made a clean build. It build successfully and ros2 interface proto px4_msgs/msg/TaskStackInfo
gives the proper output.
At that point I tried to replace https://github.com/PX4/px4_msgs with this in tree package. I did the following test:
px4_msgs
_I independently compiled workspace A and B, both of them extending only the bare ros2 rolling. The compilations were successful and I could get ros2 interface proto
of the px4 messages from both workspaces. Then the real test:
fatal error: px4_msgs/msg/offboard_control_mode.hpp: No such file or directory
on all px4_msgs that I try to include and use.
@DaesungAn Did you try something similar?
At this point I went and see the content of the install
directories of Workspace A and B, they should be the same, but they are not, in particular workspace B is missing files that I presume are related to the command ament_export_dependencies(rosidl_default_runtime)
. However, even adding it just before ament_package()
in https://github.com/PX4/PX4-Autopilot/blob/main/platforms/ros2/cmake/finalize.cmake does not change the result.
I still think that part of the output of rosidl_generate_interfaces
is hidden from ament_cmake
due to the use of add_subdirectory
On the left workspace B, on the right workspace A
"As soon as the content of src/PX4-Autopilot/platforms/ros2/CMakeLists.txt is copied in the main CMakeLists.txt file in the root of PX4, then everything works." @beniaminopozzan: would you please show me which lines I need to copy to solve the problem? Thanks
I was getting the same exception from the terminal in which I was trying to call ros2 topic echo ...
because I wasn't sourcing the install/setup.sh
of the workspace in which I was building px4_msgs. I use a single workspace, so this probably doesn't apply to everyone, but hopefully it helps out a few.
Hi @beniaminopozzan , I am trying to repeat the change you made to avoid the
add_subdirectory(platforms/${PX4_PLATFORM})
problem in PX4-Autopilot/CMakeLists.txt.
But I can not understand what did you do...If I simply copy&paste the from PX4-Autopilot/platform/ros2/CMakeLists.txt I get an error about the px4 target already exists.
I have trying to resolve it, but I can not understand what I have to do...can you please help?
Describe the bug
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.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.
colcon
workspaceModify 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 with
git apply << adapt-dds_topic.patch.txt
px4
packagewhich will return something like
which will return
you will get the error
make px4_sitl gazebo
, the microDDS agent enabledMicroXRCEAgent udp4 -p 8888
, then all topics are available but they cannot be echoed.will return the error
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,gives
while echoing a topic gives the expected echo.