You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -176,10 +176,6 @@ The benefits of using TypeScript become evident when working with more complex m
176
176
177
177
Smart TypeScript tools such as Visual Studio Code and the CodeMix plugin for Eclipse will help you learn the rclnodejs api and identify issues while coding rather than at runtime.
178
178
179
-
## Experimental - Deprecated
180
-
181
-
-[actionlib](https://github.com/RobotWebTools/rclnodejs/blob/develop/tutorials/actionlib.md) - as the [rcl](https://github.com/ros2/rcl) library has implemented the action related functions, we are going to drop this one and we don't guarantee the current actionlib can work with [rclcpp](https://github.com/ros2/rclcpp).
182
-
183
179
## Troubleshooting
184
180
185
181
### Maximum call stack size exceeded error when running in Jest
Copy file name to clipboardExpand all lines: tutorials/actionlib.md
+30-12Lines changed: 30 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,13 @@
1
-
# Introduction
1
+
# Introduction - Deprecated, please reference examples under /example for the usage based on the latest implementation.
2
+
2
3
Actionlib tutorial based on `rclnodejs`.
3
4
4
5
## Actionlib background
6
+
5
7
To continue the tutorial, you should have some basic understanding of the `action` term in ROS. If you're not familar with it, please refer to the [description](http://wiki.ros.org/actionlib/DetailedDescription).
6
8
7
9
## Precondition
10
+
8
11
You should prepare an action text file. The content is like this:
9
12
10
13
```
@@ -23,41 +26,50 @@ sensor_msgs/Image image
23
26
Fortunately, there is a `dodishes.action` file that is already available in the `test/ros1_actions` directory.
24
27
25
28
## Basic steps of processing action files for rclnodejs
29
+
26
30
For `rclnodejs`, the basic steps of process an action file is separated into 2 steps:
27
-
* Generate several msg files and the js message package from the action file.
28
-
* Build the shared library from the msg files that will be used in running actionlib-feature-related code.
31
+
32
+
- Generate several msg files and the js message package from the action file.
33
+
- Build the shared library from the msg files that will be used in running actionlib-feature-related code.
29
34
30
35
### Generate msg files from the action file
36
+
31
37
The `generated` directory contains the generated js message package for `rclnodejs`. If you have run `npm install`, then it should
32
38
exist after `npm install` was done. However, since your `AMENT_PREFIX_PATH` may not include the directory path of the action file, the `ros1_actions` package may not be generated. So you need remove the whole `generated` directory and regenerate them.
After the build, you can run the action example. The action example contains two parts, one is the [action server](./example/action-server-example.js), another is the [action client](./example/action-client-example.js). When running the example, you should launch the server first, and then launch the client.
47
56
48
-
* Launch a terminal session, load ROS2 environment and go to `rclnodejs` directory.
57
+
- Launch a terminal session, load ROS2 environment and go to `rclnodejs` directory.
First, you should new an `ActionServer` with the `type` and the `actionServer`. The `type` is the action package name and the `actionServer` is the name of the action server, which should be the same as the action client request to in future.
104
119
105
120
The `ActionServer` can emit 2 type events: `goal` and `cancel` events.
106
-
*`goal` event: triggered when an action client sends an goal to the action server by calling its `sendGoal()` method. In the handler of the this event, you can accept the goal by calling `goal.setAccepted()`. During executing the goal, you can send a feedback to the action client by calling `goal.publishFeedback()`. Once the goal is completed, you should set the goal status by calling `goal.setSucceeded()`, which will trigger the `result` event for the action client.
107
-
*`cancel` event: triggered when an action client cancels the the goal after a goal was sent to the action server but not completed yet.
121
+
122
+
-`goal` event: triggered when an action client sends an goal to the action server by calling its `sendGoal()` method. In the handler of the this event, you can accept the goal by calling `goal.setAccepted()`. During executing the goal, you can send a feedback to the action client by calling `goal.publishFeedback()`. Once the goal is completed, you should set the goal status by calling `goal.setSucceeded()`, which will trigger the `result` event for the action client.
123
+
-`cancel` event: triggered when an action client cancels the the goal after a goal was sent to the action server but not completed yet.
108
124
109
125
The `start()` method must be called to start the action server.
110
126
111
127
2. Action client
112
-
For the action client, the skeleton code is like this:
128
+
For the action client, the skeleton code is like this:
To construct an action client, use `new rclnodejs.ActionClientInterface()`. The action client can emit 3 type events:
147
-
*`status` event: tirggered when the action server sends messages to the action client during the goal is executing.
148
-
*`feedback` event: triggered after the action server called `publishFeedback`.
149
-
*`result` event: triggered after the action server called `setSucceeded`.
164
+
165
+
-`status` event: tirggered when the action server sends messages to the action client during the goal is executing.
166
+
-`feedback` event: triggered after the action server called `publishFeedback`.
167
+
-`result` event: triggered after the action server called `setSucceeded`.
150
168
151
169
**Notice**, the action state transitions must obey some specific order, for more details please refer to [this articile](http://wiki.ros.org/actionlib/DetailedDescription)
0 commit comments