How to send rosservice call message from a c++ package?
Hello all,
I am writing a package written in c++ for ros-melodic on ubuntu 18.04.
I need to send service call to a node that takes 3 values as following service call from terminal to change LED color.
$ rosservice call /set_led_color "red: ###
green: ###
blue: ##"
The node have service file definition under "node_name/srv" as Color.srv and its contents as following
int64 red
int64 green
int64 blue
--
And in node.py the service is coded as
from omo_r1mini_bringup.srv import Color, ColorResponse
rospy.Service('set_led_color', Color, self.save_led_color_service_handle)
def save_led_color_service_handle(self, req):
command = "$sCOLOR," + str(req.red) + ',' + str(req.green) + ',' + str(req.blue)
self.ph.write_port(command)
return ColorResponse()
I tried to initialize my service client by
svc_client = n.serviceClient("/set_led_color", true);
however it is not working.