Hello,
Im currently running the zed_node by the command: roslaunch zed_wrapper zed2.launch
There i see the service zed_interfaces/set_pose and I believe I can set the zed camera pose. This is my code so far looking from ROS wiki examples on using srv.
from zed_interfaces.srv import set_pose
def set_zedPose(x, y, z, R, P, Y):
rospy.wait_for_service(“zed_interfaces/set_pose”)
try:
set_pose = rospy.ServiceProxy(“zed_interfaces/set_pose”, zed_interfaces.srv.set_pose)
resp = set_pose(x, y, z, R, P, Y)
return resp
except rospy.ServiceException as e:
print(“unable to set pose”)
apologize if I do stupid mistake. Im still new to ROS and services. If someone has an example code for it, it would be very much appreciated.
Thank you.
Actually no error, but it stuck in rospy.wait_for_service(). Even though when I look on the list of services using rossrv list, there exist the service zed_interfaces/set_pose.
If I commented the line rospy.wait_for_service(), the line
Hi again. yes sorry for the stupid mistake. I thought “rossrv list” would give all the available ros services, but it just gives you the type. for anyone that is still newbie for me, use “rosservice list” instead.
I also attached my code if anyone is interested.
Set_Pose = set_pose()
def set_zedPose(x, y, z, R, P, Y):
print("waiting for set pose service")
rospy.wait_for_service("/zed2/zed_node/set_pose")
print("found the set_pose service!")
try:
setpose = rospy.ServiceProxy("/zed2/zed_node/set_pose", Set_Pose)
resp = setpose(x, y, z, R, P, Y)
print("response of the service is: ", resp)
return resp
except rospy.ServiceException as e:
print("service not working yet")
if everything goes well, the service would return: