Virtual Duckiedrone Takeoff Demo
Contents
Virtual Duckiedrone Takeoff Demo#
This chapter describes the Takeoff demo (demonstration) for virtual Duckiedrones.
What you will need
What you will get
A virtual Duckiedrone successfully arming and taking off autonomously.
Introduction to virtual Duckiedrone takeoff#
Setup#
To set up the demo:
Create a virtual Duckiedrone by running the following command, where
ROBOT_NAMEis the name of your virtual Duckiedrone:dts duckiebot virtual create -t duckiedrone -c DD24 ROBOT_NAME
Once created, start your virtual Duckiedrone by running the following command, where
ROBOT_NAMEis the name of your virtual Duckiedrone:dts duckiebot virtual start ROBOT_NAME
Run the Duckiematrix using the
sandbox_dronemap by running:dts matrix run --standalone --embedded --map sandbox_drone
Start the matrix with the
sandbox_dronemap:dts matrix run --standalone -d --map sandbox_drone
Note
If you are using a Duckietown Workspace, the
--standaloneflag starts both the Duckiematrix Engine and Renderer in the same environment. For the split workspace workflow, start the Engine separately and connect to it withdts matrix runfrom a local terminal outside the dev container.Attach the Duckiedrone to the matrix engine:
dts matrix attach ROBOT_NAME map_0/vehicle_1
Attention
Wait for all containers to be running before proceeding to the next step.
Start#
To run the demo on your virtual Duckiedrone, run the following command, where ROBOT_NAME is the name of your virtual Duckiedrone:
docker exec -it dts-virtual-ROBOT_NAME docker exec -it ros2-mavros bash
Inside the bash prompt:
Set your virtual Duckiedrone to takeoff mode by running:
ros2 service call /mavros/set_mode mavros_msgs/srv/SetMode "{base_mode: 0, custom_mode: 'AUTO.TAKEOFF'}"
Note
Expected output:
response: mavros_msgs.srv.SetMode_Response(mode_sent=True)
Arm your virtual Duckiedrone to initiate takeoff by running:
ros2 service call /mavros/cmd/arming mavros_msgs/srv/CommandBool "{value: true}"
Note
Expected output:
requester: making request: mavros_msgs.srv.CommandBool_Request(value=True) response: mavros_msgs.srv.CommandBool_Response(success=True, result=0)
Your virtual Duckiedrone should now arm and begin its takeoff sequence to a default height of 2.5 m.
Stop#
To stop the demo:
Land your virtual Duckiedrone by setting it to
AUTO.LANDmode by running:ros2 service call /mavros/set_mode mavros_msgs/srv/SetMode "{base_mode: 0, custom_mode: 'AUTO.LAND'}"
Select the terminal from which the demo was run.
Press Ctrl+D.
How it works#
The Takeoff demo consists of the following steps:
MAVROS interface establishes communication between ROS2 and the PX4 flight controller via the MAVLink protocol.
Mode setting configures the flight controller to
AUTO.TAKEOFFmode, which prepares your virtual Duckiedrone for autonomous takeoff.Arming enables the motors, allowing your virtual Duckiedrone to generate thrust.
Takeoff execution uses the flight controller’s autopilot to execute a controlled vertical ascent to a predefined altitude.
The MAVROS node acts as a bridge, translating ROS2 service calls and topic publications into MAVLink messages that the flight controller understands, and vice versa.
Debugging and parameter tuning#
If the performance of your virtual Duckiedrone is inconsistent or the takeoff does not execute properly, consider the following debugging steps.
Verifying MAVROS connection#
Check that MAVROS is properly connected to the flight controller by running:
ros2 topic echo /mavros/state
You should see output indicating that the flight controller is connected and that the mode is being reported.
Checking sensor data#
Verify that sensor data is being published by running:
ros2 topic list
Look for topics such as /mavros/imu/data, /mavros/battery and /mavros/altitude, and echo them to verify data flow.
Troubleshooting#
Troubleshooting
SYMPTOM
My virtual Duckiedrone does not arm.
RESOLUTION
Verify that the flight controller is in a safe state and that all pre-arm checks have passed. Check the /mavros/state topic to ensure that the mode is set correctly.
Troubleshooting
SYMPTOM
MAVROS cannot connect to the flight controller.
RESOLUTION
Restart your virtual Duckiedrone using dts duckiebot virtual restart ROBOT_NAME, where ROBOT_NAME is the name of your virtual Duckiedrone.
Troubleshooting
SYMPTOM
My virtual Duckiedrone arms but does not take off.
RESOLUTION
Verify that the takeoff mode was set correctly before arming. Some flight controllers require the mode to be set before arming.
Troubleshooting
SYMPTOM
I see service call return errors.
RESOLUTION
Ensure that all containers in the ros2 stack are running. Use docker ps or Portainer (accessible through your virtual Duckiedrone’s Dashboard or at ROBOT_NAME.local:9000, where ROBOT_NAME is the name of your virtual Duckiedrone) to verify container statuses.