Skip to content

Commit b257149

Browse files
wayneparrottMinggang Wang
authored andcommitted
Reduce README length by dividing into smaller documents
README.md - added Documents section with TOC ./docs/BUILD.md - build instructions ./CONTRIBUTORS.md - list of contributors and short description of each contributors work. ./docs/CONTRIBUTING.md - short guide for how to contribute to the project ./docs/FAQ.md - faq topics and known issues Fix #761 Update README.md Added contributing guidelines.
1 parent 349ab6a commit b257149

File tree

5 files changed

+265
-176
lines changed

5 files changed

+265
-176
lines changed

CONTRIBUTORS.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
rclnodejs contributors (sorted alphabetically)
2+
==============================================
3+
4+
* **[Alex Mikhalev](https://github.com/amikhalev)**
5+
* Fix build for AMENT_PREFIX_PATH with multiple entries
6+
7+
* **[Felix Divo](https://github.com/felixdivo)**
8+
* Code cleanup of index.js, tests cases & message generation
9+
* Improved shutdown behavior
10+
* Fixed compilation warnings
11+
12+
* **[Hanyia](https://github.com/hanyia)**
13+
* Benchmark test script
14+
15+
* **[Kenny Yuan](https://github.com/kenny-y)**
16+
* Message features: JS generation, typed arrays, plain JS object, compound msgs, many others...
17+
* npm publish scripts
18+
* Mac support
19+
20+
* **[Matt Richard](https://github.com/mattrichard)**
21+
* ROS2 Actions
22+
* Guard conditions
23+
* Node utility methods (countPublishers/subscribers...)
24+
* TypeScript improvements
25+
* Node 12 compatibility
26+
27+
* **[Minggang Wang](https://github.com/minggangw)**
28+
* Author, lead developer, maintainer
29+
* Core, CI
30+
31+
* **[Martins Mozeiko](https://github.com/martins-mozeiko)**
32+
* QoS new/delete fix
33+
34+
* **[Qiuzhong](https://github.com/qiuzhong)**
35+
* Test coverage for actions, topics, multi-array messages, cross platform, security
36+
* Converted from setTimeout to ROS2 Timer
37+
38+
* **[Teo Koon Peng](https://github.com/koonpeng)**
39+
* TypeScript improvements
40+
* Added Client#waitForService
41+
* Code style improvements, e.g., Prettier formatting
42+
* Improved code generation smarts and efficiency
43+
44+
* **[Wayne Parrott](https://github.com/wayneparrott)**
45+
* TypeScript support with interface generation
46+
* ROS2 parameter support
47+
* ROS2 lifecycle node
48+
* Rate class
49+
* Node class hierarchy
50+

README.md

Lines changed: 33 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,48 @@
55
| develop | [![Build Status](https://travis-ci.org/RobotWebTools/rclnodejs.svg?branch=develop)](https://travis-ci.org/RobotWebTools/rclnodejs) | [![macOS Build Status](https://circleci.com/gh/RobotWebTools/rclnodejs/tree/develop.svg?style=shield)](https://circleci.com/gh/RobotWebTools/rclnodejs) | [![Build status](https://ci.appveyor.com/api/projects/status/upbc7tavdag1aa5e/branch/develop?svg=true)](https://ci.appveyor.com/project/minggangw/rclnodejs/branch/develop) |
66
| master | [![Build Status](https://travis-ci.org/RobotWebTools/rclnodejs.svg?branch=master)](https://travis-ci.org/RobotWebTools/rclnodejs) | [![macOS Build Status](https://circleci.com/gh/RobotWebTools/rclnodejs/tree/master.svg?style=shield)](https://circleci.com/gh/RobotWebTools/rclnodejs) | [![Build status](https://ci.appveyor.com/api/projects/status/upbc7tavdag1aa5e/branch/master?svg=true)](https://ci.appveyor.com/project/minggangw/rclnodejs/branch/master) |
77

8-
`rclnodejs` is a Node.js client for the Robot Operating System (ROS 2). It provides a simple and easy JavaScript API for ROS 2 programming. TypeScript declarations are included to support use of rclnodejs in TypeScript projects.
8+
`rclnodejs` is a Node.js client library for the Robot Operating System (ROS 2). It provides a JavaScript API and TypeScript declarations for ROS 2 programming.
99

1010
Here's an example for how to create a ROS 2 node that publishes a string message in a few lines of JavaScript.
1111

1212
```JavaScript
1313
const rclnodejs = require('rclnodejs');
1414
rclnodejs.init().then(() => {
15-
const node = rclnodejs.createNode('publisher_example_node');
15+
const node = new rclnodejs.Node('publisher_example_node');
1616
const publisher = node.createPublisher('std_msgs/msg/String', 'topic');
1717
publisher.publish(`Hello ROS 2 from rclnodejs`);
18-
rclnodejs.spin(node);
18+
node.spin();
1919
});
2020
```
21+
## Documentation
22+
- [Installation](#installation)
23+
- [API Documentation](#api-documentation)
24+
- [Using TypeScript](#using-typescript)
25+
- [Examples](https://github.com/RobotWebTools/rclnodejs/tree/develop/example)
26+
- [FAQ and Known Issues](./docs/FAQ.md)
27+
- [Building from Scratch](./docs/BUILDING.md)
28+
- [Contributing](./docs/CONTRIBUTING.md)
2129

22-
## Prerequisites
30+
## Installation
2331

24-
**Node.js**
32+
### Prerequisites
33+
Before installing `rclnodejs` please ensure the following softare is installed and configured on your systemd:
2534

26-
- [Node.js](https://nodejs.org/en/) version between 8.12 - 12.x.
35+
- [Nodejs](https://nodejs.org/en/) version between 8.12 - 12.x.
2736

28-
**ROS 2 SDK**
37+
- [ROS 2 SDK](https://index.ros.org/doc/ros2/Installation/) for details.
38+
**DON'T FORGET TO [SOURCE THE ROS 2 SETUP FILE](https://index.ros.org/doc/ros2/Tutorials/Configuring-ROS2-Environment/#source-the-setup-files)**
2939

30-
- See the ROS 2 SDK [Installation Guide](https://index.ros.org/doc/ros2/Installation/) for details.
31-
- **DON'T FORGET TO [SOURCE THE ROS 2 STARTUP FILES](https://index.ros.org/doc/ros2/Tutorials/Configuring-ROS2-Environment/#source-the-setup-files)**
32-
33-
## Install rclnodejs
40+
### Installing rclnodejs
3441

3542
Install the rclnodejs version that is compatible with your version of ROS 2 (see table below).
3643

37-
Run the following command for the most current version of rclnodejs
38-
44+
For the most current version of rclnodejs run:
3945
```bash
4046
npm i rclnodejs
4147
```
4248

43-
or to install a specific version of rclnodejs use
49+
To install a specific version of rclnodejs use:
4450

4551
```bash
4652
@@ -55,19 +61,13 @@ npm i [email protected]
5561

5662
## API Documentation
5763

58-
The API documentation is generated by `jsdoc`. To create a local copy run `npm run docs`. Alternatively you can use the prebuilt api documentation found in the `docs/` folder or view the [on-line version](http://robotwebtools.org/rclnodejs/docs/index.html) in your browser.
64+
API documentation is generated by `jsdoc` and can be viewed in the `docs/` folder or [on-line](http://robotwebtools.org/rclnodejs/docs/index.html). To create a local copy of the documentation run `npm run docs`.
5965

6066
## Using TypeScript
6167

62-
TypeScript declaration files (\*.d.ts) are included to support developers that wish to use rclnodejs in TypeScript projects.
63-
64-
In your node project, in addition to installing the rclnodejs package, you will need to install the TypeScript compiler and node typings.
65-
66-
```
67-
npm install typescript @types/node -D
68-
```
68+
`rclnodejs` API can be used in TypeScript projects. You can find the TypeScript declaration files (\*.d.ts) in the `types/` folder.
6969

70-
Your tsconfig.json file should include the following compiler options:
70+
Your project `tsconfig.json` file should include the following compiler options:
7171

7272
```jsonc
7373
{
@@ -80,177 +80,34 @@ Your tsconfig.json file should include the following compiler options:
8080
}
8181
```
8282

83-
Here's a simple example implemented in TypeScript.
83+
Here's a short `rclnodejs` TypeScript example:
8484

8585
```typescript
8686
import * as rclnodejs from 'rclnodejs';
8787
rclnodejs.init().then(() => {
88-
const node = rclnodejs.createNode('publisher_example_node');
88+
const node = new rclnodejs.Node('publisher_example_node');
8989
const publisher = node.createPublisher('std_msgs/msg/String', 'topic');
9090
publisher.publish(`Hello ROS 2 from rclnodejs`);
91-
rclnodejs.spin(node);
91+
node.spin();
9292
});
9393
```
9494

95-
The benefits of using TypeScript become evident when working with more complex use-cases. The ROS 2 messages are defined in the `types/interfaces.d.ts` module. This module is updated as part of the `generate_messages` process. Here's a trivial example of working with a String msg.
95+
The benefits of using TypeScript become evident when working with more complex use-cases. The ROS 2 messages in your environment are defined in the `types/interfaces.d.ts` module. This module is updated as part of the `generate-ros-messages` process. Here's a trivial example of working with a String msg.
9696

9797
```typescript
9898
const msg: rclnodejs.std_msgs.msg.String = {
9999
data: 'hello ROS2 from rclnodejs',
100100
};
101101
```
102102

103-
## Build from Scratch
104-
105-
### Get ready for ROS 2
106-
107-
1.Install ROS 2 from binary package.
108-
109-
ROS 2 is a cross-platform system, which covers Linux, macOS and Windows, and the `rclnodejs` module is developed against the [`master`](https://github.com/ros2/ros2/blob/master/ros2.repos) branch of ROS 2. You can download the latest binary packages from [ROS 2 build farm](http://ci.ros2.org/view/packaging/) and follow the instructions of [Linux](https://index.ros.org/doc/ros2/Installation/Linux-Install-Binary/)/[macOS](https://index.ros.org/doc/ros2/Installation/OSX-Install-Binary/)/[Windows](https://index.ros.org/doc/ros2/Installation/Windows-Install-Binary/) to setup the environment (If you want to run your apps on a stable release of ROS 2, e.g. crystal-clemmys, please see the section `Running on Stable Release of ROS 2).
110-
111-
2.Build ROS 2 from scratch.
112-
113-
Alternatively, you can build ROS 2 from scratch. Please select the platform you want to work on, then reference the instructions of [Linux](https://index.ros.org/doc/ros2/Installation/Linux-Development-Setup/)/[macOS](https://index.ros.org/doc/ros2/Installation/OSX-Development-Setup/)/[Windows](https://index.ros.org/doc/ros2/Installation/Windows-Development-Setup/) to build ROS 2 (please build wiht flag `--merge-install`).
114-
115-
### Install `Node.js`
116-
117-
**Notice:**
118-
`rclnodejs` should only be used with node versions between 8.12 - 12.99. The lowest LTS Node.js we used to verify the unit tests is `8.12.0`. And there is a known issue installing rclnodejs with versions of node >= 13.0.
119-
120-
The `Node.js` version we selected is the LTS [`Erbium`](https://nodejs.org/download/release/latest-erbium/) (12.x). You can install it:
121-
122-
- Download from Node.js offical [website](https://nodejs.org/en/), and install it.
123-
- Use the Node Version Manager ([nvm](https://github.com/creationix/nvm)) to install it.
124-
125-
### Get Code
126-
127-
Open a terminal, and input:
128-
129-
```bash
130-
git clone https://github.com/RobotWebTools/rclnodejs.git
131-
```
132-
133-
### Build Module
134-
135-
Before you build the module, you should make sure the ROS2 environments were loaded. You can check if the `AMENT_PREFIX_PATH` environment variable was set:
136-
137-
- For Windows: `echo %AMENT_PREFIX_PATH%` in the command prompt.
138-
139-
- For Linux and macOS: `echo $AMENT_PREFIX_PATH` in the terminal.
140-
141-
If the `AMENT_PREFIX_PATH` is unset, you should load the ROS2 environments:
142-
143-
- For Windows, open the command prompt and run
144-
145-
```bash
146-
call <path\to\ros2>\install\local_setup.bat
147-
```
148-
149-
- For Linux and macOS, open the terminal and run:
150-
151-
```bash
152-
source <path/to/ros2>/install/local_setup.bash
153-
```
154-
155-
This `Node.js` module is built by [node-gyp](https://www.npmjs.com/package/node-gyp), all you have to do is just to run the following command:
156-
157-
```javascript
158-
npm install
159-
```
160-
161-
**Windows-specific**: make sure Python 2.x interpreter is first searched in your `PATH` before running the command. You can change it temporarily by:
162-
163-
```bash
164-
set PATH=<path\to\python 2.x>;%PATH%
165-
```
166-
167-
## Run Unit Tests
168-
169-
The test suite is implemented using the [mocha](https://www.npmjs.com/package/mocha) JavaScript test framework for node.js. Run the unit tests:
170-
171-
```javascript
172-
npm run test
173-
```
174-
175-
**Windows-specific**: the tests requires in a `Microsoft Visual Studio Native Tools command prompt`, and also make sure Python 3.x interpreter is first searched in your `PATH` before running te test. You can change it temporarily by:
176-
177-
```bash
178-
set PATH=<path\to\python 3.x>;%PATH%
179-
```
180-
181-
## Troubleshooting
182-
183-
### Maximum call stack size exceeded error when running in Jest
184-
185-
When running tests in Jest, you may see an error like this:
186-
187-
```
188-
RangeError: Maximum call stack size exceeded
189-
190-
at debug (../node_modules/ref/node_modules/debug/src/debug.js:1:1)
191-
at Object.writePointer [as _writePointer] (../node_modules/ref/lib/ref.js:746:3)
192-
at Object.writePointer [as _writePointer] (../node_modules/ref/lib/ref.js:747:11)
193-
at Object.writePointer [as _writePointer] (../node_modules/ref/lib/ref.js:747:11)
194-
at Object.writePointer [as _writePointer] (../node_modules/ref/lib/ref.js:747:11)
195-
at Object.writePointer [as _writePointer] (../node_modules/ref/lib/ref.js:747:11)
196-
at Object.writePointer [as _writePointer] (../node_modules/ref/lib/ref.js:747:11)
197-
at Object.writePointer [as _writePointer] (../node_modules/ref/lib/ref.js:747:11)
198-
at Object.writePointer [as _writePointer] (../node_modules/ref/lib/ref.js:747:11)
199-
at Object.writePointer [as _writePointer] (../node_modules/ref/lib/ref.js:747:11)
200-
```
201-
202-
This is caused by a bug in `ref` which happens when you `require` it multiple times. There is a fix available for `ref` but it's no longer being maintained and the author has not published it.
203-
204-
If it is required to use Jest, a solution would be to fork `ref` and use npm shrinkwrap to installed a patched version.
205-
206-
### Running with ASAN
207-
208-
#### Linux
209-
210-
To run with google's AddressSanitizer tool, build with `-fsanitize=address` flag,
211-
212-
```sh
213-
CXXFLAGS=-fsanitize=address node-gyp build --debug
214-
```
215-
216-
ASAN needs to be loaded at the start of the process, since rclnodejs is a dynamically loaded library, it will not do so by default. To workaround this, run node with `LD_PRELOAD` to force ASAN to be loaded.
217-
218-
```sh
219-
LD_PRELOAD=$(g++ -print-file-name=libasan.so) node node_modules/.bin/mocha test/test-publisher.js
220-
```
103+
## Contributing
221104

222-
Due to v8's garbage collector, there may be false positives in the leak test, to remove them as much as possible, there is a simple helper script to run gc on exit. To use it, the `--expose-gc` flag needs to be set in node, then run mocha with `-r test/gc-on-exit.js` e.g.
223-
224-
```sh
225-
LD_PRELOAD=$(g++ -print-file-name=libasan.so) node --expose-gc node_modules/.bin/mocha -r test/gc-on-exit.js test/test-publisher.js
226-
```
105+
Please make sure to read the [Contributing Guide]() before making a pull request.
227106

228-
**Note**: Tests that forks the current process like `test-array.js` will not run gc when they exit. They may report many false positive leaks.
107+
Thank you to all the [people](CONTRIBUTORS.md) who already contributed to rclnodejs!
229108

230-
ASAN may report leaks in ref-napi and other modules, there is a suppression file you can use to hide them
231-
232-
```sh
233-
LSAN_OPTIONS=suppressions=suppr.txt node --expose-gc node_modules/.bin/mocha -r test/gc-on-exit.js test/test-publisher.js
234-
```
235-
236-
## Get Involved
237-
238-
### Contributing
239-
240-
If you want to contribute code to this project, first you need to fork the
241-
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.
242-
243-
### Contributors
244-
245-
Special thanks to the people who contribute.
246-
247-
- [martins-mozeiko](https://github.com/martins-mozeiko)
248-
- [Teo Koon Peng](https://github.com/koonpeng)
249-
- [Alex Mikhalev](https://github.com/amikhalev)
250-
- [Wayne Parrott](https://github.com/wayneparrott)
251-
- [Matt Richard](https://github.com/mattrichard)
252-
- [Felix Divo](https://github.com/felixdivo)
109+
[![](https://github.com/minggangw.png?size=25)](https://github.com/minggangw)
110+
[![](https://github.com/wayneparrott.png?size=25)](https://github.com/wayneparrott)
253111

254112
## License
255-
256-
This project abides by [Apache License 2.0](https://github.com/RobotWebTools/rclnodejs/blob/develop/LICENSE).
113+
This project abides by the [Apache License 2.0](https://github.com/RobotWebTools/rclnodejs/blob/develop/LICENSE).

0 commit comments

Comments
 (0)