RoboticsAcademy - Follow Road

The follow-road exercise is akin to a line follower with a drone. In this, a solution for the control of the AR-Drone is made using OpenCV to segment and find the alignment of the road while the JdeRobot API is used to send commands to the drone.

Follow Road Image

A solution for this exercise is required to verify the correct working of the exercise when ported to using the new backend: ROS, PX4 and MAVROS.

The current solution was implemented in the following steps:

  1. Using the colorTuner, the HSV region is found that best segments the road and background.
  2. These values are used to segment the recieved image (after its conversion from BGR to HSV)
  3. Contours are found in the lower half of the image (as this solution utilizes the front camera of the drone flying at a very low altitude) and the longest contour, presumably representing the largest segment of visible road, is used to fit an ellipse.
  4. The center of this ellipse is passed to a proportional controller on the angular rate which is futher bounded by a maximum allowed angular velocity.
  5. The drone is sent the result of the controller and a constant forward velocity using the JdeRobot API
  6. The ellipse, its center, the selected contour and a central line are drawn for visualization purposes.

(Click on the image for the video)

Follow-Road Video

MAVROS Exercise

The second task for this week was to make a ROS project using the new infrastructure (MavROS-based) to execute a complete closed trajectory (take off, hover, fly, hover, land at the take-off point) at a given height, just using relative speed commands (forward speeds, yaw rotation speeds).

The requirement presented by this task, though fulfilled by modifying the offb_position_control for velocity control and further for an entire trajectory was a simple but hacky approach to verify the feasibility of velocity based control in the body frame.

The real requirement, for both, this task and all exercises is a class that will able to abstract all the functions of MAVROS and present something as simple as:

drone = DroneWrapper(verbose=True)
drone.takeoff()
drone.set_cmd_vel(vx=1,az=1)
drone.land()

to fly in a circle (with appropriate sleep commands of course). For this, I present DroneWrapper as a solution.

Wrapped Drone

This class (built taking help from previous work and [1] [2] [3] [4] [5] ) provides a simple API for some of the various functions required in the exercises. The code for the task is made as simple as provided in trial.py.

I plan to build upon this in the coming weeks to facilitate all the required functions by the exercises.

(Click on the image for the video)

DroneWrapper