Skip to content

Commit 5d021c5

Browse files
authored
Added GETTING-STARTED & README files to package templates (#16)
* improved ros version specific tests * set 775 permission on run_ros_version.sh * Added GETTING-STARTED & README to js & ts pkg templates; bumped ver number * set mode 755 on all .sh files
1 parent 931fbeb commit 5d021c5

File tree

6 files changed

+176
-2
lines changed

6 files changed

+176
-2
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Getting Started With Your ROS2-Nodejs Package
2+
3+
### 1. Use the [colcon](https://docs.ros.org/en/foxy/Tutorials/Colcon-Tutorial.html) build utility to install the key JavaScript resources into the `./install/share/` folder.
4+
```
5+
colcon build
6+
```
7+
Your package folder will now include the standard ROS2 package directories: `build/`, `install/` and `log/`. The `install/` directory includes configuration scripts and if you look deep into the `install/ros2_nodejs/share/ros2_nodejs` folder you will see the `install()` rules in the CMakeLists.txt have installed the key JavaScript resources from the `src/` and `launch/` directories.
8+
9+
### 2. Add your new ROS2-Nodejs package to your ROS environment.
10+
11+
From your `<package-directory>` run:
12+
13+
Linux
14+
```
15+
source install/setup.bash
16+
```
17+
Windows
18+
```
19+
install\setup.bat #windows
20+
```
21+
22+
### 3. Verify that the ROS2-Nodejs package is part of your ROS2 environment using the `ros2` CLI command.
23+
```
24+
ros2 pkg list
25+
```
26+
This command will output a long list of the packages in your ROS2 environment. Scroll through the list and verify it contains the ros2_nodejs package.
27+
28+
### 4. Launch example.launch.py
29+
We can now use the `ros2 launch` command to run the `example.launch.py` launch-description. This launch file defines how to startup the example app in our ROS2-Nodejs package. The example app creates a ROS2 node and publisher that sends a message every second to the topic named `foo`. See `src/index.js` for the JavaScript implementation details.
30+
31+
Launch `example.launch.py` as shown below:
32+
```
33+
ros2 launch ros2_nodejs example.launch.py
34+
```
35+
To view the messages being published to the `foo` topic, open a separate shell configured with your ROS2 environment and enter:
36+
```
37+
ros2 topic echo foo
38+
```
39+
A message should appear every second.
40+
41+
# Working With Typescript #
42+
If you would like to work with TypeScript instead of JavaScript use the `--typescript` commandline option as shown.
43+
```
44+
rclnodejs create-package <mypkg> --typescript
45+
or
46+
rclnodejs-cli create-package <mypkg> --typescript
47+
```
48+
The ROS2-Nodejs package will include a `tsconfig.json` file and a TypeScript example at `src/index.ts`.
49+
50+
51+
# Using the command from the `ros2` commandline #
52+
An alternative way to use the `create-package` command is from the `ros2` commandline.
53+
54+
Before using, you must first extend your ROS2 environment by running the `install/setup.[bash|bat|sh|ps1]` script from the root folder of the `rclnode-cli package`. For background on configuring your ROS2 environement see this [tutorial](https://index.ros.org/doc/ros2/Tutorials/Configuring-ROS2-Environment/).
55+
56+
Verify the command is installed properly:
57+
```
58+
ros2 pkg -h
59+
```
60+
You should see `create_nodejs` in the Commands list similar to the output shown below.
61+
```
62+
usage: ros2 pkg [-h] Call `ros2 pkg <command> -h` for more detailed usage. ...
63+
64+
Various package related sub-commands
65+
66+
optional arguments:
67+
-h, --help show this help message and exit
68+
69+
Commands:
70+
create Create a new ROS2 package
71+
create_nodejs Create a ROS2 package for Nodejs development.
72+
executables Output a list of package specific executables
73+
list Output a list of available packages
74+
prefix Output the prefix path of a package
75+
xml Output the XML of the package manifest or a specific tag
76+
77+
Call `ros2 pkg <command> -h` for more detailed usage.
78+
```
79+
80+
Next create a new ROS2-Nodejs package as shown below:
81+
```
82+
ros2 pkg create_nodejs <pkg_name>
83+
or
84+
ros2 pkg create_nodejs <pkg_name> --typescript
85+
```
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Placeholder file
2+
<your project details here>
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Getting Started With Your ROS2-Nodejs Package
2+
3+
### 1. Use the [colcon](https://docs.ros.org/en/foxy/Tutorials/Colcon-Tutorial.html) build utility to install the key JavaScript resources into the `./install/share/` folder.
4+
```
5+
colcon build
6+
```
7+
Your package folder will now include the standard ROS2 package directories: `build/`, `install/` and `log/`. The `install/` directory includes configuration scripts and if you look deep into the `install/ros2_nodejs/share/ros2_nodejs` folder you will see the `install()` rules in the CMakeLists.txt have installed the key JavaScript resources from the `src/` and `launch/` directories.
8+
9+
### 2. Add your new ROS2-Nodejs package to your ROS environment.
10+
11+
From your `<package-directory>` run:
12+
13+
Linux
14+
```
15+
source install/setup.bash
16+
```
17+
Windows
18+
```
19+
install\setup.bat #windows
20+
```
21+
22+
### 3. Verify that the ROS2-Nodejs package is part of your ROS2 environment using the `ros2` CLI command.
23+
```
24+
ros2 pkg list
25+
```
26+
This command will output a long list of the packages in your ROS2 environment. Scroll through the list and verify it contains the ros2_nodejs package.
27+
28+
### 4. Launch example.launch.py
29+
We can now use the `ros2 launch` command to run the `example.launch.py` launch-description. This launch file defines how to startup the example app in our ROS2-Nodejs package. The example app creates a ROS2 node and publisher that sends a message every second to the topic named `foo`. See `src/index.js` for the JavaScript implementation details.
30+
31+
Launch `example.launch.py` as shown below:
32+
```
33+
ros2 launch ros2_nodejs example.launch.py
34+
```
35+
To view the messages being published to the `foo` topic, open a separate shell configured with your ROS2 environment and enter:
36+
```
37+
ros2 topic echo foo
38+
```
39+
A message should appear every second.
40+
41+
# Working With Typescript #
42+
If you would like to work with TypeScript instead of JavaScript use the `--typescript` commandline option as shown.
43+
```
44+
rclnodejs create-package <mypkg> --typescript
45+
or
46+
rclnodejs-cli create-package <mypkg> --typescript
47+
```
48+
The ROS2-Nodejs package will include a `tsconfig.json` file and a TypeScript example at `src/index.ts`.
49+
50+
51+
# Using the command from the `ros2` commandline #
52+
An alternative way to use the `create-package` command is from the `ros2` commandline.
53+
54+
Before using, you must first extend your ROS2 environment by running the `install/setup.[bash|bat|sh|ps1]` script from the root folder of the `rclnode-cli package`. For background on configuring your ROS2 environement see this [tutorial](https://index.ros.org/doc/ros2/Tutorials/Configuring-ROS2-Environment/).
55+
56+
Verify the command is installed properly:
57+
```
58+
ros2 pkg -h
59+
```
60+
You should see `create_nodejs` in the Commands list similar to the output shown below.
61+
```
62+
usage: ros2 pkg [-h] Call `ros2 pkg <command> -h` for more detailed usage. ...
63+
64+
Various package related sub-commands
65+
66+
optional arguments:
67+
-h, --help show this help message and exit
68+
69+
Commands:
70+
create Create a new ROS2 package
71+
create_nodejs Create a ROS2 package for Nodejs development.
72+
executables Output a list of package specific executables
73+
list Output a list of available packages
74+
prefix Output the prefix path of a package
75+
xml Output the XML of the package manifest or a specific tag
76+
77+
Call `ros2 pkg <command> -h` for more detailed usage.
78+
```
79+
80+
Next create a new ROS2-Nodejs package as shown below:
81+
```
82+
ros2 pkg create_nodejs <pkg_name>
83+
or
84+
ros2 pkg create_nodejs <pkg_name> --typescript
85+
```
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Placeholder file
2+
<your project details here>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rclnodejs-cli",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "Commandline tools for the ROS2 rclnodejs client library",
55
"main": "index.js",
66
"bin": "./index.js",

test/run_ros_version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22
source install/local_setup.sh && \
3-
echo $ROS_DISTRO
3+
echo $ROS_DISTRO

0 commit comments

Comments
 (0)