The easiest way to develop using the Websocket API is to use
roslibpy. Here is an example that
will listen to the robot’s odometry:
#!/usr/bin/env python
import roslibpy
client = roslibpy.Ros(host='192.168.3.42', port=9090)
client.run()
def callback(msg):
position = msg['pose']['pose']['position']
print(f"Received Pose: x={position['x']}, y={position['y']}")
listener = roslibpy.Topic(client, '/odometry/filtered', 'nav_msgs/Odometry')
listener.subscribe(callback)
try:
while True:
pass
except KeyboardInterrupt:
client.terminate()
A similar library can be created in C or C++ that follows the same Websocket
protocol.