Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dependency on ament_index_cpp to resolve build error in ROS 2 #24

Conversation

TakashiSato
Copy link

This PR adds a dependency on ament_index_cpp to the package to resolve a build error encountered in ROS 2.
The missing dependency was causing issues during the build process, specifically related to including headers from ament_index_cpp.
Adding this dependency ensures that the necessary components are available for successful compilation.

Testing Environment

OS: Ubuntu 24.04 (Docker)
ROS 2: Jazzy

Build Error Log

The following is the build error log that prompted this change:

Starting >>> choreonoid_ros
--- stderr: choreonoid_ros
/home/ubuntu/ws_cnoid/src/choreonoid_ros/src/node/choreonoid_ros2.cpp:1:10: fatal error: ament_index_cpp/get_package_prefix.hpp: No such file or directory
    1 | #include <ament_index_cpp/get_package_prefix.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [src/node/CMakeFiles/choreonoid.dir/build.make:76: src/node/CMakeFiles/choreonoid.dir/choreonoid_ros2.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:185: src/node/CMakeFiles/choreonoid.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
/home/ubuntu/ws_cnoid/src/choreonoid_ros/src/plugin/BodyROS2Item.cpp: In member function ‘void cnoid::BodyROS2Item::update3DRangeSensor(cnoid::RangeSensor*, rclcpp::Publisher<sensor_msgs::msg::PointCloud2_<std::allocator<void> > >::SharedPtr)’:
/home/ubuntu/ws_cnoid/src/choreonoid_ros/src/plugin/BodyROS2Item.cpp:681:22: warning: unused variable ‘sinPitchAngle’ [-Wunused-variable]
  681 |         const double sinPitchAngle = sin(pitchAngle);
      |                      ^~~~~~~~~~~~~
gmake: *** [Makefile:146: all] Error 2

Changes

Updated package.xml and CMakeLists.txt to include ament_index_cpp as a dependency.

Testing

Successfully built and tested the package with the new dependency included.
Verified that the build error is no longer present after the addition of the dependency.

@s-nakaoka
Copy link
Member

Sorry, I had committed the fix for this issue in commit 8d2b078 without noticing your pull request. However, the change to package.xml wasn't included, so I've incorporated your correction for that part ( de948af ). Thanks for your cooperation.

@TakashiSato
Copy link
Author

No problem at all, I’m glad to hear that the issue has been resolved. I will go ahead and close this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants