ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Rosbridge is a perfect solution, though I would go by www.rosbridge.org rather than the rosbridge stack on the ROS wiki, as we are in the process of releasing a rosbridge v2 but not quite to the point of release yet.
All you need to do is pick a language, pick a websockets library, and go from there. You can check out some example rosbridge commands on this page: http://rosbridge.org/doku.php?id=rosbridge_v2.0_example_commands
2 | No.2 Revision |
Rosbridge is a perfect solution, though I would go by www.rosbridge.org rosbridge.org rather than the rosbridge stack on the ROS wiki, as we are in the process of releasing a rosbridge v2 but not quite to the point of release yet.
All you need to do is pick a language, pick a websockets library, and go from there. You can check out some example rosbridge commands on this page:
http://rosbridge.org/doku.php?id=rosbridge_v2.0_example_commands
To get up and running, all you need to do is pick a language, pick a websockets library, and go from there.
For example, a python websocket client that calls a service (using the python-websocket websocket client library):
from websocket import WebSocket
from json import dumps
# Callback handler for incoming messages
def my_msg_handler(msg):
print 'Got "%s"!' % msg
# Create websocket connection and pass incoming messages to the handler
socket = WebSocket('ws://localhost:9090', onmessage=my_msg_handler)
# When the socket opens, call a service
def get_loggers():
msg = {'op': 'call_service', 'service': '/rosout/get_loggers'}
socket.send(dumps(msg))
socket.onopen = get_loggers
try:
asyncore.loop()
except KeyboardInterrupt:
socket.close()
3 | No.3 Revision |
Rosbridge is a perfect solution, though I would go by rosbridge.org rather than the rosbridge stack on the ROS wiki, as we are in the process of releasing a rosbridge v2 but not quite to the point of release yet.
You can check out some example rosbridge commands on this page: http://rosbridge.org/doku.php?id=rosbridge_v2.0_example_commands
To get up and running, all you need to do is pick a language, pick a websockets library, and go from there.
For example, a python websocket client that calls a service (using the python-websocketws4py websocket client library):
from websocket import WebSocket
from json import dumps
# Callback handler for incoming messages
def my_msg_handler(msg):
print 'Got "%s"!' % msg
# Create websocket connection and pass incoming messages to the handler
socket = WebSocket('ws://localhost:9090', onmessage=my_msg_handler)
# When the socket opens, call a service
def get_loggers():
from ws4py.client.threadedclient import WebSocketClient
class GetLoggersClient(WebSocketClient):
def get_loggers(self):
msg = {'op': 'call_service', 'service': '/rosout/get_loggers'}
socket.send(dumps(msg))
socket.onopen self.send(dumps(msg))
def opened(self):
print "Connection opened..."
self.get_loggers()
def closed(self, code, reason=None):
print code, reason
def received_message(self, m):
print "received", m
if __name__=="__main__":
try:
ws = get_loggers
try:
asyncore.loop()
GetLoggersClient('ws://127.0.0.1:9090/')
ws.connect()
except KeyboardInterrupt:
socket.close()
ws.close()
4 | Clarified description of rosbridge |
Rosbridge is a perfect solution, though I would go solution. You can write a client that connects to rosbridge using any language that has a websocket library. Websocket is a poor choice of name for the protocol because it implies use by web browsers only. Sure, it was designed for web browsers, but the protocol itself is just a layer on top of TCP and provides a number of useful properties.
As for the rosbridge ROS node - we have just released rosbridge v2.0 beta, which is the 'industrial strength' rosbridge. It has a much more robust server implementation and a more well defined protocol. We haven't yet officially released v2.0 on ROS.org so the information on the ROS wiki is still for v1.0. The most up to date resource is rosbridge.org rather than the (for both v1.0 and v2.0 of rosbridge). The source code repository for v2.0 is here.
To give you the gist of how rosbridge stack on the ROS wiki, as we are in the process of releasing a rosbridge v2 but not quite to the point of release yet.
You works, you can check out some example rosbridge commands on this page:
http://rosbridge.org/doku.php?id=rosbridge_v2.0_example_commandspage.
To get up and running, actually write a client that connects to rosbridge, all you need to do is pick a language, pick is a websockets library, and go from there.
library. For example, a the following python websocket client that connects and calls a service (using ROS service. In the example we use the ws4py websocket client library):library.
from json import dumps
from ws4py.client.threadedclient import WebSocketClient
class GetLoggersClient(WebSocketClient):
def get_loggers(self):
msg = {'op': 'call_service', 'service': '/rosout/get_loggers'}
self.send(dumps(msg))
def opened(self):
print "Connection opened..."
self.get_loggers()
def closed(self, code, reason=None):
print code, reason
def received_message(self, m):
print "received", m
if __name__=="__main__":
try:
ws = GetLoggersClient('ws://127.0.0.1:9090/')
ws.connect()
except KeyboardInterrupt:
ws.close()