Skip to content

Latest commit

 

History

History
86 lines (65 loc) · 3.07 KB

File metadata and controls

86 lines (65 loc) · 3.07 KB

rosbridge2cpp Build Status

A C++11 library to interface ROS via rosbridge

This library can be used to talk to ROS and ROS2 via rosbridge. It enables you to communicate with ROS even if you don't have the full ROS Stack on your machine available (for example, when you are using Windows). The network communication of this library uses WebSocket protocol for compatibility with ROS2 rosbridge.

Please note that this library is in an early development stage and features are added as needed. Even though the library supports JSON and BSON, it's strongly recommended to use BSON.

Dependencies

Before you can compile the library, you need to install websocketpp, jsoncpp, libbson, and Boost.

sudo apt update
sudo apt install -y libwebsocketpp-dev libjsoncpp-dev libbson-dev libboost-all-dev

If you want to run rosbridge on the same machine:

# For ROS1 and ROS2
sudo apt install -y ros-${ROS_DISTRO}-rosbridge-suite

Compiling the library

Now you can clone this repo. Please use --recursive if you want to use the unit tests. After cloning the repo, change into that directory and execute:

mkdir build
cd build
cmake .. # or 'cmake .. -Dtest=on' if you build the unit tests
make 

Usage

The library provides two transport options:

WebSocket Client (ROS2 Compatible)

Checkout src/client/websocket_client.cpp for an example implementation using WebSocket connections.

For ROS2 (Recommended):

ros2 run rosbridge_server rosbridge_websocket
# or
ros2 launch rosbridge_server rosbridge_websocket_launch.xml

For ROS1:

roslaunch rosbridge_server rosbridge_websocket.launch bson_only_mode:=True

TCP Client (ROS1 Compatible)

Checkout src/client/tcp_client.cpp for an example implementation using TCP connections.

For ROS1:

roslaunch rosbridge_server rosbridge_tcp.launch bson_only_mode:=True

Building Both Clients

The CMakeLists.txt builds both clients:

  • websocket_client - WebSocket client (default)
  • tcp_client - TCP client (for ROS1 compatibility)

Running the unit tests

Please ensure that the you executed cmake with '-Dtest=on' before you continue. When the library and the unit tests are compiled, execute the following commands on a machine running ROS to setup a minimal testing environment:

ROS2

ros2 run rosbridge_server rosbridge_websocket
ros2 topic pub /test std_msgs/String "data: 'a5424890996794277159554918'"
ros2 run examples_rclcpp_minimal_service add_two_ints_server

For ROS1

roslaunch rosbridge_server rosbridge_websocket.launch # plus bson_only_mode:=True if you want to use BSON
rostopic pub /test std_msgs/String a5424890996794277159554918
rosrun rospy_tutorials add_two_ints_server