Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jhurliman/remove png #2

Merged
merged 36 commits into from May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5645b4c
Replace travis by GH actions (#392)
MatthijsBurgh Apr 4, 2021
74fe3db
Small changes related to replacing travis by GH actions (#409)
MatthijsBurgh Apr 4, 2021
3058f0d
Bump socket.io from 2.2.0 to 4.0.1 (#410)
dependabot[bot] Apr 4, 2021
b976528
Accept ros distro as argument in Dockerfile (#412)
MatthijsBurgh Apr 8, 2021
0c9e2b0
Bump xmldom from 0.1.31 to 0.5.0 (#404)
dependabot[bot] Apr 8, 2021
18fb7e9
Bump grunt-contrib-jshint from 1.1.0 to 3.0.0 (#385)
dependabot[bot] Apr 8, 2021
6464293
Bump grunt-karma from 2.0.0 to 4.0.0 (#411)
dependabot[bot] Apr 8, 2021
3260d09
Bump grunt-mocha-test from 0.12.7 to 0.13.3 (#389)
dependabot[bot] Apr 8, 2021
2f75ec3
Bump karma-mocha from 1.3.0 to 2.0.1 (#416)
dependabot[bot] Apr 8, 2021
c83e768
Bump karma from 3.1.4 to 6.3.2 (#417)
dependabot[bot] Apr 8, 2021
d4766d0
Bump time-grunt from 1.4.0 to 2.0.0 (#414)
dependabot[bot] Apr 8, 2021
92808aa
Bump grunt-contrib-uglify from 1.0.2 to 5.0.1 (#418)
dependabot[bot] Apr 8, 2021
04f94f4
Bump grunt-contrib-clean from 1.1.0 to 2.0.0 (#415)
dependabot[bot] Apr 8, 2021
76749e6
Bump mocha from 2.5.3 to 8.3.2 (#405)
dependabot[bot] Apr 8, 2021
5b42ad1
Bump grunt-browserify from 5.3.0 to 6.0.0 (#421)
dependabot[bot] Apr 8, 2021
9834e73
Bump karma-firefox-launcher from 1.3.0 to 2.1.0 (#422)
dependabot[bot] Apr 8, 2021
dd6c496
Bump load-grunt-tasks from 3.5.2 to 5.1.0 (#423)
dependabot[bot] Apr 8, 2021
b51f21b
Update/lint README & CONTRIBUTING (#420)
MatthijsBurgh Apr 9, 2021
2e125d0
Update Dockerfile/CI tool versions (#424)
MatthijsBurgh Apr 9, 2021
f29a50f
(actions) dont't run pull_request on develop (#425)
MatthijsBurgh Apr 12, 2021
112f8dc
Bump xmldom from 0.5.0 to 0.6.0 (#427)
dependabot[bot] Apr 19, 2021
72aca8d
Sort dependencies (#428)
MatthijsBurgh Apr 21, 2021
21a32ec
Add support for custom encoding/decoding. (#397)
J-Rojas Apr 22, 2021
2b63457
Extend testing (#431)
MatthijsBurgh May 4, 2021
28ff4f5
(actions) run on noetic again (#432)
MatthijsBurgh May 4, 2021
907963f
(actions) drop kinetic as EOL has been reached (#434)
MatthijsBurgh May 7, 2021
1ecf89a
Bump mocha from 8.3.2 to 8.4.0 (#436)
dependabot[bot] May 10, 2021
f4a3b6d
Bump socket.io from 4.0.1 to 4.0.2 (#435)
dependabot[bot] May 10, 2021
5f20a0d
Widen package requirements (#438)
MatthijsBurgh May 10, 2021
be4f54d
Bump grunt-karma from 4.0.0 to 4.0.2 (#440)
dependabot[bot] May 17, 2021
32cd935
Bump socket.io from 4.0.0 to 4.1.1 (#441)
dependabot[bot] May 17, 2021
80554d8
Bump socket.io from 4.1.1 to 4.1.2 (#442)
dependabot[bot] May 24, 2021
5545924
Remove pngparse
jhurliman May 27, 2021
1670951
build
jhurliman May 27, 2021
fc97743
Merge branch 'develop' into jhurliman/remove-png
jhurliman May 27, 2021
6904cfd
:hocho:
jhurliman May 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/dependabot.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .npmignore
Expand Up @@ -2,6 +2,6 @@ test
examples
Gruntfile.js
.gitignore
.travis.yml
.github
bower.json
*.md
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

23 changes: 11 additions & 12 deletions CONTRIBUTING.md
@@ -1,24 +1,23 @@
roslibjs Build Setup
====================
# roslibjs Build Setup

[Grunt](http://gruntjs.com/) is used for building, including concatenating, minimizing, documenting, linting, and testing.

### Install Grunt and its Dependencies
## Install Grunt and its Dependencies

1. Install [Node.js](http://nodejs.org/) for your environment
2. Install the build task runner, [Grunt](http://gruntjs.com/)

```sh
$ [sudo] npm install -g grunt
```
```bash
$ [sudo] npm install -g grunt
```
3. Install the dependencies and build dependencies

```sh
$ cd /path/to/roslibjs/
$ [sudo] npm install
```
```bash
$ cd /path/to/roslibjs/
$ [sudo] npm install
```

### Build with Grunt
## Build with Grunt

Before proceeding, please confirm you have installed the dependencies above.

Expand All @@ -27,7 +26,7 @@ To run the build tasks:
1. `cd /path/to/roslibjs/`
2. `grunt build`

`grunt build` will concatenate and minimize the files under src and replace roslib.js and roslib.min.js in the build directory. It will also run the linter and test cases. This is what [Travis CI](https://travis-ci.org/RobotWebTools/roslibjs) runs when a Pull Request is submitted.
`grunt build` will concatenate and minimize the files under src and replace roslib.js and roslib.min.js in the build directory. It will also run the linter and test cases. This is what [GH Actions](https://github.com/RobotWebTools/roslibjs/actions) runs when a Pull Request is submitted.

`grunt dev` will watch for any changes to any of the src/ files and automatically concatenate and minimize the files. This is ideal for those developing as you should only have to run `grunt dev` once.

Expand Down
18 changes: 10 additions & 8 deletions Dockerfile
@@ -1,16 +1,18 @@
FROM ros:kinetic-ros-core
ARG ROS_DISTRO=melodic
FROM ros:$ROS_DISTRO-ros-core

ARG CI=true
ENV CI=$CI

ENV ROS_DISTRO=kinetic
# Dependencies for rosbridge
RUN apt update && apt-get install -y xvfb firefox git wget ros-$ROS_DISTRO-rosbridge-server ros-$ROS_DISTRO-tf2-web-republisher ros-$ROS_DISTRO-common-tutorials ros-$ROS_DISTRO-rospy-tutorials ros-$ROS_DISTRO-actionlib-tutorials
RUN apt update && apt-get install -y firefox git wget ros-$ROS_DISTRO-rosbridge-server ros-$ROS_DISTRO-tf2-web-republisher ros-$ROS_DISTRO-common-tutorials ros-$ROS_DISTRO-rospy-tutorials ros-$ROS_DISTRO-actionlib-tutorials

# Install nvm, Node.js and node-gyp
ENV NODE_VERSION v10.15.0
RUN wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash \
ARG NODE_VERSION=14
RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash \
&& . $HOME/.nvm/nvm.sh \
&& nvm install $NODE_VERSION && nvm alias default $NODE_VERSION \
&& npm install -g node-gyp

RUN echo "source /opt/ros/kinetic/setup.bash" >> $HOME/.bashrc
ENV PATH /bin/versions/node/$NODE_VERSION/bin:$PATH

RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> $HOME/.bashrc
ENV PATH=/bin/versions/node/$NODE_VERSION/bin:$PATH
21 changes: 16 additions & 5 deletions Gruntfile.js
Expand Up @@ -31,11 +31,19 @@ module.exports = function(grunt) {
]
},
karma: {
build: {
configFile: './test/karma.conf.js',
options: {
singleRun: true,
browsers: ['Firefox']
}
browsers: process.env.CI ? ['FirefoxHeadless'] : ['Firefox']
},
test: {
configFile: './test/karma.conf.js',
},
examples: {
configFile: './test/examples/karma.conf.js',
},
workersocket: {
configFile: './test/workersocket/karma.conf.js',
},
},
mochaTest: {
options: {
Expand Down Expand Up @@ -103,7 +111,10 @@ module.exports = function(grunt) {
});

grunt.registerTask('dev', ['browserify', 'watch']);
grunt.registerTask('test', ['jshint', 'mochaTest:test', 'browserify', 'karma']);
grunt.registerTask('test', ['jshint', 'mochaTest:test', 'karma:test']);
grunt.registerTask('test-examples', ['mochaTest:examples', 'karma:examples']);
grunt.registerTask('test-tcp', ['mochaTest:tcp']);
grunt.registerTask('test-workersocket', ['karma:workersocket']);
grunt.registerTask('build', ['browserify', 'uglify']);
grunt.registerTask('build_and_watch', ['watch']);
grunt.registerTask('doc', ['clean', 'jsdoc']);
Expand Down
40 changes: 26 additions & 14 deletions README.md
@@ -1,45 +1,57 @@
roslibjs [![Build Status](https://api.travis-ci.org/RobotWebTools/roslibjs.png)](https://travis-ci.org/RobotWebTools/roslibjs)
========
# roslibjs

[![CI](https://github.com/RobotWebTools/roslibjs/actions/workflows/main.yml/badge.svg)](https://github.com/RobotWebTools/roslibjs/actions/workflows/main.yml)

## The Standard ROS JavaScript Library

#### The Standard ROS JavaScript Library
For full documentation, see [the ROS wiki](http://wiki.ros.org/roslibjs) or check out some [working demos](http://robotwebtools.org/demos.html).

[JSDoc](http://robotwebtools.org/jsdoc/roslibjs/current/) can be found on the Robot Web Tools website.

This project is released as part of the [Robot Web Tools](http://robotwebtools.org/) effort.

### Usage
## Usage

Pre-built files can be found in either [roslib.js](build/roslib.js) or [roslib.min.js](build/roslib.min.js).

Alternatively, you can use the current release via the Robot Web Tools CDN: ([full](https://static.robotwebtools.org/roslibjs/current/roslib.js)) | ([min](https://static.robotwebtools.org/roslibjs/current/roslib.min.js))

### Troubleshooting
## Troubleshooting

1. Check that connection is established. You can listen to error and
connection events to report them to console. See
examples/simple.html for a complete example:

ros.on('error', function(error) { console.log( error ); });
ros.on('connection', function() { console.log('Connection made!'); });
```js
ros.on('error', function(error) { console.log( error ); });
ros.on('connection', function() { console.log('Connection made!'); });
```

1. Check that you have the websocket server is running on
2. Check that you have the websocket server is running on
port 9090. Something like this should do:

netstat -a | grep 9090
```bash
netstat -a | grep 9090
```

### Dependencies
## Dependencies

roslibjs has a number of dependencies. You will need to run:

`npm install`
```bash
npm install
```

Depending on your build environment.

### Build
## Build

Checkout [CONTRIBUTING.md](CONTRIBUTING.md) for details on building.

### License
## License

roslibjs is released with a BSD license. For full terms and conditions, see the [LICENSE](LICENSE) file.

### Authors
## Authors

See the [AUTHORS.md](AUTHORS.md) file for a full list of contributors.
28 changes: 0 additions & 28 deletions bower.json

This file was deleted.

48 changes: 23 additions & 25 deletions package.json
Expand Up @@ -2,45 +2,42 @@
"name": "roslib",
"homepage": "https://www.robotwebtools.org",
"description": "The standard ROS Javascript Library",
"version": "1.1.0",
"version": "1.1.1",
"license": "BSD-2-Clause",
"main": "./build/roslib.js",
"browser": {
"./src/RosLibNode.js": "./src/RosLib.js",
"canvas": "./src/util/shim/canvas.js",
"ws": "./src/util/shim/WebSocket.js",
"xmldom": "./src/util/shim/xmldom.js",
"./src/util/decompressPng.js": "./src/util/shim/decompressPng.js"
"xmldom": "./src/util/shim/xmldom.js"
},
"devDependencies": {
"chai": "*",
"grunt": "^1.0.1",
"grunt-browserify": "^5.0.0",
"grunt-browserify": "^6.0.0",
"grunt-cli": "^1.2.0",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-jshint": "^1.0.0",
"grunt-contrib-uglify": "^1.0.1",
"grunt-contrib-clean": "^2.0.0",
"grunt-contrib-jshint": "^3.0.0",
"grunt-contrib-uglify": "^5.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-jsdoc": "^2.1.0",
"grunt-karma": "^2.0.0",
"grunt-mocha-test": "^0.12.7",
"karma": "^3.1.4",
"grunt-karma": "^4.0.0",
"grunt-mocha-test": "^0.13.0",
"karma": "^6.3.0",
"karma-chai": "^0.1.0",
"chai": "*",
"karma-firefox-launcher": "^1.0.0",
"karma-mocha": "^1.1.1",
"load-grunt-tasks": "^3.3.0",
"mocha": "^2.3.3",
"time-grunt": "^1.0.0"
"karma-firefox-launcher": "^2.1.0",
"karma-mocha": "^2.0.0",
"load-grunt-tasks": "^5.1.0",
"mocha": "^8.3.0",
"time-grunt": "^2.0.0"
},
"dependencies": {
"cbor-js": "^0.1.0",
"eventemitter2": "^6.4.0",
"object-assign": "^4.0.1",
"pngparse": "^2.0.1",
"ws": "^7.2.1",
"xmldom": "^0.1.19",
"cbor-js": "^0.1.0",
"socket.io": "^4.0.0",
"webworkify": "^1.5.0",
"socket.io": "2.2.0"
"ws": "^7.2.1",
"xmldom": "^0.6.0"
},
"directories": {
"example": "examples",
Expand All @@ -51,10 +48,11 @@
},
"scripts": {
"prepack": "grunt build",
"build": "grunt build",
"test": "grunt test",
"test-examples": "grunt mochaTest:examples && xvfb-run -a karma start test/examples/karma.conf.js",
"test-workersocket": "grunt uglify && xvfb-run -a karma start test/workersocket/karma.conf.js",
"test-tcp": "grunt mochaTest:tcp"
"test-examples": "grunt test-examples",
"test-workersocket": "grunt test-workersocket",
"test-tcp": "grunt test-tcp"
},
"repository": {
"type": "git",
Expand Down
27 changes: 18 additions & 9 deletions src/core/Ros.js
Expand Up @@ -32,11 +32,13 @@ var EventEmitter2 = require('eventemitter2').EventEmitter2;
*/
function Ros(options) {
options = options || {};
var that = this;
this.socket = null;
this.idCounter = 0;
this.isConnected = false;
this.transportLibrary = options.transportLibrary || 'websocket';
this.transportOptions = options.transportOptions || {};
this._sendFunc = function(msg) { that.sendEncodedMessage(msg); };

if (typeof options.groovyCompatibility === 'undefined') {
this.groovyCompatibility = true;
Expand Down Expand Up @@ -120,14 +122,9 @@ Ros.prototype.authenticate = function(mac, client, dest, rand, t, level, end) {
this.callOnConnection(auth);
};

/**
* Sends the message over the WebSocket, but queues the message up if not yet
* connected.
*/
Ros.prototype.callOnConnection = function(message) {
var that = this;
var messageJson = JSON.stringify(message);
Ros.prototype.sendEncodedMessage= function(messageEncoded) {
var emitter = null;
var that = this;
if (this.transportLibrary === 'socket.io') {
emitter = function(msg){that.socket.emit('operation', msg);};
} else {
Expand All @@ -136,10 +133,22 @@ Ros.prototype.callOnConnection = function(message) {

if (!this.isConnected) {
that.once('connection', function() {
emitter(messageJson);
emitter(messageEncoded);
});
} else {
emitter(messageJson);
emitter(messageEncoded);
}
};

/**
* Sends the message over the WebSocket, but queues the message up if not yet
* connected.
*/
Ros.prototype.callOnConnection = function(message) {
if (this.transportOptions.encoder) {
this.transportOptions.encoder(message, this._sendFunc);
} else {
this._sendFunc(JSON.stringify(message));
}
};

Expand Down