please check https://github.com/RobotWebTools/ros2-web-bridge for the fundamental installation
- Prepare for ROS 2 Please reference the documentation to install ROS 2.
- Install
Node.js
You can install Node.js: - Clone and install dependencies
Note that a ROS 2 installation has to be sourced before installing dependencies.
$ git clone https://github.com/RobotWebTools/ros2-web-bridge.git $ cd ros2-web-bridge $ source /opt/ros/$DISTRO/setup.sh # or a source installation $ npm install
- Make sure to source a ROS 2 installation, e.g.:
$ source /opt/ros/$DISTRO/setup.sh # or a source installation
- Start
ros2-web-bridge
module:If you want to start in client mode (i.e. connecting the bridge to an existing websocket server), do this instead:$ node bin/rosbridge.js
$ node bin/rosbridge.js --address ws://<address>:<port>
- Start the express server:
$ cd examples && node index.js
- Open your browser, and navigate to URL: http://localhost:3000/html/publisher.html
-
Open your browser, and navigate to URL : (default) ws/example/html/cmd_vel_pub.html
-
Set Connection as same as your ws://
: and check the button "connect!" (default)_http://localhost:9090 (it can be changable as your flavor) -
If you can see the connected sign, you are fully ready for sending the topic
(I took a test using turtlebot_node as the picture)
- Subscribe to a topic.
// Define a topic with its type. var example = new ROSLIB.Topic({ ros : ros, name : '/example_topic', messageType : 'std_msgs/String' }); // Subscribe to a topic. example.subscribe(function(message) { console.log(`Receive message: ${message}`); });
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.
This project abides by Apache License 2.0.