... | ... | @@ -29,6 +29,23 @@ In ```~/TDDE05/ros2_ws/```, you will now have four directories |
|
|
Setup GIT Repository
|
|
|
--------------------
|
|
|
|
|
|
<details>
|
|
|
<summary><span style="font-weight:bold;">Click me - Your GIT repository and adding SSH Key!</span></summary>
|
|
|
|
|
|
### Your GIT repository name:
|
|
|
The course uses automatically generated GIT repositories for storing your lab assignments source code.
|
|
|
Make sure you are registered on Webreg, so that the repository is created. The assigned name of the repository follows ```gitlab.liu.se:tdde05-2025/air-labs-XX.git``` pattern, where ```XX``` is your group number in WebReg.
|
|
|
|
|
|
### SSH Key - if you do not have one yet
|
|
|
|
|
|
Working with GitLab requires setting up an SSH Key. If you have not done it in previous corses
|
|
|
|
|
|
1. Click ```Add new key``` in [SSH Keys section of your profile](https://gitlab.liu.se/-/user_settings/ssh_keys)
|
|
|
2. Follow the instructions [HERE](https://gitlab.liu.se/help/user/ssh.md) to generate the key and add it to your GitLab profile.
|
|
|
|
|
|
</details>
|
|
|
|
|
|
</br>
|
|
|
You should go to the source directory in your environment:
|
|
|
|
|
|
```bash
|
... | ... | @@ -36,7 +53,8 @@ cd ~/TDDE05/ros2_ws/src/ |
|
|
mkdir labs
|
|
|
cd labs
|
|
|
git init
|
|
|
git remote add origin git@gitlab.liu.se:tdde05-20YY/air-labs-XX.git
|
|
|
git remote add origin git@gitlab.liu.se:tdde05-2025/air-labs-XX.git
|
|
|
git push --set-upstream origin master
|
|
|
```
|
|
|
|
|
|
Create a package for screen and Rviz
|
... | ... | @@ -80,8 +98,18 @@ git add . |
|
|
git commit -m "import air_lab_common"
|
|
|
```
|
|
|
|
|
|
You can now run ```tdde05-build``` to install your files and ```tdde05-start``` to reload the configuration.
|
|
|
You can now start your screen file with:
|
|
|
You can now run ```tdde05-build``` to install your files. After which you need to reload the configuration either by:
|
|
|
```bash
|
|
|
source $HOME/TDDE05/ros2_ws/install/local_setup.bash
|
|
|
```
|
|
|
|
|
|
or starting a new shell with:
|
|
|
|
|
|
```bash
|
|
|
start_ros
|
|
|
```
|
|
|
|
|
|
Now, you can start your screen file with:
|
|
|
|
|
|
```bash
|
|
|
ros2screen air_lab_common [name of screen file]
|
... | ... | @@ -128,7 +156,6 @@ or start a new shell with: |
|
|
start_ros
|
|
|
```
|
|
|
|
|
|
|
|
|
You can then run your node with the following command:
|
|
|
|
|
|
```bash
|
... | ... | @@ -155,13 +182,13 @@ The documentation for ```geometry_msgs/Twist``` can be found online at [geometry |
|
|
Listen on a topic
|
|
|
-----------------
|
|
|
|
|
|
In the previous part, we have 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 meter away from its start position.
|
|
|
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.
|
|
|
|
|
|
Check in the Python or C++ tutorial to see how you can subscribe to a topic. You will have to somehow combine together the publisher and subscriber classes. We strongly advise that you follow an incremental approach:
|
|
|
|
|
|
* Add a subscriber to your ```lab2_node```. **You should have a single class**, so add the `subscribe` and `callback` to your existing class. This is different from the ROS tutorials where the `subscribe` and `callback` are in different classes. By default, the `spin` function is blocking and accepts a single `node` as an argument.
|
|
|
* Add a printout in the callback to check that you receive a message.
|
|
|
* Modify your program so that it exits once the robot has moved by 1.0 meter.
|
|
|
* 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
|
|
|
----------
|
... | ... | @@ -214,7 +241,7 @@ We will now create a new node that will send the robot to a random location to e |
|
|
|
|
|
### Python
|
|
|
|
|
|
Create a new file in ```$HOME/TDDE05/ros2_ws/src/labs/air_lab2/air_lab2``` called ```random_exploration.py``` this will be your new node. You need to modify your ```setup.py``` so that it contains the following change to ```entry_points```:
|
|
|
Create a new file in ```$HOME/TDDE05/ros2_ws/src/labs/air_lab2/air_lab2``` called ```random_exploration.py```. This will be your new node. You need to modify your ```setup.py``` so that it contains the following change to ```entry_points```:
|
|
|
|
|
|
```python
|
|
|
entry_points={
|
... | ... | @@ -299,11 +326,11 @@ if __name__ == '__main__': |
|
|
main()
|
|
|
```
|
|
|
|
|
|
Extend that class so that you keep going to a new random location, either when the robot has reached its current location or when it is failing to reach it, instead of basing yourself on time, you should check using feedback if the robot is moving. There are at least two approaches to solving that problem. One is much easier to implement than the other, so look carefully at the message structure.
|
|
|
Extend that class so that you keep going to a new random location, either when the robot has reached its current location or when it is failing to reach it. Instead of basing yourself on time, you should check using feedback if the robot is moving. There are at least two approaches to solving that problem. One is much easier to implement than the other, so look carefully at the message structure.
|
|
|
|
|
|
### C++
|
|
|
|
|
|
Create a new file in ```$HOME/TDDE05/ros2_ws/src/labs/air_lab2/src``` called ```random_exploration.cpp``` this will be your new node. You need to modify your ```CMakeLists.txt```, to duplicate what is available for ```lab2_node```.
|
|
|
Create a new file in ```$HOME/TDDE05/ros2_ws/src/labs/air_lab2/src``` called ```random_exploration.cpp```. This will be your new node. You need to modify your ```CMakeLists.txt```, to duplicate what is available for ```lab2_node```.
|
|
|
|
|
|
|
|
|
We will use the ```NavigateToPose``` action. You can check its type with:
|
... | ... | @@ -439,7 +466,7 @@ int main(int argc, char * argv[]) |
|
|
}
|
|
|
```
|
|
|
|
|
|
Extend that class so that you keep going to a new random location, either when the robot has reached its current location or when it is failing to reach it, instead of basing yourself on time, you should check using feedback if the robot is moving. There are at least two approaches to solving that problem. One is much easier to implement than the other, so look carefully at the message structure.
|
|
|
Extend that class so that you keep going to a new random location, either when the robot has reached its current location or when it is failing to reach it. Instead of basing yourself on time, you should check using feedback if the robot is moving. There are at least two approaches to solving that problem. One is much easier to implement than the other, so look carefully at the message structure.
|
|
|
|
|
|
Demonstration
|
|
|
--------------
|
... | ... | |