Skip to content

Commit

Permalink
ROS2 upgrade (#14)
Browse files Browse the repository at this point in the history
* Migrate to ROS2
* Add Qt-based GUI
* Update docker and README
  • Loading branch information
kanishkegb authored Sep 2, 2024
1 parent b91cd04 commit fb5577a
Show file tree
Hide file tree
Showing 39 changed files with 1,931 additions and 897 deletions.
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,38 @@ tags
# Persistent undo
[._]*.un~

### ROS2 ###
install/
log/
build/

# Ignore generated docs
*.dox
*.wikidoc

# eclipse stuff
.project
.cproject

# qcreator stuff
CMakeLists.txt.user

srv/_*.py
*.pcd
*.pyc
qtcreator-*
*.user

*~

# Emacs
.#*

# Colcon custom files
COLCON_IGNORE
AMENT_IGNORE


### vscode ###
.vscode/*
!.vscode/settings.json
Expand Down
14 changes: 5 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
FROM ros:noetic-ros-core-focal
FROM ros:iron-ros-core-jammy
RUN apt update
RUN apt -y install python3-pip python3-gi python3-pip tmux
RUN apt -y install mesa-utils libgl1-mesa-glx dbus
RUN apt -y install libgtk-3-dev python3-gi gobject-introspection
RUN apt -y install ros-noetic-gazebo-ros-pkgs ros-noetic-gazebo-ros-control ros-noetic-xacro
RUN apt -y install python3-pip tmux
RUN apt -y install python3-colcon-common-extensions
RUN apt -y install ros-iron-gazebo-ros-pkgs ros-iron-gazebo-ros2-control ros-iron-xacro
RUN python3 -m pip install pip --upgrade
RUN python3 -m pip install numpy pandas matplotlib

RUN python3 -m pip install -U rosdep
RUN sudo rosdep init
RUN rosdep update
RUN python3 -m pip install PyQt5

RUN adduser --disabled-password sim
USER sim
Expand Down
40 changes: 23 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,8 @@ If you want to install everything locally, follow [Local Install](#local-install
If you want to run a docker container instead, skip to [Docker Setup](#docker-setup).

#### Local Install
1. [ROS](http://wiki.ros.org/): this repository has been developed using ROS Noetic, on Ubuntu 20.04. If you are on ROS Melodic with Ubuntu 18.04, please checkout `ros-melodic` branch before installing dependencies.
1. Python GTK libraries for GUI (not required if you opt to not to use the GUI)
```sh
sudo apt-get install python3-pip python3-gi
```
1. [ROS2](http://wiki.ros.org/): this repository has been developed using ROS2 Iron, on Ubuntu 22.04. If you are on a different version of Ubunto or ROS, please check the previous releases before installing dependencies. We recommend installing the ROS2 full version.

1. Python modules: these libraries must be installed in the system
1. NumPy
1. Pandas
Expand Down Expand Up @@ -127,7 +124,7 @@ The first time you run the build command will take a while as it installs all th
You can skip the build command altogether by pulling the built docker from the Docker Hub with the following command.
This is NOT required if you are building it locally using the build command.
```sh
docker pull kanishgama/uav_simulator:ros-noetic
docker pull kanishgama/uav_simulator:ros2-iron
bash docker_run.sh
```

Expand All @@ -142,40 +139,47 @@ You only need to do the followings once (unless you change the Gazebo plugins)
1. Make the plugging.
```sh
# From uav_simulator
catkin_make
colcon build
```
1. Source the relevant directories (**NOTE**: you need to do this on every new terminal).
```sh
# From uav_simulator
cd devel && source setup.bash && cd ../
source install/local_setup.bash
```

### Running the simulation environment
1. In the current terminal window, launch the Gazebo environment:
```sh
# From uav_simulator
roslaunch uav_gazebo simple_world.launch
ros2 launch uav_gazebo uav_gazebo.launch.py
```
1. Once the Gazebo is launched, run the rover code from a different rover terminal (if you already don't know, you may find [**tmux**](https://github.com/tmux/tmux/wiki) a life-saver):
1. Once the Gazebo is launched, run the UAV code from a different terminal (if you already don't know, you may find [**tmux**](https://github.com/tmux/tmux/wiki) a life-saver):
```sh
# From uav_simulator/scripts
python3 main.py
# From uav_simulator/src/fdcl_uav/launch
ros2 launch fdcl_uav_launch.py
```
If you change the Python code, simply re-run the Python code.
The code has been tested with Python3.8.10, which comes default with Ubuntu 20.04.
If you change the Python code, run the following command
```sh
# From uav_simulator
colcon build --packages-select fdcl_uav
```
Then, re-run the above launch command.
The code has been tested with Python3.10.12, which comes default with Ubuntu 22.04.
![Terminal](images/running.gif)
### Tips
1. Every time you change the simulation environment, you have to kill the program, `catkin_make` and re-run it.
1. If you do not make any changes to the simulation environment, you only need to kill the Python program.
1. The UAV will re-spawn at the position and orientation defined in `reset_uav()` in `rover.py` when you run the Python code.
<!-- 1. The UAV will re-spawn at the position and orientation defined in `reset_uav()` in `rover.py` when you run the Python code. -->
## Control Guide
* Simply click on the buttons on the GUI to control the UAV.
* You can easily switch between each trajectory mode simply clicking on the radio buttons.
* Stay mode simply commands the UAV to stay at the current position.
* When take-off, stay, and circle trajectories end, the UAV switched to the "manual" mode.
* When take-off, stay, and circle trajectories end, the UAV switches to the "manual" mode.
* When the UAV is in manual, you can use following keys (these are not case sensitive):
* `WASD`: to move in horizontal plane
* `P`: increase altitude
Expand All @@ -192,4 +196,6 @@ You only need to do the followings once (unless you change the Gazebo plugins)
* Make sure you are in the main directory.
* Run `python -m unittest`.
* Unit tests have only been tested on Python 3.9.
* Currently, unit test only covers the `matrix_utils.py` module.
* Currently, unit test only covers the `matrix_utils.py` module.
<!-- `export GAZEBO_PLUGIN_PATH=/home/kani/Documents/uav_simulator/build:$GAZEBO_PLUGIN_PATH` -->
6 changes: 5 additions & 1 deletion docker_run.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
docker run \
--rm \
--name uav-simulator-container \
--mount source="$(pwd)",target=/home/uav_simulator,type=bind \
--net host \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-u sim \
-e DISPLAY=unix$DISPLAY \
--privileged \
-it uav_simulator bash

# For debugging: once the container is first run with the above command, you
# can run the following command for the second and subsequent runs.
# docker start --interactive uav-simulator-container
224 changes: 0 additions & 224 deletions scripts/gui.py

This file was deleted.

Loading

0 comments on commit fb5577a

Please sign in to comment.