Skip to content

Commit dc9d06c

Browse files
author
Minggang Wang
committed
Install rclnodejs which works on the stable release of ROS 2
Fix #114
1 parent 341ed13 commit dc9d06c

File tree

10 files changed

+74
-105
lines changed

10 files changed

+74
-105
lines changed

Diff for: Dockerfile

+23-33
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,31 @@ ENV GIT_USER_NAME mrbuild
44
ENV GIT_USER_EMAIL [email protected]
55
ENV LANG en_US.UTF-8
66

7-
RUN apt-get update && apt-get install -y git wget locales python
7+
RUN apt-get update && apt-get install -y git wget curl locales python
88
RUN locale-gen en_US en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
99

1010
RUN /bin/bash -c 'echo "deb http://packages.ros.org/ros/ubuntu xenial main" > /etc/apt/sources.list.d/ros-latest.list' \
1111
&& apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 421C365BD9FF1F717815A3895523BAEEB01FA116
1212

13+
RUN apt install -y gnupg2 lsb-release
14+
RUN curl http://repo.ros2.org/repos.key | apt-key add -
15+
RUN sh -c 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
16+
1317
# Install prerequisites
14-
RUN apt update && apt install -y \
15-
libopencv-dev \
16-
libasio-dev \
17-
libeigen3-dev \
18-
libtinyxml2.6.2v5 \
19-
libtinyxml2-dev \
20-
libfreetype6 \
21-
libgles2-mesa-dev \
22-
libglu1-mesa-dev \
23-
libqt5core5a \
24-
libqt5gui5 \
25-
libqt5opengl5 \
26-
libqt5widgets5 \
27-
libx11-dev \
28-
libxaw7 \
29-
libcurl4-openssl-dev \
30-
python3-argcomplete \
31-
python3-catkin-pkg-modules \
32-
python3-empy \
33-
python3-pip \
34-
python3-pyparsing \
35-
python3-setuptools \
36-
python3-yaml \
37-
python3-colcon-common-extensions \
38-
cmake \
39-
cppcheck
40-
41-
RUN pip3 install -U setuptools
18+
RUN export DEBIAN_FRONTEND=noninteractive && apt update && apt install -y \
19+
build-essential \
20+
cmake \
21+
python3-colcon-common-extensions \
22+
python3-pip \
23+
python-rosdep \
24+
python3-vcstool \
25+
libpython3-dev \
26+
libtinyxml2.6.2v5 \
27+
libtinyxml2-dev \
28+
cppcheck
29+
30+
RUN rosdep init
31+
RUN rosdep update
4232

4333
# Configure git
4434
RUN git config --global user.name $GIT_USER_NAME \
@@ -48,14 +38,14 @@ RUN git config --global user.name $GIT_USER_NAME \
4838
ENV ROS2_WS=/root
4939
WORKDIR $ROS2_WS
5040

51-
RUN wget https://ci.ros2.org/view/packaging/job/packaging_xenial_linux/lastSuccessfulBuild/artifact/ws/ros2-package-linux-x86_64.tar.bz2 \
52-
&& tar xf ros2-package-linux-x86_64.tar.bz2
41+
RUN wget https://github.com/ros2/ros2/releases/download/release-crystal-20190408/ros2-crystal-20190408-linux-xenial-amd64.tar.bz2 \
42+
&& tar xf ros2-crystal-20190408-linux-xenial-amd64.tar.bz2
5343

5444
RUN echo "source $ROS2_WS/ros2-linux/local_setup.bash" >> $HOME/.bashrc
5545

5646
# Install nvm, Node.js and node-gyp
57-
ENV NODE_VERSION v8.11.3
58-
RUN wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash \
47+
ENV NODE_VERSION v10.15.3
48+
RUN wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash \
5949
&& . $HOME/.nvm/nvm.sh \
6050
&& nvm install $NODE_VERSION && nvm alias default $NODE_VERSION
6151

Diff for: README.md

+7-23
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
ros2-web-bridge, which leverages the [rclnodejs](https://github.com/RobotWebTools/rclnodejs) client, provides a JSON interface to [ROS 2.0](https://github.com/ros2/ros2/wiki) by adopting the [rosbridge v2 protocol](https://github.com/RobotWebTools/rosbridge_suite/blob/develop/ROSBRIDGE_PROTOCOL.md). The bridge can process commands through JSON tuneled over WebSockets.
88

9+
## ROS2 support
10+
11+
The ros2-web-bridge **SUPPORTS** the latest ROS 2 stable release by default, please visit the [relase channel](https://github.com/ros2/ros2/releases) to check out the information.
12+
13+
Any one who wants to run on the nightly build of ROS 2, please change the `dependencies` section of [package.json](https://github.com/RobotWebTools/ros2-web-bridge/blob/develop/package.json) file to install other version of [rclnodejs](https://github.com/RobotWebTools/rclnodejs#match-with-ros-20-stable-releases).
14+
915
## Supported Clients
1016

1117
A client is a program that communicates with ros2-web-bridge using its JSON API. Clients include:
@@ -16,7 +22,7 @@ A client is a program that communicates with ros2-web-bridge using its JSON API.
1622

1723
1.Prepare for ROS2
1824

19-
Please reference the [wiki](https://github.com/ros2/ros2/wiki/Installation) to install ROS2.
25+
Please reference the [wiki](https://index.ros.org/doc/ros2/Installation/) to install ROS2.
2026

2127
2.Install `Node.js`
2228
You can install Node.js:
@@ -70,7 +76,6 @@ opreations | rosbridge v2.0 protocol spec | ros2-web-bridge implementation |
7076
:------------: | :------------ | :------------- |
7177
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](https://github.com/RobotWebTools/rosbridge_suite/blob/develop/ROSBRIDGE_PROTOCOL.md#343-publish--publish-). | If the subset of the msg is unspecified, then an error status message is sent and this message is dropped.
7278
subscribe | The type of the topic is [optional](https://github.com/RobotWebTools/rosbridge_suite/blob/develop/ROSBRIDGE_PROTOCOL.md#344-subscribe). | The type of the topic must be offered.
73-
call_service | No requirement of the service [type](https://github.com/RobotWebTools/rosbridge_suite/blob/develop/ROSBRIDGE_PROTOCOL.md#346-call-service). | You have to transfer both the request and the type of service through `args`.
7479

7580
If you use [roslibjs](https://static.robotwebtools.org/roslibjs/current/roslib.js) as the client running in the browser, please reference the code snippet below:
7681

@@ -90,27 +95,6 @@ example.subscribe(function(message) {
9095
});
9196
```
9297

93-
* Call a service.
94-
95-
```JavaScript
96-
let addTwoInts = new ROSLIB.Service({
97-
ros : ros,
98-
name : '/add_two_ints',
99-
serviceType : 'example_interfaces/AddTwoInts'
100-
});
101-
102-
let request = new ROSLIB.ServiceRequest({
103-
a : 1,
104-
b : 2
105-
});
106-
107-
// Encapsulate the request and the type of service into args.
108-
let args = {request: request, type: 'example_interfaces/AddTwoInts'};
109-
addTwoInts.callService(args, function(result) {
110-
console.log(`Receive result: ${result.sum}`);
111-
});
112-
```
113-
11498
## Contributing
11599

116100
If you want to contribute code to this project, first you need to fork the

Diff for: appveyor.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ branches:
88
image: Visual Studio 2017
99

1010
environment:
11-
nodejs_version: "8"
12-
PYTHON3: "c:\\Python37"
11+
nodejs_version: "10"
12+
PYTHON3: "c:\\Python37-x64"
1313
PYTHON2: "c:\\Python27"
1414

1515
clone_folder: c:\proj\ros2-web-bridge
@@ -25,8 +25,8 @@ before_build:
2525
- appveyor DownloadFile https://github.com/ros2/choco-packages/releases/download/2017-04-04-1/tinyxml-usestl.2.6.2.nupkg
2626
- appveyor DownloadFile https://github.com/ros2/choco-packages/releases/download/2018-06-12-1/tinyxml2.6.0.0.nupkg
2727
- choco install -y -s c:\download\ asio eigen tinyxml-usestl tinyxml2
28-
- appveyor DownloadFile http://ci.ros2.org/view/packaging/job/packaging_windows/lastSuccessfulBuild/artifact/ws/ros2-package-windows-AMD64.zip
29-
- 7z x -y "c:\download\ros2-package-windows-AMD64.zip" -o"c:\" > nul
28+
- appveyor DownloadFile https://github.com/ros2/ros2/releases/download/release-crystal-20190408/ros2-crystal-20190408-windows-release-amd64.zip
29+
- 7z x -y "c:\download\ros2-crystal-20190408-windows-release-amd64.zip" -o"c:\" > nul
3030
- setx -m OPENSSL_CONF C:\OpenSSL-Win64\bin\openssl.cfg
3131
- set PATH=C:\OpenSSL-Win64\bin;%PATH%
3232
- setx AMENT_PYTHON_EXECUTABLE "c:\Python37"

Diff for: examples/html/client.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@
5050
b : 2
5151
});
5252

53-
var args = {request: request, type: 'example_interfaces/AddTwoInts'};
54-
5553
// Send the request
56-
addTwoInts.callService(args, function(result) {
54+
addTwoInts.callService(request, function(result) {
5755
document.getElementById("sum").innerText = result.sum;
5856
console.log('Result for service call on ' + addTwoInts.name + ': ' + result.sum);
5957
});

Diff for: lib/bridge.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ class Bridge extends EventEmitter {
212212
this._registerOpMap('call_service', (command) => {
213213
let serviceName = command.service;
214214
let client =
215-
this._resourceProvider.createClient(this._exractServiceType(command.args.type), serviceName);
215+
this._resourceProvider.createClient(this._exractServiceType(command.type), serviceName);
216216

217217
if (client) {
218-
client.sendRequest(command.args.request, (response) => {
218+
client.sendRequest(command.args, (response) => {
219219
let serviceResponse =
220220
{op: 'service_response', service: command.service, values: response, id: command.id, result: true};
221221

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
},
4343
"dependencies": {
4444
"commander": "^2.12.2",
45-
"debug": "^3.1.0",
46-
"rclnodejs": "^0.x.0",
45+
"debug": "^4.1.1",
46+
"rclnodejs": "0.9.0",
4747
"uuid": "^3.1.0",
4848
"ws": "^6.0.0"
4949
}

Diff for: test/browser/test-service.html

+5-10
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
a: 1,
3737
b: 2
3838
});
39-
var args = {request: request, type: 'example_interfaces/AddTwoInts'};
40-
reqService.callService(args, function(result) {
39+
reqService.callService(request, function(result) {
4140
});
4241

4342
}, 'Service.advertise() positive case 1');
@@ -82,8 +81,7 @@
8281
a: 3,
8382
b: 4
8483
});
85-
var args = {request: request, type: 'example_interfaces/AddTwoInts'};
86-
reqService.callService(args, function(result) {
84+
reqService.callService(request, function(result) {
8785
assert_equals(result.sum, 7);
8886
t.done();
8987
});
@@ -141,8 +139,7 @@
141139
name: '/add_two_ints5',
142140
serviceType: 'example_interfaces/AddTwoInts'
143141
});
144-
var args = {request: {a: 9, b: 10}, type: 'example_interfaces/AddTwoInts'};
145-
reqService.callService(args, function(result) {
142+
reqService.callService({a: 9, b: 10}, function(result) {
146143
assert_equals(result.sum, 19);
147144
t.done();
148145
});
@@ -171,8 +168,7 @@
171168
var request = new ROSLIB.ServiceRequest({
172169
c: 9, d: 10
173170
});
174-
var args = {request: request, type: 'example_interfaces/AddTwoInts'};
175-
reqService.callService(args, function(result) {
171+
reqService.callService(request, function(result) {
176172
assert_unreached('Never go to here as callService() failed.');
177173
});
178174
setTimeout(function() {
@@ -211,8 +207,7 @@
211207
a: 11,
212208
b: 12
213209
});
214-
var args = {request: request, type: 'example_interfaces/AddTwoInts'};
215-
reqService.callService(args, function(result) {
210+
reqService.callService(request, function(result) {
216211
assert_true(result instanceof ROSLIB.ServiceResponse);
217212
assert_equals(result.sum, 23);
218213
t.done();

Diff for: test/nodejs/protocol/entry.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('Rosbridge v2.0 protocol testing', function() {
9191
require('./test-op-neg.js')();
9292
});
9393
describe('service_response operation', function() {
94-
require('./test-service-response.js')();
94+
require('./test-service-response.js');
9595
});
9696
});
9797

Diff for: test/nodejs/protocol/test-call-service.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ module.exports = function() {
4343
{
4444
title: 'call_service positive case 1: full fields',
4545
callServiceMsg: { op: 'call_service', id: 'call_service_id1', service: 'add_two_ints',
46-
args: {request: {a: 1, b: 2}, type: 'example_interfaces/AddTwoInts'},
46+
args: {a: 1, b: 2},
47+
type: 'example_interfaces/AddTwoInts',
4748
fragment_size: 1, compression: 'none'
4849
},
4950
responseCount: 2,
@@ -53,7 +54,8 @@ module.exports = function() {
5354
{
5455
title: 'call_service positive case 2: full fields with full service name',
5556
callServiceMsg: { op: 'call_service', id: 'call_service_id2', service: '/add_two_ints',
56-
args: {request: {a: 1, b: 2}, type: 'example_interfaces/AddTwoInts'},
57+
args: {a: 1, b: 2},
58+
type: 'example_interfaces/AddTwoInts',
5759
fragment_size: 1, compression: 'none'
5860
},
5961
responseCount: 2,
@@ -63,7 +65,8 @@ module.exports = function() {
6365
{
6466
title: 'call_service positive case 3: no id field',
6567
callServiceMsg: { op: 'call_service', service: 'add_two_ints',
66-
args: {request: {a: 3, b: 4}, type: 'example_interfaces/AddTwoInts'},
68+
args: {a: 3, b: 4},
69+
type: 'example_interfaces/AddTwoInts',
6770
fragment_size: 1, compression: 'none'
6871
},
6972
responseCount: 2,
@@ -73,7 +76,7 @@ module.exports = function() {
7376
{
7477
title: 'call_service positive case 4: no fragment_size field',
7578
callServiceMsg: { op: 'call_service', id: 'call_service_id4', service: 'add_two_ints',
76-
args: {request: {a: 5, b: 6}, type: 'example_interfaces/AddTwoInts'}, compression: 'none'
79+
args: {a: 5, b: 6}, type: 'example_interfaces/AddTwoInts', compression: 'none'
7780
},
7881
responseCount: 2,
7982
opStatus: 'none',
@@ -82,7 +85,7 @@ module.exports = function() {
8285
{
8386
title: 'call_service positive case 5: no compression field',
8487
callServiceMsg: { op: 'call_service', id: 'call_service_id5', service: 'add_two_ints',
85-
args: {request: {a: 7, b: 8}, type: 'example_interfaces/AddTwoInts'}, fragment_size: 1
88+
args: {a: 7, b: 8}, type: 'example_interfaces/AddTwoInts', fragment_size: 1
8689
},
8790
responseCount: 2,
8891
opStatus: 'none',
@@ -91,15 +94,14 @@ module.exports = function() {
9194
{
9295
title: 'call_service negative case 1: args without type information',
9396
callServiceMsg: { op: 'call_service', id: 'call_service_id6', service: 'add_two_ints',
94-
args: {request: {a: 9, b: 10}, fragment_size: 1, compression: 'none'}
95-
},
97+
args: {a: 9, b: 10}, fragment_size: 1, compression: 'none'},
9698
responseCount: 1,
9799
opStatus: 'error'
98100
},
99101
{
100102
title: 'call_service negative case 2: unknown service',
101103
callServiceMsg: { op: 'call_service', id: 'call_service_id7', service: 'add_two_float',
102-
args: {request: {a: 11, b: 12}, type: 'example_interfaces/AddTwoInts'},
104+
args: {a: 11, b: 12}, type: 'example_interfaces/AddTwoInts',
103105
fragment_size: 1, compression: 'none'
104106
},
105107
responseCount: 1,
@@ -108,7 +110,7 @@ module.exports = function() {
108110
{
109111
title: 'call_service field checking: invalid service',
110112
callServiceMsg: { op: 'call_service', id: 'call_service_id8', service: 42,
111-
args: {request: {a: 13, b: 14}, type: 'example_interfaces/AddTwoInts'},
113+
args: {a: 13, b: 14}, type: 'example_interfaces/AddTwoInts',
112114
fragment_size: 1, compression: 'none'
113115
},
114116
responseCount: 1,
@@ -136,10 +138,8 @@ module.exports = function() {
136138

137139
if (response.op === 'set_level') {
138140
assert.deepStrictEqual(response.level, testData.opStatus);
139-
if (testData.responseCount === 1) {
140-
ws.close();
141-
done();
142-
}
141+
ws.close();
142+
done();
143143
}
144144
if (testData.expectedResponse && response.op === testData.expectedResponse.op) {
145145
assert.deepStrictEqual(response.result, testData.expectedResponse.result);

0 commit comments

Comments
 (0)