0
$\begingroup$

Rosanswers logo

I am writing a service and this is the message :

std_msgs/String pose
---
sensor_msgs/JointState finalpos 

This is the client :

#!/usr/bin/env python

import rospy 
from interbotix_moveit.srv import pickitstr,pickitstringResponse
from std_msgs.msg import String
rospy.init_node('service_arm_client')
word=String()
rospy.wait_for_service('/widowxl/arm_service')

pose = rospy.ServiceProxy('/widowxl/arm_service',pickitstr)
word = pickitstringResponse()
word= 'Upright'
finalpose = pose(word)
print(finalpose.finalpose)

And I get this error :

Traceback (most recent call last):
File "/home/michael/catkin_ws/src/interbotix_ros/interbotix_moveit/src/service_client_test.py", line 13, in finalpose = pose(word) File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py", line 435, in call return self.call(*args, **kwds) File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py", line 512, in call transport.send_message(request, self.seq) File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_base.py", line 665, in send_message serialize_message(self.write_buff, seq, msg) File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/msg.py", line 152, in serialize_message msg.serialize(b) File "/home/michael/catkin_ws/devel/lib/python2.7/dist-packages/interbotix_moveit/srv/_pickitstr.py", line 58, in serialize _x = self.pose.data AttributeError: 'str' object has no attribute 'data'

What Is the problem ?


Originally posted by MichaelDUEE on ROS Answers with karma: 15 on 2020-02-25

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Well in your case pose is a server proxy, not an actual pose or a string pose request as defined in your srv. Also you are not creating your srv request for the call properly. Check the documentation for the std_msg/Sring.
You can try the following:

word=String()
word.data= 'Upright'
srv_proxy = rospy.ServiceProxy(step.context.set_navigation_config_service_name, String)
response = srv_proxy(word)

The response should be of type sensor_msgs/JointState and you should be able to access its data with response.specific_field (for example response.name[0] to get the name of the first joint).


Originally posted by pavel92 with karma: 1655 on 2020-02-26

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

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