Skip to main content

ROS WEBSOCKET BRIDGE

version license

Overview

This is a package for converting ROS 2 DDS to WebSocket. This project was inspired by rosbridge_suite by Robo Web Tools. The implemented features are not for specific topics or services but all available ros interfaces. It's in early development, and not all interfaces are tested. Any bug reported will be fixed in upcoming releases.

When using the suite, I faced issues with ROS 2 and couldn't find a way to move forward. So I decided to create another which is not advanced as the suite but gets my job done. I decided to package it and publish it on PyPI for easy availability to others and for learning purposes. The code I use is different, and the features are not the same. The client libraries for the suite won't work because this is not a suite clone.

Note: This project is not a suite clone. The architecture and implementation are different. Not all the features of the suite are not available in this project.

Requirements


  • Ubuntu 20.04
  • Python 3.8
  • ROS 2 Foxy

Installation


pip3 install ros2bridge

Usage


python3 -m ros2bridge

optional parameters:

  • -p, --port: For specific port. Default is 9020
  • -n, --ngrok: WebSocket is hosted on local IP by default. If this flag is set ws are hosted internally

NOTE: for using custom ros interface source that workspace before running the bridge.

Available ROS Interfaces


  • Publisher
  • Subscriber
  • Service Client
  • Action Client

TODO:

  • Service Server
  • Action Server

Request structure


Publisher

{
    "operation": "publish",
    "topic": "/<topic_name>",
    "type": "<message_parent>/<message_type>",
    "message": "<message>"
}
  • type eg: 'std_msgs/String'
  • message eg: {"data": "HELLO WORLD !"}
  • NOTE: the message should be in the format of the message type

Subscriber

{
    "operation": "subscribe",
    "topic": "/<topic_name>",
    "type": "<message_parent>/<message_type>",
}
  • type eg: 'std_msgs/String'

NOTE: Subscribed messages will return in this format.

{
    "operation": "subscribe",
    "topic": "/<topic_name>",
    "type": "<message_parent>/<message_type>",
    "message": "<message>"
}
  • type eg: 'std_msgs/String'
  • message eg: {"data": "HELLO WORLD !"}

NOTE: To unsubscribe from a topic send the following message to the server

{
    "operation": "subscribe",
    "topic": "/<topic_name>",
    "type": "<message_parent>/<message_type>",
    "unsubscribe": true
}
  • type eg: 'std_msgs/String'

SERVICE CLIENT

For creating a service client

{
    "operation": "srv_client",
    "action": "create",
    "srv_name": "/<service_name>",
    "srv_type": "<service_parent>/<service_type>"
}

For calling a service client

{
    "operation": "srv_client",
    "action": "call",
    "srv_name": "/<service_name>",
    "srv_type": "<service_parent>/<service_type>",
    "message": "<message>"

}
  • NOTE: the message should be in the format of the service type

ACTION CLIENT

For creating an action client

{
    "operation": "action_client",
    "action": "create",
    "action_name": "/<action_name>",
    "action_type": "<action_parent>/<action_type>"
}

For calling an action client

{
    "operation": "action_client",
    "action": "call",
    "action_name": "/<action_name>",
    "action_type": "<action_parent>/<action_type>",
    "message": "<message>"
}
  • NOTE: the message should be in the format of action type

Feedback from calling an action client

{
    "operation": "action_client",
    "action": "call",
    "action_response": "<action_response>",
    "action_name": "/<action_name>",
    "action_type": "<action_parent>/<action_type>",
    "message": "<message>"

}
  • NOTE: the message should be in the format of action type.
  • NOTE: action_response will be any of 'response', 'feedback', or 'result'.

QOS PROFILE

I added a QoS profile to the subscription. No validation of QoS is added and no error is sent back to the client.

Available QoS settings for subscribers:

  • QoSReliabilityPolicy
  • QoSDurabilityPolicy
  • QoSHistoryPolicy

For creating a Qos Profile add the following in addition to the above request syntax

"qos": {
    "durability": "<durability>",
    "reliability": "<reliability>",
    "history": "<history>",
}

For options to provide please refer to this docs

A general request will look like

{
    "operation": "subscribe",
    "topic": "/<topic_name>",
    "type": "<message_parent>/<message_type>",
    "qos": {
        "durability": "<durability>",
        "reliability": "<reliability>",
        "history": "<history>",
    }
}

Testing


For testing using tox, the ROS package is required and I haven't found a way to get around it. So testing within the system.

  • MYPY
  • FLAKE8
  • PYTEST

Metadata

Release files for ros2bridge 0.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ros2bridge 0.2.6
File Size Uploaded
ros2bridge-0.2.6.tar.gz 37.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ros2bridge 0.2.6
File Interpreter ABI Platform
ros2bridge-0.2.6-py3-none-any.whl Python 3 none any Details

Total release size: 54.9 kB

Release files / ros2bridge-0.2.6.tar.gz

Download URL ros2bridge-0.2.6.tar.gz
Size 37.4 kB
Tags Source
SHA-256 checksum
How to use checksums
24dde0acfe8612f1ab9b4cd74c42a2f1dbbf9dbe4bd14d1d5463e7759b0d26db
BLAKE2b-256 checksum
How to use checksums
bee1dc87435a5d3f0842d12d820692ef142c20f72290e8fb69a8557bbce28df0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Release files / ros2bridge-0.2.6-py3-none-any.whl

Download URL ros2bridge-0.2.6-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b98f07340f2b121c93983045cd160e05eaa7772e54adacb0fc04ed6810785ece
BLAKE2b-256 checksum
How to use checksums
bd3a54c9c52d1b9ab6206986f7a5498a0b0e01ea699d4d03abd69b1d310f9ca9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.2.6 This release

2 release files

0.2.5

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page