0
$\begingroup$

I am using ros2 without colcon or ament in my project. It works with existing message types but now I want to use custom ros msgs in this project. I have no idea how to do that. For ros1 I can see an example at https://github.com/gerkey/ros1_external_use/tree/ros2/ros1_msgs and https://wiki.ros.org/ROS/Tutorials/CreatingMsgAndSrv%28plain%20cmake%29 (similar), but I couldn't find anything analogous for ros2. If anyone can help me on how to do that or point me to some resources that might help me will be of great help.

Note: I only want to build for cpp, and choosing to do it with raw cmake has been easier for me to understand and learn.

I have tried calling rosidl_generate_interfaces(...) inside the CMakeLists.txt. It gives an error that package.xml is missing the <member_of_group> statement. Since I am not using colcon/ament, I don't have a package.xml in my project. I could use the other libraries like rclcpp, sensor_msgs, etc., by treating them as usual cmake packages. But I don't know how to do this for rosidl_generator.

$\endgroup$
0

1 Answer 1

0
$\begingroup$

Not a 100% solution to your question - however a way you might want to choose.

The ROS2 documentation contains a full tutorial of how to create a working ros-package with custom msg and srv here: ROS2 custom msg and srv tutorial. Obviously they use colcon (other than your question). However (if you have colcon installed) you can build your own msg/srv package (with colcon), source it and than use it (the package) in what every way you want (e.g. the same way you are obviously using std_msgs right now).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.