... | ... | @@ -3,26 +3,14 @@ Lab 2: Navigation |
|
|
|
|
|
In this lab, you will start programming your first ROS node.
|
|
|
|
|
|
<div style="background-color: rgb(221, 250, 221);border-left: 3px solid rgb(106, 222, 106)">
|
|
|
|
|
|
**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.**
|
|
|
</div>
|
|
|
|
|
|
{+
|
|
|
|
|
|
**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.**
|
|
|
|
|
|
+}
|
|
|
|
|
|
Setup the environment
|
|
|
Setup the Environment
|
|
|
---------------------
|
|
|
|
|
|
To setup your environment:
|
... | ... | @@ -112,7 +100,7 @@ If you are using C++, you can add a custom build command by editing the default |
|
|
</details>
|
|
|
|
|
|
|
|
|
Create a package for screen and Rviz
|
|
|
Creating a Package for Screen and Rviz
|
|
|
------------------------------------
|
|
|
|
|
|
We will create a package ```air_lab_common``` to add common files among all the labs, such as the screen file to start commands and the Rviz configuration.
|
... | ... | @@ -176,7 +164,7 @@ We also would like to load Rviz configuration automatically. To do so you can us |
|
|
rviz2 -d $HOME/TDDE05/ros2_ws/src/labs/air_lab_common/rviz/[name of your rviz config]
|
|
|
```
|
|
|
|
|
|
Create a package for Lab2
|
|
|
Creating a Package for Lab2
|
|
|
-------------------------
|
|
|
|
|
|
To create a Python package with a default node:
|
... | ... | @@ -217,7 +205,7 @@ You can then run your node with the following command: |
|
|
ros2 run air_lab2 lab2_node
|
|
|
```
|
|
|
|
|
|
Publishing on a topic
|
|
|
Publishing on a Topic
|
|
|
---------------------
|
|
|
|
|
|
At this point, your node is not doing anything interesting. First, we will make our node send a message on a topic. We will make it send a velocity on ```/cmd_vel```.
|
... | ... | @@ -234,7 +222,7 @@ Modify the publisher example to instead publish a ```geometry_msgs/msg/Twist``` |
|
|
|
|
|
The documentation for ```geometry_msgs/Twist``` can be found online at [geometry_msgs/Twist](https://docs.ros2.org/galactic/api/geometry_msgs/msg/Twist.html) or by running ```ros2 msg info geometry_msgs/Twist```.
|
|
|
|
|
|
Listen on a topic
|
|
|
Listening to a Topic
|
|
|
-----------------
|
|
|
|
|
|
In the previous part, we created a node that publishes on a topic and makes your robot move, but it never stops. In this part, we will listen to the ```/odom``` topic and use that information to stop when the robot has moved more than 1.0 meters away from its start position.
|
... | ... | @@ -245,7 +233,7 @@ Check in the Python or C++ tutorial to see how you can subscribe to a topic. You |
|
|
* Add a printout in the callback to check that you received a message.
|
|
|
* Modify your program so that it exits once the robot has moved by 1.0 meters.
|
|
|
|
|
|
Parameters
|
|
|
Command Line Parameters
|
|
|
----------
|
|
|
|
|
|
For now, we have hard-coded parameters, such as the velocity and the distance. To make our node more effective, we should set those as parameters on the command line.
|
... | ... | @@ -260,7 +248,7 @@ Before starting, you should study the [official Python tutorial](https://docs.ro |
|
|
|
|
|
Create a ```linear```, ```angular``` and ```distance``` parameter.
|
|
|
|
|
|
Navigation and path planning
|
|
|
Navigation and Path Planning
|
|
|
----------------------------
|
|
|
|
|
|
The turtlebot4 includes a motion planner that can navigate and avoid obstacles. This is implemented as an action that can be started from the terminal with the following command:
|
... | ... | @@ -289,7 +277,7 @@ Now you can select ```Nav2 goal``` tool and click in Rviz to make your robot mov |
|
|
|
|
|

|
|
|
|
|
|
Exploration with a random pattern
|
|
|
Exploration with a Random Pattern
|
|
|
---------------------------------
|
|
|
|
|
|
We will now create a new node that will send the robot to a random location to explore the map. We will need to create a new node in the ```air_lab2``` module.
|
... | ... | |