sjtu_drone is a quadrotor simulation program forked from tum_simulator, developed using ROS + Gazebo.
The acronym 'sjtu' stands for Shanghai Jiao Tong University. This package has been used in the past for testing algorithms for the UAV contest at SJTU
This package is tested with ROS 2 Humble version (Ubuntu 22.04) and Gazebo 11.
cd ~/git && git clone git@github.com:NovoG93/sjtu_drone.git -b ros2
cd ~/ros2_ws/src && ln -s ~/git/sjtu_drone
cd .. && rosdep install -r -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO && colcon build --packages-select-regex sjtu*
To use the playground.world file (as depicted below) make sure to install the common gazebo models, for more see the Readme in sjtu_drone_description.
The folowing sensors are currently implemented:
- ~/front_camera/image_raw [sensor_msgs/msg/Image]
- ~/bottom/image_raw [sensor_msgs/msg/Image]
- ~/sonar [sensor_msgs/msg/Range]
- ~/imu [sensor_msgs/msg/Imu]
The following control topics are currently subscribed to:
- ~/cmd_vel [geometry_msgs/msg/Twist]: Steers the drone
- ~/land [std_msgs/msg/Empty]: Lands the drone
- ~/takeoff [std_msgs/msg/Empty]: Starts the drone
- ~/posctrl [std_msgs/msg/Bool]: Switch to position control
- ~/dronevel_mode [std_msgs/msg/Bool]: Change the drone steering method
- ~/reset [std_msgs/msg/Empty]: Resets the drone
The following ground truth topics are currently published:
- ~/gt_acc [geometry_msgs/msg/Twist]: ground truth acceleration
- ~/gt_pose [geometry_msgs/msg/Pose]: ground truth pose
- ~/gt_vel [geometry_msgs/msg/Twist]: ground truth velocity
- Start the docker container:
bash run_docker.sh
- Connect to docker container to takeoff / land drone:
docker container exec -it sjtu_drone 'ros2 topic pub /drone/takeoff std_msgs/msg/Empty {} --once'
docker container exec -it sjtu_drone 'ros2 topic pub /drone/land std_msgs/msg/Empty {} --once'
- Start gazebo, spawn drone, open teleop in xterm window, and open rviz:
ros2 launch sjtu_drone_bringup sjtu_drone_bringup.launch.py
- Takeoff drone:
ros2 topic pub /drone/takeoff std_msgs/msg/Empty {} --once
- Move drone: (use teleop window)
- Land drone:
ros2 topic pub /drone/land std_msgs/msg/Empty {} --once
You should see the following:
For more see the following image:
The parameters of the PID controller that controls the drone and the motion noise can be changed by adapting the file sjtu_drone.urdf.xacro:
<plugin name='simple_drone' filename='libplugin_drone.so'>
<bodyName>base_link</bodyName>
<rosNamespace>drone</rosNamespace>
<imuTopic>imu</imuTopic>
<rollpitchProportionalGain>10.0</rollpitchProportionalGain>
<rollpitchDifferentialGain>5.0</rollpitchDifferentialGain>
<rollpitchLimit>0.5</rollpitchLimit>
<yawProportionalGain>2.0</yawProportionalGain>
<yawDifferentialGain>1.0</yawDifferentialGain>
<yawLimit>1.5</yawLimit>
<velocityXYProportionalGain>5.0</velocityXYProportionalGain>
<velocityXYDifferentialGain>2.3</velocityXYDifferentialGain>
<velocityXYLimit>2</velocityXYLimit>
<velocityZProportionalGain>5.0</velocityZProportionalGain>
<velocityZIntegralGain>0.0</velocityZIntegralGain>
<velocityZDifferentialGain>1.0</velocityZDifferentialGain>
<velocityZLimit>-1</velocityZLimit>
<positionXYProportionalGain>1.1</positionXYProportionalGain>
<positionXYDifferentialGain>0.0</positionXYDifferentialGain>
<positionXYIntegralGain>0.0</positionXYIntegralGain>
<positionXYLimit>5</positionXYLimit>
<positionZProportionalGain>1.0</positionZProportionalGain>
<positionZDifferentialGain>0.2</positionZDifferentialGain>
<positionZIntegralGain>0.0</positionZIntegralGain>
<positionZLimit>-1</positionZLimit>
<maxForce>30</maxForce>
<motionSmallNoise>0.05</motionSmallNoise>
<motionDriftNoise>0.03</motionDriftNoise>
<motionDriftNoiseTime>5.0</motionDriftNoiseTime>
</plugin>
- No ROS communication between docker container and host
- Change of ROS namespace not working automatically for plugin_drone when changed in spawn_drone.py
- TODO: Change to gazebo_ros::Node::SharedPtr