service [/service_name] responded with an error: b'error processing request: field value must be of type bytes or an ascii string'
I want to run a service from python code using subprocess
as it was recommended here, but when I do so, I get the following error: service [/service_name] responded with an error: b'error processing request: field value must be of type bytes or an ascii string'
,
note that inside my node I'm mapping back the parameters from string to list of list of floats using
json.loads(lst)
to read them as floats list in order to define them as RobTarget
my service file .srv
is:
abb_rapid_msgs/RobTarget pickpoint
abb_rapid_msgs/RobTarget placepoint
---
bool success
Can you please tell me what might be a possible cause of this problem, and how can I solve it? thanks in advance.
#!/usr/bin/python3
import subprocess
import rospy
pick_pt = "[[0.285266, 0.3534495, 0.10697140000000001], [0.005935209, 0.9999219, 0.01035514, 0.003705649], [-1.0, 1.0, 2.0, 4.0], [156.847]]"
place_pt = "[[0.399374, 0.05215265, 0.11088379999999999], [0.005965178, 0.9999416, -0.006217764, -0.00652423], [-1.0, 1.0, 1.0, 4.0], [-160.319]]"
rospy.wait_for_service('/yumi/rws/set_rapid_symbol')
subprocess.run(["rosrun", "yumi_rapid_interface", "yumi_pickplace_rapid_node.py", pick_pt, place_pt])
Could you please explain why you want to do this?
Without more context or rationale, this seems like an incredibly convoluted and brittle way to do things.
@gvdhoorn yes, I want to provide a ros service to run a RAPID routine of pick/place tasks by defining the pick/place points externally in order to provide a simple interface to other colleagues who are not familiar with the robot, just using python and simple ros concepts. The ABB
run_rapid_routine
service works perfectly with the pick/place points already defined internally inside the robot controller RAPID code, I can call it from the command line using therun_rapid_routine
service provided by ABB driver, but I want to provide a simple interface to pass the points externally to the robot controller.So why not create a
rospy
service client and call the service directly?Like in wiki/Writing a Simple Service and Client (Python)?
And a suggestion: using the generic
geometry_msgs/PoseStamped
would be better. Try to avoid using package-specific messages as much as possible.@gvdhoorn thanks for your kind suggestion, the problem was that I'm passing the RAPID symbol as
RobTarget
instead of a raw text format as mentioned hereI'm not sure I understand what you're saying, but as long as you're using a regular
rospy.ServiceProxy
instead ofsubprocess
for a simple service call I'd be happy.