0
$\begingroup$

Rosanswers logo

Hi,

source: https://github.com/ros2/examples/blob/master/rclcpp/minimal_client/main.cpp

In the example of the service Client they use following header file:

#include "example_interfaces/srv/add_two_ints.hpp"

I think it is necessary to make the server Client, to find the (example_interfaces::srv::AddTwoInts):

 rclcpp::Client<example_interfaces::srv::AddTwoInts::SharedPtr init = node->create_client<example_interfaces::srv::AddTwoInts>("init");

In my custom package I made some .srv files that I want to use, do I need a Header file as well ?

sum.srv
#include "my_package/srv/sum.hpp"

Obviously I don't have this .hpp file so it will throw an error. Do I need to make one myself or can I generate this file ?

Thanks


Originally posted by jlepers on ROS Answers with karma: 39 on 2020-02-13

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The headers are generated and not written by hand. You can generate them using the rosidl_generate_interfaces CMake macro (examnple here)

There doesn't seem to be an up-to-date tutorial explaining how to define and use custom interfaces at the moment.

I recommend you to create a package with only your custom messages / services files (you can look at https://github.com/ros2/example_interfaces for an example)

And use them in your package (using https://github.com/ros2/examples/tree/35674eb17494ab3f67cc5fbe5f127c614be2220b/rclcpp/minimal_client as an example)


Originally posted by marguedas with karma: 3606 on 2020-02-14

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by jlepers on 2020-02-14:
Thank you, I was trying something similar. Is it possible that I need to install ROS2 by source to use rosidl_default_generators instead of ROS2 Debian packages?

Comment by marguedas on 2020-02-14:\

Is it possible that I need to install ROS2 by source to use rosidl_default_generators instead of ROS2 Debian packages?

You should be able to use it from debian packages. You'll need to make sure that that package is installed (though I believe it is installed by default).

apt-get list --installed | grep rosidl-default-generators

Comment by jlepers on 2020-02-14:
edit:

apt list --installed | grep rosidl-default-generators

output:

ros-dashing-rosidl-default-generators/now 0.7.0-1bionic.20191016.185016 amd64 [installed,upgradable to: 0.7.0-1bionic.20191210.230356]

I guess this is fine, but I still have cmake troubles with the find_package(rosidl_default_generators REQUIRED) command.

Comment by jlepers on 2020-02-14:
Should I open a new question ?

Comment by marguedas on 2020-02-14:
Yes please. Can you make sure to add your full package.xml and CMakeLists (with the comment lines, starting with # removed for readability) ? This will help diagnose the issue

$\endgroup$

Your Answer

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