[ROS2][dashing] is there any roslibpy-like lib for ros2 frontend? [closed]
I am looking for a way for a non-ROS machine (my local computer) to access the ROS2 robot(Rasberry pi) to, for example, call the service. Is there any method to do so? I found a similar post, but it's about a year ago.
Since I confirmed that both ros-dashing-rosbridge-server
and tf2
are already available in ROS2, I tried to use roslibpy
. Seems it can connect to the ros2 without any problem. I am wondering if it is the proper way to use roslibpy
for my purpose?
Below is what I did, however, I got FieldTypeMismatchException
error.
I followed the online examples to create a service '/set_ludicrous_speed', 'std_srvs/srv/SetBool'.
import roslibpy
def handler(request, response):
print('Setting speed to {}'.format(request['data']))
response['success'] = True
return True
client = roslibpy.Ros(host='10.3.xxx.xxx', port=9090)
service = roslibpy.Service(client, '/set_ludicrous_speed', 'std_srvs/srv/SetBool')
service.advertise(handler)
print('Service advertised.')
client.run_forever()
client.terminate()
While, when I try to call the service like below:
import roslibpy
client = roslibpy.Ros(host='10.3.xxx.xxx', port=9090)
client.run()
service = roslibpy.Service(client, '/set_ludicrous_speed', 'std_srvs/srv/SetBool')
request = roslibpy.ServiceRequest({'data': True})
result = service.call(request)
print('Service response: {}'.format(result))
client.terminate()
I got error like this, but I can see the node is connected and the service is created:
[INFO] [rosbridge_websocket]: Client disconnected. 0 clients total.
[INFO] [rosbridge_websocket]: Client connected. 1 clients total.
[INFO] [rosbridge_websocket]: [Client 1] Advertised service /set_ludicrous_speed.
[INFO] [rosbridge_websocket]: Client connected. 2 clients total.
[ERROR] [rosbridge_websocket]: [Client 2] [id: call_service:/set_ludicrous_speed:1] call_service FieldTypeMismatchException: std_srvs/SetBool_Request message requires a boolean for field data, but got a <class 'bool'>
Any idea what did I miss? Thank you very much.
You tagged this
ros2
anddashing
. Afaik,roslibpy
androsbridge
are ROS 1 libraries/nodes.Could you please clarify?
@gvdhoorn I am sorry for the confusion. Actually, I need a frontend (ideally in python) to access ROS2-dashing env. Then I found this post. It mentioned Robot web tool and rosbridge_suite. Since seems both
ros-dashing-rosbridge-server
andtf2
are already available in ROS2, so I thought maybe I could useroslibpy
to access the ROS2 dashing. Seems my whole approach was wrong. >.<I have changed my question. Thank you.
Well, I'm not saying that's the case, I just wanted to make sure I understood the context correctly.