| ... | ... | @@ -4,6 +4,12 @@ The goal of this lab is to create an executor for Task-Specification-Trees. The |
|
|
|
|
|
|
|
It is *important* to have studied **Lecture 07: Deliberative Architecture** before starting this lab.
|
|
|
|
|
|
|
|
**Remainder!**
|
|
|
|
|
|
|
|
```start_ros``` needs to be used to start ```bash``` terminal with ROS setup when you open a new Terminal window.
|
|
|
|
|
|
|
|
**This has to be run always before any commands discussed below when using new Terminal window, otherwise ROS commands will not work.**
|
|
|
|
|
|
|
|
## TST
|
|
|
|
|
|
|
|
A Task-Specification-Tree (TST) is a hierachical tree structure which represents a complex mission. For the purpose of this lab, six types of TST nodes are used:
|
| ... | ... | @@ -44,7 +50,7 @@ ros2 run air_tst tst_editor explore_record_semantic.json |
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
## TST File format
|
|
|
|
## TST File Format
|
|
|
|
|
|
|
|
TST are defined using the JSON file format.
|
|
|
|
|
| ... | ... | @@ -109,11 +115,13 @@ List of relevant classes for executing TST: |
|
|
|
|
|
|
|
The `NodeExecutorRegistry` and `TSTNodeModelsRegistry` are common for all TSTs and should be permanent. While `TSTNode` and `Executor` are specific to the execution of a given tree.
|
|
|
|
|
|
|
|
## TST executor service definition
|
|
|
|
## TST Executor Service Definition
|
|
|
|
|
|
|
|
We will need to create a new service definition. You should check and understand the [official tutorial](https://docs.ros.org/en/galactic/Tutorials/Beginner-Client-Libraries/Custom-ROS2-Interfaces.html) first. It is good practice to create a standalone package for defining messages, so that it is independent of Python and C++. We will need to create a package specially for storing our definitions:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
cd ~/TDDE05/ros2_ws/src/labs
|
|
|
|
ros2 pkg create --build-type ament_cmake air_lab_interfaces --dependencies std_msgs rosidl_default_generators
|
|
|
|
```
|
|
|
|
|
| ... | ... | @@ -134,46 +142,59 @@ rosidl_generate_interfaces(${PROJECT_NAME} |
|
|
|
)
|
|
|
|
```
|
|
|
|
|
|
|
|
Then we need to add the following to `package.xml` file:
|
|
|
|
Then we need to add the following to `package.xml` file, within the `package` block:
|
|
|
|
|
|
|
|
```xml
|
|
|
|
<member_of_group>rosidl_interface_packages</member_of_group>
|
|
|
|
```
|
|
|
|
|
|
|
|
Then you can build with `tdde05-build`. Then you should reload the environment with `tdde05-start`. Then you should be able to see the new message with:
|
|
|
|
You can now build with ```tdde05-build```. After which you need to reload the configuration either by:
|
|
|
|
```bash
|
|
|
|
source $HOME/TDDE05/ros2_ws/install/local_setup.bash
|
|
|
|
```
|
|
|
|
|
|
|
|
or starting a new Terminal and executing:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
start_ros
|
|
|
|
```
|
|
|
|
|
|
|
|
After that, you should be able to see the new message with:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
ros2 interface show air_lab_interfaces/srv/ExecuteTst
|
|
|
|
```
|
|
|
|
|
|
|
|
## Implementation
|
|
|
|
## Implementation of the Lab
|
|
|
|
|
|
|
|
This lab can be completed using **Python** or **C++**. Follows the instruction corresponding to your choice of programming language.
|
|
|
|
This lab can be completed using **Python** or **C++**. Follow the instructions corresponding to your choice of the programming language.
|
|
|
|
|
|
|
|
You will need to create a package for `air_lab3`, in your `ros2_ws/src/labs` directory, with dependencies on a few packages. For python:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
cd ~/TDDE05/ros2_ws/src/labs
|
|
|
|
ros2 pkg create air_lab3 --build-type ament_python --dependencies rclpy air_lab_interfaces --node-name tst_executor
|
|
|
|
```
|
|
|
|
|
|
|
|
For C++:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
cd ~/TDDE05/ros2_ws/src/labs
|
|
|
|
ros2 pkg create air_lab3 --build-type ament_cmake --dependencies rclcpp rclcpp_action air_lab_interfaces irobot_create_msgs --node-name tst_executor
|
|
|
|
```
|
|
|
|
|
|
|
|
## TST executor service server
|
|
|
|
## TST Executor Service Server
|
|
|
|
|
|
|
|
We will create a service server whose goal is to load a TST description from a file (one of the JSON file) and execute it. In the remainer of the lab we will help you implent that service call, in this section, we will start by just seting up an empty service.
|
|
|
|
We will create a service server whose goal is to load a TST description from a file (one of the JSON files) and execute it. In the remainder of the lab, we will help you implement that service call; in this section, we will start by just setting up an empty service.
|
|
|
|
|
|
|
|
You should start by reading and understanding the official tutorials for [Python](https://docs.ros.org/en/galactic/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Service-And-Client.html) or [C++](https://docs.ros.org/en/galactic/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Service-And-Client.html).
|
|
|
|
|
|
|
|
You should follow an incremental approach:
|
|
|
|
|
|
|
|
* Copy/paste the service server example from the respective tutorials into your `tst_executor.py` or `tst_executor.cpp`. *We do not need a client, in this lab, we will use the command line to call the service*.
|
|
|
|
* Make sure you understand what is happening, if you have doubts, ask questions to your lab assistant.
|
|
|
|
* Make sure you understand what is happening. If you have doubts, ask your lab assistant questions.
|
|
|
|
* You won't be able to run the tutorial. So you can start modifying to replace the service call with `execute_tst` and the type `air_lab_interfaces/srv/ExecuteTst`.
|
|
|
|
* Once you have modified it, you can test your calling your service with:
|
|
|
|
* Once you have modified it, you can test it by calling your service with:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
ros2 service call /execute_tst air_lab_interfaces/srv/ExecuteTst "tst_file: '`ros2 pkg prefix air_tst`/share/air_tst/tsts/undock.json'"
|
| ... | ... | |