Create a srv folder inside session3_cliserver folder
mkdir -p ~/ros_workshop/src/session3_cliserver/srvOpen the folder
cd ~/ros_workshop/src/session3_cliserver/srvCreate a .srv file with desired name. (we will select custom.srv as an example)
code custom.srvInside the file add following lines, then save and close.
uint8 a
uint8 b
---
uint16 resultOpen package.xml and add the following lines in the respective sections
<build_depend>message_generation</build_depend>
<exec_depend>message_runtime</exec_depend>Open the CMakeLists.txt and add following lines to respective section,
message_generation to find_package()
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
message_generation
)message_runtime to catkin_package
catkin_package(
...
CATKIN_DEPENDS message_runtime ...
...)uncomment add_service_files section and add custom.srv file
add_service_files(DIRECTORY
srv
FILES
custom.srv
)uncomment generate_messgae() section. It shoul look like this,
generate_messages(
DEPENDENCIES
std_msgs
)Move to the workspace root and rebuild
cd ~/ros_workshop/catkin buildor
catkin_make