Skip to content
Snippets Groups Projects
Commit 0b77343d authored by Patrick Simmel's avatar Patrick Simmel
Browse files

stuff

parent d85fcc25
No related branches found
No related tags found
No related merge requests found
# Turtlebot3 ROS2 template
# Code für die einzelnen Challenges
## Preparing ROS workspaces and environment variables
Dieses Repository enthält den gesamten Code, um die einzelnen Challenges laufen zu lassen.
`rosenv` alias (example in `ros.sh`) which activates preinstalled `ros-base`, `gazebo-ros-pkgs`, and `turtlebot3` workspaces. If `ros.sh` is installed in `/etc/profile.d` then `ros.sh` will be automatically loaded everytime you open a terminal. Then you can type `rosenv` to activate the ROS environment in a new terminal.
## Challenge 1
Um Challenge 1 laufen zu lassen, muss nach dem Klonen dieses Repos einfach folgendes eingegeben werden:
Setting up your `ROS_DOMAIN_ID`, e.g., if multiple users are working on the same server. You can use `set_my_ros_domain_id.sh` for this. Generate a random id with `make set_my_ros_domain_id.sh`
# Setup
Open three terminal windows for:
1. running your ROS node
2. writing code
3. launching & monitoring Gazebo
### 1st window - running your ROS node
```sh
git clone https://mygit.th-deg.de/gaydos/tb3-ros2-template && cd tb3-ros2-template
make # creates a ROS package, builds it and links `tb3.py` to the file in `src/.../tb3.py` (creates a shortcut)
. ./set_my_ros_domain_id.sh # sets a random `ROS_DOMAIN_ID`. Useful when multiple users are working on the same server
. ./install/local_setup.sh # activate current workspace (you can also use `. ./load_workspace.sh`)
```shell
python tb3_challenge1.py
```
Then you can run your ROS node:
```sh
ros2 run my_pkg tb3 # (you can also use `./run.sh`)
```
## Challenge 2
Um Challenge 2 laufen zu lassen, muss nach dem Klonen dieses Repos einfach folgendes eingegeben werden:
This should at least output:
```
waiting for messages...
```
If the robot is already brought up, then you should also get `LaserScan` messages:
```
F: 0.5624107122421265
R: 0.3894226849079132
...
```shell
python tb3_challenge2.py
```
### 2nd window - writing code
## Challenge 4
Um Challenge 4 laufen zu lassen, muss nach dem Klonen dieses Repos einfach folgendes eingegeben werden:
Open `tb3.py` with your your favorite text editor, e.g., `vim`, `Visual Studio Code (Code OSS)`
### 3rd window - launching & monitoring Gazebo
```sh
rosenv
gazebo --verbose WORLD_FILE # the world file can be e.g., world.sdf
```shell
python tb3_challenge4.py
```
Should output:
```
Gazebo multi-robot simulator, ...
...
[Msg] Waiting for master.
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
...
[Msg] Loading world file [/home/...]
...
```
## Challenge 5
Um Challenge 5 laufen zu lassen, muss nach dem Klonen dieses Repos einfach folgendes eingegeben werden:
And if you open a world with TB3 or add it manually:
```
[INFO] [1608802634.071946263] [gazebo_ros_node]: ROS was initialized without arguments.
...
```shell
python tb3_challenge5.py
```
After TB3 is instantiated, you should see `LaserScan` values in the first window
## Notes
- In Gazebo, use CTRL+r on Gazebo to restart the simulation. This way you do not have to close and open Gazebo
- use CTRL+C to kill a command line process, e.g., your ROS program or non-responsive Gazebo
- if you get the following error:
```
[Err] ... EXCEPTION: Unable to start server[bind: Address already in use]. There is probably another Gazebo process running.
```
then choose another port for Gazebo, e.g.:
```
$ GAZEBO_MASTER_URI=:12346 gazebo --verbose challenge_2.sdf
```
- if you do not use the simulation, then close Gazebo to leave the processor resources for others. If the system is slow, `htop` may show you the reason. `htop` shows who the active processes belong to and processor usage.
- you can kill a process with process id 12345 using `kill 12345`. The process id is shown in the `PID` column in `htop`.
- `make clean` removes all generated files which may help in case of an error
- `tools/` folder contain convenience scripts, e.g.,
# Zusammenfassung
- `stop-tb3.sh`: to stop the robot manually
- `tb3-teleop.sh`: teleoperation using keyboard
Die Zusammenfassung der gesamten PLV-Woche ist [hier](https://joan.th-deg.de/~ps16214/sphinx-book-template/index.html#) zu finden.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment