|
|
|
Lab 2:
|
|
|
|
=====================
|
|
|
|
|
|
|
|
In this lab you will start programming your first node.
|
|
|
|
|
|
|
|
Setup the environment
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
To setup your environment:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
mkdir -p ~/TDDE05/ros2_ws/src
|
|
|
|
cd ~/TDDE05/ros2_ws/src
|
|
|
|
```
|
|
|
|
|
|
|
|
**It is strongly advised that you use the exact directory structure.** A number of scripts are provided by the course and expect you to follow that structure.
|
|
|
|
|
|
|
|
TODO: explain the structure of the environment src/ build inst...
|
|
|
|
|
|
|
|
Create a package
|
|
|
|
----------------
|
|
|
|
|
|
|
|
You should go to the source directory in your environment:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
cd ~/TDDE05/ros2_ws/src
|
|
|
|
```
|
|
|
|
|
|
|
|
To create a C++ package with a default node:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
ros2 pkg create --build-type ament_cmake --node-name lab2_node lab2
|
|
|
|
```
|
|
|
|
|
|
|
|
To create a python package with a default node:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
ros2 pkg create --build-type ament_python --node-name lab2_node lab2
|
|
|
|
```
|
|
|
|
|
|
|
|
You should go to the top directory in your environment and run the build command:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
cd ~/TDDE05/ros2_ws/
|
|
|
|
colcon build
|
|
|
|
```
|
|
|
|
|
|
|
|
Then you need to source the environment with:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
source install/local_setup.bash
|
|
|
|
```
|
|
|
|
|
|
|
|
or run:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
tdde05_setup
|
|
|
|
```
|
|
|
|
|
|
|
|
You can then run your node with the following command:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
ros2 run lab2 lab2_node
|
|
|
|
```
|
|
|
|
|