
Today, we are combining an autonomous drone control program with a ball detection program in order to burst a balloon with an autonomous drone.
In previous articles, we examined the launch of an autonomous virtual and real drone, as well as the development of an ROS node that defines and transfers the coordinates of a ball in space . Now we’ll remake the drone control program so that it automatically tries to burst the ball.
The program flying to the ball
The program flying to the ball is based on the same speed control cycle as in the manual control program .
The difference is that instead of the control keys from the keyboard, the drone velocity vector is controlled by information on the position of the ball obtained from the topic /baloon_detector/twist
.
setvel_forward
speeds and setvel_forward
vector setvel
set so that the drone flew right into the ball.
If the drone does not see the ball for more than 0.2 seconds, we believe that we burst it and put the drone in landing mode.
The full text of the program is given below: (crash_baloon.py) Debugging Recommendations
For debugging, we recommend choosing an open space, attaching the ball to the base, making sure that there are no red objects nearby so that there are no false positives of the guidance program.
The operation of the guidance program, before the flight, should be checked using a browser, at 192.168.11.1:8080:

If everything is configured correctly, the program must confidently distinguish the ball and not cause false positives.

At the start of the guidance program, it is assumed that the drone should see the ball after takeoff. Otherwise, the drone will think that the ball has already burst, and will switch to landing mode.
In the future, you can modify the program - to fly up to the ball, for example, using the AUTO.MISSION mode. And after reaching the desired GPS point, switch to visual search mode.
The selection of coefficients for speeds in the main cycle of the program is carried out experimentally for a specific drone.
At competitions, attempts to burst the ball looked like this:
I would be grateful for comments and questions from those who try to repeat our experiment.
Source codes for the programs are uploaded to Github .