Skip to content

YassinBaraa/JoystickDroneController

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Drone Simulation Toolkit (ROS + Gazebo + ArduPilot)

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

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.

Key Features

  • Monitors drone position via /red/pose topic (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.

Parameters

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

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.

Features

  • 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).

Topics

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

Marker Setup

  • Current Pose (Arrow): Green arrow scaled for visibility
  • Trajectory Path (Line Strip): Red line showing position history

Joy Controller Advanced

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.

Features

  • 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.

Joystick Mapping

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 – Drone Gate Spawner for Gazebo

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.

Features

  • 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.

How It Works

The script:

  • Reads gate model data from .sdf files.
  • Uses geometry_msgs/Pose and tf.transformations to set correct position & orientation.
  • Calls the /gazebo/spawn_sdf_model service to spawn each gate in sequence.

Parameters

Param Description Default
~namespace Namespace prefix for model names red

Gate model

The models/ folder contains a .dae file used for the drone race gate.
Make sure to place it in:/root/.gazebo/models/drone_gate/

Startup

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors