0
$\begingroup$

Rosanswers logo

Hello,

I have been looking everywhere for documentation on how to add .srv files to a workspace when using the Python build system for ROS2. I assume something needs to go in the setup.py (as well as the package.xml) but don't know what to add.

To be clear, I just want to define a simple service.srv for use in my custom package, and can't figure out how to import my service into my python script (seems like documentation on this is sparse...).

Thanks in advance!


Originally posted by stbuebel on ROS Answers with karma: 5 on 2019-05-08

Post score: 0


Original comments

Comment by gvdhoorn on 2019-05-09:
It would perhaps be good to use a separate package to store your service definition. It's a best practice in any version of ROS as it makes it possible to use your service definition (and by that being able to invoke your service) wthout having to build (or even have access to) your Python package.

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

You can't define messages and services in a pure Python package. The reason is that for every interface file the types for various languages needs to be generated (even if you only want to use Python). All that logic is only available in CMake packages since it requires to compile c and C++ libraries etc.


Originally posted by Dirk Thomas with karma: 16276 on 2019-05-08

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$
0
$\begingroup$

Rosanswers logo

I don't believe we support message generation from a pure Python package. You have to use CMake if you want to define new message or service types.

The reason for this is likely that we need to generate (and sometimes compile) code for each support language when you define a new message or service, and we only have infrastructure to do that in CMake.


Originally posted by William with karma: 17335 on 2019-05-08

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

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