Práctica 3: Obstacle Avoidance

 Welcome!

Picture 1. Overtaking in an F1 race

Goal:

In this exercise we are going to implement the logic of the VFF (Virtual Force Field) navigation algorithm, where each object generates a repulsive force towards the robot and it´s destiny an attractive force.

Explanation:

In this exercise we were asked to design a version of the VFF (Virtual-Force-Field) algorithm, in which an F1 car must travel the circuit taking into account that this time it will have obstacles on the way and you will have to dodge them.

First, I've declared three constants, one to check if you've hit the target, and the other two corresponding to the alpha and beta values ​​that will be applied to calculate the resultant force.

Then I have implemented the function absolute2relative(), which, as its name indicates, converts the absolute coordinates (point (0,0) at the beginning of the circuit) to relative ones (positive x-axis means forward and positive y-axis means left).

The functions corresponding to the laser parse_laser_data() and laser_vector() have also been implemented, whose main function is to read the data that the laser collects.

Once we have declared all the functions that were given to us in the statement of the practice, I have created two new functions, one for the attractive force and another for the repulsive force, which are explained in more detail below:

- The attractive_force() function gets the force generated by the target, using the distance between the target and the car based on the coordinates of the car.

- The repulsive_force() function establishes a value for each measurement taken by the laser, for which an inverse proportionality must be defined by dividing the distance between the car and the obstacle, where the higher values ​​correspond to a lower distance from the obstacle. Finally, all the x and y components are added to obtain the total repulsive force.

And finally, already in the main function, within the while True loop, once we have declared all the variables corresponding to the position parameters of the car, forces, vectors, etc, and calls to all the functions explained above, we calculate the resulting force following the following formula:

Resultant Force = α * Attractive Force + β * Repulsive Force

Where the value of alpha should not be very high to avoid collisions, the same happens with beta, since it can cause a blockage when reaching the target, and whose values ​​in the x and y axis will be applied to the linear and angular speeds that will be taking the car, respectively.

With these values of α and β, the car takes approximately 2:40 minutes to complete one lap.

MULTIMEDIA CONTENT (SIMULATION IN UNIBOTICS):

Image: View of the car with it's force's diagram

Picture 2. Environment visualization

Video: Execution of the program

Picture 3. Execution of the program (Gazebo)


Picture 4. Execution of the program (first person view and force´s diagram)

Comentarios

Entradas populares de este blog

Práctica 1: Vacuum Cleaner

Práctica 2: Follow Line