... | @@ -277,15 +277,13 @@ status = tst_executor.waitForFinished() |
... | @@ -277,15 +277,13 @@ status = tst_executor.waitForFinished() |
|
# Display the result of execution
|
|
# Display the result of execution
|
|
if status.type() == TstML.Executor.ExecutionStatus.Type.Finished:
|
|
if status.type() == TstML.Executor.ExecutionStatus.Type.Finished:
|
|
print("Execution successful")
|
|
print("Execution successful")
|
|
elif status.type() == TstML.Executor.ExecutionStatus.Type.Failed:
|
|
|
|
print("Execution failed: {}".format(status.message()))
|
|
|
|
else:
|
|
else:
|
|
print("Execution failed!")
|
|
print("Execution failed: {}".format(status.message()))
|
|
```
|
|
```
|
|
|
|
|
|
Instead of displaying the results, you should set the result in the response of your service call.
|
|
Instead of displaying the results, you should set the result in the response of your service call.
|
|
|
|
|
|
### C++
|
|
\\paragraph{C++}
|
|
|
|
|
|
First you need to create a `NodeExecutorRegistry`, and use the `registerNodeExecutor` function to associate `TSTNodeModel` with `AbstractNodeExecutor`. We provide you with a default executor for `sequence` and `concurrent`.
|
|
First you need to create a `NodeExecutorRegistry`, and use the `registerNodeExecutor` function to associate `TSTNodeModel` with `AbstractNodeExecutor`. We provide you with a default executor for `sequence` and `concurrent`.
|
|
|
|
|
... | @@ -574,58 +572,6 @@ You should see your robot undocking. |
... | @@ -574,58 +572,6 @@ You should see your robot undocking. |
|
|
|
|
|
You can use `std_srvs/Empty` to define a service call for `abort`, `stop`, `pause` and `resume`. Those service call need to be defined in your `tst_executor` node, along the `execute_tst` service call. You can call the function `abort`, `stop`, `pause` and `resume` of the `TstML.Executor.Executor`/`TstML::Executor::Executor` class.
|
|
You can use `std_srvs/Empty` to define a service call for `abort`, `stop`, `pause` and `resume`. Those service call need to be defined in your `tst_executor` node, along the `execute_tst` service call. You can call the function `abort`, `stop`, `pause` and `resume` of the `TstML.Executor.Executor`/`TstML::Executor::Executor` class.
|
|
|
|
|
|
If you try to call with ```ros2 service call```, you will notice that the call is hanging, and the execution is not aborted, stoped, paused or resumed. This is because, by default, ROS is single threaded and can only handle one request. We need to use a ```MultiThreadedExecutor``` with a reentrant group.
|
|
|
|
|
|
|
|
### Python
|
|
|
|
|
|
|
|
Modify your main function to look like this, instead of using `rclpy::spin(...)`:
|
|
|
|
|
|
|
|
```python
|
|
|
|
executor = rclpy.executors.MultiThreadedExecutor()
|
|
|
|
executor.add_node(tst_executor_node)
|
|
|
|
executor.spin()
|
|
|
|
```
|
|
|
|
|
|
|
|
Create a reentrant group:
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
group = ReentrantCallbackGroup()
|
|
|
|
```
|
|
|
|
|
|
|
|
And when creating a service use:
|
|
|
|
|
|
|
|
```python
|
|
|
|
service = self.create_service(..., callback_group=self.group)
|
|
|
|
```
|
|
|
|
|
|
|
|
Note that the ```execute_tst``` call is not reentrant, and should not be added to the group.
|
|
|
|
|
|
|
|
### C++
|
|
|
|
|
|
|
|
Modify your main function to look like this, instead of using `rclcpp::spin(...)`:
|
|
|
|
|
|
|
|
```c++
|
|
|
|
rclcpp::executors::MultiThreadedExecutor executor;
|
|
|
|
auto node = std::make_shared<TstExecutor>();
|
|
|
|
executor.add_node(node);
|
|
|
|
executor.spin();
|
|
|
|
```
|
|
|
|
|
|
|
|
Create a reentrant group:
|
|
|
|
|
|
|
|
```c++
|
|
|
|
rclcpp::CallbackGroup::SharedPtr group = this->create_callback_group(rclcpp::CallbackGroupType::Reentrant);
|
|
|
|
```
|
|
|
|
|
|
|
|
And when creating a service use:
|
|
|
|
|
|
|
|
```c++
|
|
|
|
service = create_service<...>("pause_tst", ..., rmw_qos_profile_services_default, group);
|
|
|
|
```
|
|
|
|
|
|
|
|
Note that the ```execute_tst``` call is not reentrant, and should not be added to the group.
|
|
|
|
|
|
|
|
## Parameters
|
|
## Parameters
|
|
|
|
|
|
### python
|
|
### python
|
... | | ... | |