The provided code is :
add_service_files(
FILES
MyCustomServiceMessage.srv
)
but there is no MyCustomServiceMessage in the srv directory.
Is that supposed to be SummitXLPose.srv ??
And . . . if it is, where do we get SummitXLPoseResponse and SummitXLPoseRequest from in the following line of the python service script ?
from my_summit_xl_tools.srv import SummitXLPose, SummitXLPoseResponse, SummitXLPoseRequest
Hello @adeoduye ,
Yes, that’s an error in the notebook. The message file is SummitXLPose.srv. Whenever you compile a Service message (.srv), 2 extra messages are generated, which correspond to the request and response messages of a service (you can learn more about this in the ROS Basics course). These messages are:
<your_service_msg>Request
- the request part of the message
<your_service_msg>Response
- the response part of the message
Hope this helps,
1 Like
Grasias Alberto.
But I have a problem with the extra messages. They are not being generated.
I have this in package.xml:
<build_depend>message_generation</build_depend>
<build_export_depend>message_generation</build_export_depend>
<exec_depend>message_runtime</exec_depend>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>rospy</build_depend>
<build_export_depend>rospy</build_export_depend>
<exec_depend>rospy</exec_depend>
And in CMakeList.txt:
cmake_minimum_required(VERSION 3.0.2)
project(my_summit_xl_tools)
find_package(catkin REQUIRED COMPONENTS
rospy
std_msgs
message_generation
)
Generate services in the ‘srv’ folder
add_service_files(
FILES
SummitXLPose.srv
)
Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
std_msgs # Or other packages containing msgs
)
catkin_package(
INCLUDE_DIRS include
LIBRARIES my_summit_xl_tools
CATKIN_DEPENDS
rospy
DEPENDS system_lib
)
include_directories(
include
${catkin_INCLUDE_DIRS}
)
And the script, as copied and pasted, generates an error:
user:~/catkin_ws$ rosrun my_summit_xl_tools spots_to_file.py
Traceback (most recent call last):
File “/home/user/catkin_ws/src/my_summit_xl_tools/src/spots_to_file.py”, line 4, in
from my_summit_xl_tools.srv import SummitXLPose, SummitXLPoseResponse, SummitXLPoseRequest
ImportError: No module named my_summit_xl_tools.srv
Hello @adeoduye ,
Have you compiled and sourced the web shells before trying to run the program?
catkin_make
source ~/catkin_ws/devel/setup.bash
This is mandatory so that your program can find the messages. Maybe it would also be a good idea to have a look at the Services Units in the ROS Basics in 5 Days course so that you can better understand how services (and services messages) work.
Best,