Please refer to https://aerostack2.github.io/_02_examples/multirotor_simulator/project_multirotor_simulator/index.html for more information.
This project requires Aerostack2. Build it from the CVAR-UPM fork, which includes the patches this project depends on:
git clone https://github.com/GPatiA2/aerostack2.gitFollow the build/install instructions in that repository before continuing (it requires a working ROS2 installation).
The launch scripts (launch_as2.bash, launch_ground_station.bash) drive Aerostack2's per-node tmux sessions through tmuxinator, a Ruby gem:
sudo apt install tmux ruby ruby-dev
gem install tmuxinatorInstall the Python packages used by the mission scripts, plotting/analysis tools, and the experiment TUI:
pip3 install textual jinja2 matplotlib numpy scipy utm pyyamltextual powers the experiment TUI (tui_experiments.py); jinja2, matplotlib, numpy, scipy, and utm are used by the mission generation, plotting, and metrics scripts; pyyaml is used for reading/writing the mission and experiment spec files.
The remaining Python imports (rclpy, as2_python_api, as2_msgs, geometry_msgs, sensor_msgs, std_msgs, visualization_msgs, tf2_ros, rosbag2_py, rosidl_runtime_py, launch, launch_ros) are provided by the ROS2 and Aerostack2 installations from step 1, not via pip.
git clone git@github.com:cvar-upm/project_coresense.gitTo start using this project, please go to the root folder of the project.
To launch aerostack2 nodes for each drone, execute once the following command:
./launch_as2.bashThe flags for the components launcher are:
- -c: motion controller plugin (pid_speed_controller, differential_flatness_controller), choices: [pid, df]. Default: pid
- -m: multi agent. Default not set
- -n: select drones namespace to launch, values are comma separated. By default, it will get all drones from world description file
- -g: launch using gnome-terminal instead of tmux. Default not set
To launch aerostack2 nodes for the ground station, execute once the following command:
./launch_ground_station.bashThe flags for the components launcher are:
- -m: multi agent. Default not set
- -t: launch keyboard teleoperation. Default not launch
- -v: open rviz. Default launch
- -r: record rosbag. Default not launch
- -n: drone namespaces, comma separated. Default get from world description config file
- -g: launch using gnome-terminal instead of tmux. Default not set
Missions are now defined as YAML specs and run through the experiment TUI, tui_experiments.py. Launch it from the project root:
python3 tui_experiments.pyThe TUI has two modes, toggled with the Spec Generator / Experiment Runner buttons at the top of the screen:
- Spec Generator: build and edit a mission spec — add/edit/delete waypoint areas (
Add [a],Edit [e],Delete [d]), preview the resulting waypoints, thenGenerate [g]to turn the spec into a mission YAML, orGenerate & Run [r]to generate and immediately launch it. - Experiment Runner: manage a batch of experiment runs (sweeps over parameters such as drone count or controller) —
Add [a]/Edit [e]/Delete [d]runs in the list, thenRun All [r]to execute them sequentially.
Both screens support Load [^o] / Save [^s] to read and write the underlying YAML files. You can also open the TUI directly against an existing spec or experiments file:
python3 tui_experiments.py path/to/spec_or_experiments.yaml
# or explicitly:
python3 tui_experiments.py --spec path/to/spec.yaml
python3 tui_experiments.py --experiments path/to/experiments.yamlBefore running a mission you still need the simulation stack up, as described in steps 1–2 above (./launch_as2.bash / ./launch_as2.bash -m for a swarm, plus ./launch_ground_station.bash if you want RViz/monitoring).
If you are using tmux, you can end the execution with the following command:
./stop.bashYou can force the end of all tmux sessions with the command:
tmux kill-serverIf you are using gnome-terminal, you can end the execution by closing the terminal.
All projects in aerostack2 are structured in the same way. The project is divided into the following directories:
- tmuxinator: Contains the tmuxinator launch file, which is used to launch all aerostack2 nodes.
- aerostack2.yaml: Tmuxinator launch file for each drone. The list of nodes to be launched is defined here.
- ground_station.yaml: Tmuxinator launch file for the ground station. The list of nodes to be launched is defined here.
- config: Contains the configuration files for the launchers of the nodes in the drones.
- config_ground_station: Contains the configuration files for the launchers of the nodes in the ground station.
- launch_as2.bash: Script to launch nodes defined in tmuxinator/aerostack2.yaml.
- launch_ground_station.bash: Script to launch nodes defined in tmuxinator/ground_station.yaml.
- mission_*.py: Differents python mission files that can be executed.
- stop_tmuxinator_as2.bash: Script to stop all nodes launched by launch_as2.bash.
- stop_tmuxinator_ground_station.bash: Script to stop all nodes launched by launch_ground_station.bash.
- stop_tmuxinator.bash: Script to stop all nodes launched by launch_as2.bash and launch_ground_station.bash.
- rosbag/record_rosbag.bash: Script to record a rosbag. Can be modified to record only the topics that are needed.
- trees*: Contains the behavior trees that can be executed. They can be selected in the aerostack2.yaml file.
- utils: Contains utils scripts for launchers.
Both python and bash scripts have a help message that can be displayed by running the script with the -h option. For example, ./launch_as2.bash -h will display the help message for the launch_as2.bash script.
Note: For knowing all parameters for each launch, you can execute the following command:
ros2 launch my_package my_launch.py -sAlso, you can see them in the default config file of the package, in the config folder. If you want to modify the default parameters, you can add the parameter to the config file.