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
DUCKIEDRONE_NAMEis the name of your virtual Duckiedrone. DTS prompts you to enter and confirm the password for the virtual Duckiedrone’sduckieaccount; the characters you enter are not displayed:dts duckiebot virtual create -t duckiedrone -c DD24 DUCKIEDRONE_NAME
Once created, start your virtual Duckiedrone by running the following command, where
DUCKIEDRONE_NAMEis the name of your virtual Duckiedrone:dts duckiebot virtual start DUCKIEDRONE_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,
dts matrix run --standalonestarts the Duckiematrix Engine in the environment where the command is run. Ifdtsis installed on the host machine, this command can be run from inside the Duckietown Workspace and is automatically delegated to the host machine, where it launches the native Renderer. For the split Duckietown Workspace workflow, start the Engine separately and rundts matrix runinside or outside the Duckietown Workspace.Attach the Duckiedrone to a Duckiematrix Entity:
dts matrix attach DUCKIEDRONE_NAME map_0/vehicle_0
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 DUCKIEDRONE_NAME is the name of your virtual Duckiedrone:
docker exec -it dts-virtual-DUCKIEDRONE_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 DUCKIEDRONE_NAME, where DUCKIEDRONE_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 DUCKIEDRONE_NAME.local:9000, where DUCKIEDRONE_NAME is the name of your virtual Duckiedrone) to verify container statuses.