This project is a modular simulation environment for drone navigation, control, visualization, and interaction with dynamic targets using:
- ROS Noetic
- Gazebo Simulator
- ArduPilot
- MAVROS
- Joystick Input
It consists of several Python nodes that work together to simulate realistic drone behavior in a 3D environment.
The files that are used for manipulation, simulation and logging are: /root/uam_ws/src/uam_ros_pkg/uam_ros_ctl/src/collision_logger.py /root/uam_ws/src/uam_ros_pkg/uam_ros_ctl/src/drone_visualizer.py /root/uam_ws/src/uam_ros_pkg/uam_ros_ctl/src/joy_control_advanced.py /root/uam_ws/src/uam_ros_pkg/uam_ros_ctl/src/spawn_targets.py
Collision Logger is a ROS-based Python script that logs when a drone (or robot) comes within a specified distance of predefined targets in a Gazebo simulation. It tracks real-time positions of both the drone and target objects, and writes a log entry whenever a pass-through event occurs.
- Monitors drone position via
/red/posetopic (PoseStamped). - Tracks target positions via
/gazebo/model_states. - Logs proximity events when the drone comes within a defined threshold.
- Writes detailed logs (with timestamps) to a specified file.
| Parameter | Description | Default |
|---|---|---|
~target_names |
List of Gazebo model names to track | ["red/target_1", ..., "red/target_6"] |
~log_file |
Path to the output log file | /root/uam_ws/src/uam_ros_pkg/uam_ros_ctl/src/scripts/target_log.txt |
~proximity_threshold |
Distance in meters to trigger logging | 1.5 |
Drone Visualizer is a ROS-based Python script that publishes RViz visualization markers to represent a drone’s live pose and trajectory in the simulation world. It uses visualization_msgs/Marker to render an arrow for the current position and a line strip for the flight path.
- Visualizes the drone's current position and orientation with an arrow.
- Draws a persistent trajectory line showing the drone’s flight path.
- Publishes to RViz-compatible topics for real-time debugging and monitoring (use world frame).
| Topic | Message Type | Description |
|---|---|---|
/red/pose |
PoseStamped |
Drone pose input |
/drone_visualization_marker |
Marker |
RViz arrow marker for live pose |
/drone_trajectory_marker |
Marker |
RViz line strip for flight path |
- Current Pose (Arrow): Green arrow scaled for visibility
- Trajectory Path (Line Strip): Red line showing position history
Joy Controller Advanced is a ROS-based Python script that allows manual drone control using a joystick (via the /joy topic). It converts joystick inputs into velocity commands using mavros and publishes them to control the drone in real time.
- Maps joystick axes to drone velocity (forward/backward, left/right, up/down, yaw rate).
- Publishes velocity setpoints to
/red/mavros/setpoint_raw/local. - Provides live feedback on drone position.
- Throttle-friendly logging to avoid console spam.
- Includes reference MAVROS commands for arming, mode setting, and takeoff.
| Axis Index | Control | Scale |
|---|---|---|
axes[1] |
Forward/Backward | × 3.0 |
axes[0] |
Left/Right | × 3.0 |
axes[4] |
Up/Down | × 3.0 |
axes[3] |
Yaw Rotation | × 2.0 |
Spawn Targets is a ROS Python script used to dynamically spawn multiple drone gate models in a Gazebo simulation environment. It utilizes the /gazebo/spawn_sdf_model service and allows you to configure model poses, orientations, and scaling per gate.
- Spawns 12 predefined drone gates (models) into Gazebo using
SDF. - Allows customization of namespace, position, orientation, and scale.
- Supports spawning rotated gates using roll/pitch/yaw converted to quaternions.
The script:
- Reads gate model data from
.sdffiles. - Uses
geometry_msgs/Poseandtf.transformationsto set correct position & orientation. - Calls the
/gazebo/spawn_sdf_modelservice to spawn each gate in sequence.
| Param | Description | Default |
|---|---|---|
~namespace |
Namespace prefix for model names | red |
The models/ folder contains a .dae file used for the drone race gate.
Make sure to place it in:/root/.gazebo/models/drone_gate/
Everything is run in a specific order in the tmuxinator file which is located /root/uav_ros_simulation/startup/kopterworks_joystick_flying/
which is run with the start.sh file in the same path