Closed philianeles closed 2 years ago
@philianeles this is actually python complaining, not roslibpy
, you're trying to create a dictionary with two values, but the dict
constructor takes only key/value pairs. If va
contains the keys and ha
the values, you can create it with:
data = {}
data[va] = ha
notice that va
is not the key, but the value of va
is... that is not the case if you write dict(va=ha)
in which va
will literally be the key.
But service messages have a much stricter format than what your code implies... if you use the code above, your service request will have keys that change dynamically based on the content of VA_user_input
, which doesn't seem like what ROS msgs support at all. If you add the service msg type here, I can probably point you in the right direction...
Yes! my bad, the correct version should have been this:
service = roslibpy.Service(ros_client, '/plt_ros/cmd/pose_set_absolute', 'plt_msgs/SetPose')
for va, ha in zip(VA_user_input, HA_user_input):
request = roslibpy.ServiceRequest(dict(VA=va, HA=ha))
call_service(service, request)
which would imply having keys that change dynamically...
plt_msgs/SetPose
is a (custom) service msg:
float32 HA
float32 VA
---
ResponseCode response
aha! so, does that change fix the problem? can we close the issue? or is there something else still open?
not sure yet - I could not test it with the hardware, not connected atm, but will follow-up here asap!
Hi, I am trying to send a list of "va" and "ha" values in a
ServiceREquest
, on line 51 below:And running into the error that can also be seen above. Is there a way to send a list in a
ServiceRequest
?Thank you for the help!