Position Control

The goal of this exercise is to implement a local navigation algorithm through the use of a PID controller.

For this exercise, a world has been designed in gazebo that contains the Iris quadrotor and 5 beacons arranged in a cross. The task is to program the drone to follow the route as given in the picture below.

Position Control.
Gallery.

Installation

Install the General Infrastructure of the JdeRobot Robotics Academy.

As this is a drones exercise, you will need to additionally install the jderobot-assets, dronewrapper and rqt_drone_teleop packages. These can be installed as

sudo apt-get install ros-melodic-drone-wrapper ros-melodic-rqt-drone-teleop ros-melodic-jderobot-assets

There is an additional dependency on MAVROS and PX4 that you can fulfill following the Drones installation instructions.

How to run

To launch the exercise, simply use the following command from this directory:

roslaunch position_control.launch

How to do the practice

To solve the exercise, you must edit the my_solution.py file and insert the control logic into it.

Where to insert the code

Your code has to be entered in the execute function between the Insert your code here comments.

my_solution.py

def execute(event):
  global drone
  img_frontal = drone.get_frontal_image()
  img_ventral = drone.get_ventral_image()
  # Both the above images are cv2 images
  ################# Insert your code here #################################

  set_image_filtered(img_frontal)
  set_image_threshed(img_ventral)

  #########################################################################

API

  • set_image_filtered(cv2_image) - If you want to show a filtered image of the camera images in the GUI
  • set_image_threshed(cv2_image) - If you want to show a thresholded image in the GUI
  • drone.get_frontal_image() - Returns the latest image from the frontal camera as a cv2_image
  • drone.get_ventral_image() - Returns the latest image from the ventral camera as a cv2_image
  • drone.get_position() - Returns the position of the drone as a numpy array [x, y, z]
  • drone.get_orientation() - Returns the roll, pitch and yaw of the drone as a numpy array [roll, pitch, yaw]
  • drone.get_roll() - Returns the roll of the drone
  • drone.get_pitch() - Returns the pitch of the drone
  • drone.get_yaw() - Returns the yaw of the drone
  • drone.set_cmd_vel(vx, vy, vz, az) - Commands the linear velocity of the drone in the x, y and z directions and the angular velocity in z in its body fixed frame
  • init_beacons() - Initializes the beacons
  • get_next_beacon() - Returns the next beacon to be visited
  • beacon.get_pose() - Returns pose of the beacon
  • beacon.get_id() - Returns id of the beacon
  • beacon.is_reached() - Returns reached of the beacon
  • beacon.set_reached(value) - Sets reached parameter of a beacon
  • beacon.is_active() - Returns active of the beacon
  • beacon.set_active(value) - Sets active parameter of a beacon

Theory

Comming soon.

Hints

Simple hints provided to help you solve the position_control exercise. Please note that the full solution has not been provided.

Comming soon.


Contributors