Skip to content

Commit cc7583e

Browse files
committed
Add mis-deleted docs (#1227)
Fix: #1228
1 parent a20f6fa commit cc7583e

File tree

4 files changed

+260
-0
lines changed

4 files changed

+260
-0
lines changed

docs/BUILDING.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Build rclnodejs
2+
3+
### Get ready for ROS 2
4+
5+
1.Install ROS 2 from binary package.
6+
7+
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://docs.ros.org/en/rolling/Installation/Ubuntu-Install-Debians.html)/[Windows](https://docs.ros.org/en/rolling/Installation/Windows-Install-Binary.html) 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).
8+
9+
2.Build ROS 2 from scratch.
10+
11+
Alternatively, you can build ROS 2 from scratch. Please select the platform you want to work on, then reference the instructions of [Linux](https://docs.ros.org/en/rolling/Installation/Alternatives/Ubuntu-Development-Setup.html#)/[Windows](https://docs.ros.org/en/rolling/Installation/Alternatives/Windows-Development-Setup.html) to build ROS 2 (please build with flag `--merge-install`).
12+
13+
### Install `Node.js`
14+
15+
**Notice:**
16+
`rclnodejs` should only be used with node versions between 10.23.1 - 19.x. The lowest LTS Node.js we used to verify the unit tests is `10.23.1`.
17+
18+
I install Nodejs from either:
19+
20+
- Node.js official [website](https://nodejs.org/en/)
21+
- Node Version Manager ([nvm](https://github.com/creationix/nvm))
22+
23+
### Get Code
24+
25+
Open a terminal, and input:
26+
27+
```bash
28+
git clone https://github.com/RobotWebTools/rclnodejs.git
29+
```
30+
31+
### Build Module
32+
33+
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:
34+
35+
- For Windows: `echo %AMENT_PREFIX_PATH%` in the command prompt.
36+
37+
- For Linux and macOS: `echo $AMENT_PREFIX_PATH` in the terminal.
38+
39+
If the `AMENT_PREFIX_PATH` is unset, you should load the ROS2 environments:
40+
41+
- For Windows, open the command prompt and run
42+
43+
```bash
44+
call <path\to\ros2>\install\local_setup.bat
45+
```
46+
47+
- For Linux and macOS, open the terminal and run:
48+
49+
```bash
50+
source <path/to/ros2>/install/local_setup.bash
51+
```
52+
53+
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:
54+
55+
```javascript
56+
npm install
57+
```
58+
59+
**Windows-specific**: make sure Python 2.x interpreter is first searched in your `PATH` before running the command. You can change it temporarily by:
60+
61+
```bash
62+
set PATH=<path\to\python 2.x>;%PATH%
63+
```
64+
65+
## Run Unit Tests
66+
67+
The test suite is implemented using the [mocha](https://www.npmjs.com/package/mocha) JavaScript test framework for node.js. Run the unit tests:
68+
69+
```javascript
70+
npm run test
71+
```
72+
73+
**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:
74+
75+
```bash
76+
set PATH=<path\to\python 3.x>;%PATH%
77+
```

docs/CONTRIBUTING.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Contributing to rclnodejs
2+
3+
Thank you for considering contributing to rclnodejs. All help appreciated.
4+
5+
## Bugs and Feature Requests
6+
7+
If you've noticed a bug or have a feature request, [make one](https://github.com/RobotWebTools/rclnodejs/issues/new)! It's generally best if you get confirmation of your bug or approval for your feature request this way before starting to code.
8+
9+
## Getting Started
10+
11+
### Communications and Coordination
12+
13+
If there is a bug or feature request you would like to work on begin by communicating your interest in resolving it. A project maintainer will assign the issue to you.
14+
15+
### Process
16+
17+
Here's the process to follow once a bug or feature request has been assigned to you:
18+
19+
#### Setting up your rclnodejs codebase
20+
21+
1. Fork the rclnodejs project. Refer to the [Building from Scratch Guide](BUILDING.md).
22+
2. Build your the base project and ensure the test suite runs.
23+
3. Make a branch for your new code.
24+
25+
#### Coding your Fix or Feature
26+
27+
1. Code your fix or new feature on your new branch.
28+
2. Code new tests or modify existing tests to cover your changes.
29+
3. Check for coding style compliance: `npm run lint`. Fix any coding style issues.
30+
4. Run the test suite and ensure all tests pass.
31+
5. Commit your changes to your cloned repo.
32+
33+
#### Submitting your Code
34+
35+
1. Submit your changes for review by opening a Pull Request (PR) on the rclnodejs project. Fix any CI failures resulting from your code changes.
36+
2. The PR will be reviewed by the project team members. Please keep the PR updated to reflect reviewer comments and requests. You may also be requested to rebase the PR and fix any conflicts. When the PR has gained "Looks Good To Me (LGTM)" status, the project maintainers will merge the PR.

docs/EFFICIENCY.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Tips for efficent use of rclnodejs
2+
3+
While our benchmarks place rclnodejs performance at or above that of [rclpy](https://github.com/ros2/rclpy) we recommend applying efficient coding and configuration practices where applicable.
4+
5+
## Tip-1: Disable Parameter Services
6+
7+
The typical ROS 2 node creation process includes creating an internal parameter service who's job is to fulfill requests for parameter meta-data and to set and update node parameters. If your ROS 2 node does not support public parameters then you can save the resources consumed by the parameter service. Disable the node parameter service by setting the `NodeOption.startParameterServices` property to false as shown below:
8+
9+
```
10+
let options = new NodeOptions(false);
11+
// or
12+
options.startParameterServices = false;
13+
14+
let node = new Node(nodeName, namespace, Context.defaultContext(), options);
15+
```
16+
17+
## Tip-2: Disable LifecycleNode Lifecycle Services
18+
19+
The LifecycleNode constructor creates 5 life-cycle services to support the ROS 2 lifecycle specification. If your LifecycleNode instance will not be operating in a managed-node context consider disabling the lifecycle services via the LifecycleNode constructor as shown:
20+
21+
```
22+
let enableLifecycleCommInterface = false;
23+
24+
let node = new LifecycleNode(
25+
nodeName,
26+
namespace,
27+
Context.defaultContext,
28+
NodeOptions.defaultOptions,
29+
enableLifecycleCommInterface
30+
);
31+
```
32+
33+
## Tip-3: Use Content-filtering Subscriptions
34+
35+
The ROS Humble release introduced content-filtering topics
36+
which enable a subscription to limit the messages it receives
37+
to a subset of interest. While the application of the a content-filter
38+
is specific to the DDS/RMW vendor, the general approach is to apply
39+
filtering on the publisher side. This can reduce network bandwidth
40+
for pub-sub communications and message processing and memory
41+
overhead of rclnodejs nodes.
42+
43+
Note: Be sure to confirm that your RMW implementation supports
44+
content-filter before attempting to use it. In cases where content-filtering
45+
is not supported your Subscription will simply ignore your filter and
46+
continue operating with no filtering.
47+
48+
Example:
49+
50+
```
51+
// create a content-filter to limit incoming messages to
52+
// only those with temperature > 75C.
53+
const options = rclnodejs.Node.getDefaultOptions();
54+
options.contentFilter = {
55+
expression: 'temperature > %0',
56+
parameters: [75],
57+
};
58+
59+
node.createSubscription(
60+
'sensor_msgs/msg/Temperature',
61+
'temperature',
62+
options,
63+
(temperatureMsg) => {
64+
console.log(`EMERGENCY temperature detected: ${temperatureMsg.temperature}`);
65+
}
66+
);
67+
68+
```

docs/FAQ.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# FAQ and Known Issues
2+
3+
Have a question or issue that should be included in this document? Consider opening an issue or discussion with the [rclnodejs project team](https://github.com/RobotWebTools/rclnodejs).
4+
5+
## Undefined or missing JavaScript message file
6+
7+
The most common reasons for this error are:
8+
9+
- Misspelling of a message name in your code
10+
- The ROS package containing the target message is not installed in your ROS environment
11+
- The ROS package containing the target message was installed after the `rclnodejs` package was installed in your ROS2-nodejs environment.
12+
13+
#### Verify the ROS package is installed
14+
15+
The first step is to verify that your ROS environment includes the package containing the target message. Using the `ros2` cli list all of the packages in your ROS environment and inspect the output for the package.
16+
17+
```
18+
ros2 pkg list
19+
```
20+
21+
If the package containing your target message is not listed then install it.
22+
23+
Next, inspect the generated JavaScript message files by viewing the `./node_modules/rclnodejs/generated/` folder of your project for your target message. If you are unable to locate the message file then use the `generate-messages` script:
24+
25+
```
26+
<your_project>/node_modules/.bin/generate-messages
27+
```
28+
29+
## Maximum call stack size exceeded error when running in Jest
30+
31+
When running tests in Jest, you may see an error like this:
32+
33+
```
34+
RangeError: Maximum call-stack size exceeded
35+
36+
at debug (../node_modules/ref/node_modules/debug/src/debug.js:1:1)
37+
at Object.writePointer [as _writePointer] (../node_modules/ref/lib/ref.js:746:3)
38+
at Object.writePointer [as _writePointer] (../node_modules/ref/lib/ref.js:747:11)
39+
at Object.writePointer [as _writePointer] (../node_modules/
40+
...
41+
```
42+
43+
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.
44+
45+
If it is required to use Jest, a solution would be to fork `ref` and use npm shrinkwrap to installed a patched version.
46+
47+
## Running with ASAN
48+
49+
#### Linux
50+
51+
To run with google's AddressSanitizer tool, build with `-fsanitize=address` flag,
52+
53+
```sh
54+
CXXFLAGS=-fsanitize=address node-gyp build --debug
55+
```
56+
57+
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.
58+
59+
```sh
60+
LD_PRELOAD=$(g++ -print-file-name=libasan.so) node node_modules/.bin/mocha test/test-publisher.js
61+
```
62+
63+
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.
64+
65+
```sh
66+
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
67+
```
68+
69+
**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.
70+
71+
ASAN may report leaks in ref-napi and other modules, there is a suppression file you can use to hide them
72+
73+
```sh
74+
LSAN_OPTIONS=suppressions=suppr.txt node --expose-gc node_modules/.bin/mocha -r test/gc-on-exit.js test/test-publisher.js
75+
```
76+
77+
## FastDDS requirements for multiple node processes on the same machine running under different users
78+
79+
When running multiple ROS 2 node processes configured to use FastDDS ROS middleware (rmw), you can experience a communications failure when the ROS nodes are run under different Linux user accounts. The issue has to do with FastDDS use of shared memory and Linux restrictions on accessing such memory. The workaround is to disable the use of FastDDS shared memory via a configuration file as outlined [here](https://github.com/eProsima/Fast-DDS/issues/1750).

0 commit comments

Comments
 (0)