-
Notifications
You must be signed in to change notification settings - Fork 0
4. Keyboard Control and Autonomous Flight
Using this stack and espdrone-ros, the ESP-drone is able to:
- Use keyboard control in an assisted flight
- Fly autonomously following preprogrammed waypoints
The ArUco positioning system is required for both autonomous flight and keyboard control. Hence, the drone must be able to see at least 2 markers at a time throughout the entire flight, otherwise it will drift and crash.
This is not a "fully manual" control; the keyboard tells the drone which direction to go instead of controlling attitude and motor power, and the drone automatically stabilizes itself. You can think of this as autopilot, and the keyboard simply tells the autopilot where the drone should go.
Keyboard control is enabled by launching the drone with the -k or --keyboard flag after launch_espdrone_aruco as demonstrated in 3. Usage, e.g.:
launch_espdrone_aruco -d espdrone1 espdrone2 -e iot_lab -kYou can follow the instruction printed on the terminal screen for which keys are used.
You have to specify the waypoints that the drone should follow before launching the drone in an autonomous flight. The waypoints are described in the drone configuration YAML file by the waypoints_list key. For instance:
drone_ip_addr : "192.168.0.112"
camera_info_file: "espdrone1_640x480.yaml"
visualize_output: "true"
waypoints_list : [[0.0, 0.0, 0.5, 0, 5.0], [1.0, 1.0, 0.5, 90, 5.0]]Each waypoint is a list with the format [x, y, z, yaw, hover_time] in meters for x, y, z, degrees for yaw or orientation, and seconds for hover_time.
To fly the drone autonomously following the described waypoints, launch the drone using launch_espdrone_aruco with the -k or --keyboard flag, then press m to initiate autonomous flight.
During the flight, you can pause or resume the mission by pressing SPACE. When paused, you can control the drone manually using keyboard (assisted flight).
Although you can manually input waypoints_list to the drone configuration file, you can use waypoint_recorder utility provided by the espdrone-ros ROS package. This utility records the position of the drone and automatically adds or updates waypoints_list inside the configuration file. To use the utility:
- Launch the drone that you would like to record waypoints for.
launch_espdrone_aruco -d espdrone_name -e env_name
- Launch the
waypoint_recorderutility, specifying the name of the drone.A new terminal should then appear, prompting you the duration of hover for each waypoint. Enter the desired hover time (in seconds). You can change this value later by pressingroslaunch espdrone_utils waypoint_recorder.launch drone_name:=replace_this_with_drone_name
d. - You can now bring the drone by hand to the desired location and orientation, keeping at least 2 ArUco markers visible. Press
SPACEto record that position and orientation as a waypoint. You can record as many waypoints as you like. - When you are done, press
ENTERto save the recorded waypoints to the drone configuration file. No need forcatkin build. - Finally, restart ROS so that the drone will follow the new waypoints.