Giter Club home page Giter Club logo

ros2-web-bridge's Introduction

ros2-web-bridgeBuild StatusBuild statusnpmlicensedependencies Status

NPM

Server Implementations of the rosbridge v2 Protocol

ros2-web-bridge, which leverages the rclnodejs client, provides a JSON interface to ROS 2.0 by adopting the rosbridge v2 protocol. The bridge can process commands through JSON tuneled over WebSockets.

Supported Clients

A client is a program that communicates with ros2-web-bridge using its JSON API. Clients include:

  • roslibjs - A JavaScript API, which communicates with ros2-web-bridge over WebSockets.

Install

1.Prepare for ROS2

Please reference the wiki to install ROS2.

2.Install Node.js You can install Node.js:

  • Download from Node.js offical website, and install it.
  • Use the Node Version Manager (nvm) to install it.

3.Install dependencies

npm install

Run Examples

1.Start ros2-web-bridge module:

node bin/rosbridge.js

2.Start the express server:

cd examples && node index.js

3.Open your browser, and navigate to URL:

http://localhost:3000/html/publisher.html

Not supported op

Some experimental operations defined by rosbridge v2.0 protocol specification are not supported by ros2-web-bridge now, please check out the list:

and the authentication

Compability with rosbridge v2.0 protocol

We are trying to obey the rosbridge v2 protocol, but there are still some operation commands which can not follow the spec. The table below lists the differences:

opreations rosbridge v2.0 protocol spec ros2-web-bridge implementation
publish If the msg is a subset of the type of the topic, then a warning status message is sent and the unspecified fields are filled in with defaults. If the subset of the msg is unspecified, then an error status message is sent and this message is dropped.
subscribe The type of the topic is optional. The type of the topic must be offered.
call_service No requirement of the service type. You have to transfer both the request and the type of service through args.

If you use roslibjs as the client running in the browser, please reference the code snippet below:

  • Subscribe a topic.
// Define a topic with its type.
var example = new ROSLIB.Topic({
  ros : ros,
  name : '/example_topic',
  messageType : 'std_msgs/String'
});

// Subscribe a topic.
example.subscribe(function(message) {
  console.log(`Receive message: ${message}`);
});
  • Call a service.
let addTwoInts = new ROSLIB.Service({
  ros : ros,
  name : '/add_two_ints',
  serviceType : 'example_interfaces/AddTwoInts'
});

let request = new ROSLIB.ServiceRequest({
  a : 1,
  b : 2
});

// Encapsulate the request and the type of service into args.
let args = {request: request, type: 'example_interfaces/AddTwoInts'};
addTwoInts.callService(args, function(result) {
  console.log(`Receive result: ${result.sum}`);
});

Contributing

If you want to contribute code to this project, first you need to fork the project. The next step is to send a pull request (PR) for review. The PR will be reviewed by the project team members. Once you have gained "Look Good To Me (LGTM)", the project maintainers will merge the PR.

License

This project abides by Apache License 2.0.

ros2-web-bridge's People

Contributors

qiuzhong avatar kenny-y avatar jihoonl avatar

Watchers

James Cloos avatar Wanming Lin avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.