10. Salir del clase. / 10. Leaving the class.

En este ejercicio, debemos sacar al Piero de la clase mediante el uso de programas previos y el bloque de MatLab Function.

In this exercise, we need to get the Piero out of the class by using previous programs and MatLab Function block. 

10.1 Basic

 

road.pngAquí podemos ver el camino que Piero necesitaba seguir para salir de la clase. El camino fue dado por nosotros como una matriz. Esta matriz se calculó en MatLab function y el resto de bloques de Simulink. 

 

Over here we can see the path that Piero needed to follow in order to get out of the class. The path was given by us as a matrix. This matrix was computed in MatLab function and the rest of Simulink blocks. 

10.2. Simulink.

sim2.png.2

Arriba podemos ver el aspecto general de nuestro proyecto. En el marco azul, tenemos los mismos bloques que en el proyecto 8 - Cinemática de Robots Móviles. Las únicas adiciones son bloques fuera del marco.

 

Above we can see the overall look of our project. In the blue frame, we have the same blocks as in project 8 - Kinematics of Mobile Robots. The only additions are blocks out of the frame. 

 

MATLAB Function:

funkcja.png.1

Aquí está la función que proporcionará la velocidad y el ángulo theta para cada punto de la matriz camino.

También necesitamos un Unit Delay bloque de unidad para tener el estado inicial de i = 0,que no podemos inicializar en la función porque se está ejecutando desde la primera línea hasta la última todo el tiempo.

 

Here is the function that will provide the velocity and angle theta for each point of matrix camino. 

We also need a Unit Delay block to have the initial state of i = 0, which we can not initialise in the function because it is running from the first line to the last one all of the time.

 

 

 

 function.pngAquí podemos ver el código de la función MATLAB.

Estados y función que estamos utilizando:

L - es la distancia entre Piero y el punto de control en el que Piero puede comenzar a realizar el siguiente punto (precisión).

v- velocidad inicial

theta - ángulo inicial

i - punto de control

camino (i, 1) - distancia del punto de control en el eje Y.

camino (i, 2) - distancia del punto de control en el eje X.

distancia - la distancia entre el punto de control y Piero.

atan2 (a, b) - el resultado de esta función es un ángulo donde a es un seno de este ángulo yb es coseno.

lenght(camino) - el tamaño de la matriz camino.

 

¿Cómo funciona esta función?

Si todavía estamos en el rango de camino matrix, entonces el programa está contando la distancia hasta el siguiente punto. Si la distancia es menor que la L (precisión) estamos cambiando el punto al siguiente, disminuimos la velocidad y estamos esperando hasta que Piero salga de la zona de precisión. Después de eso, contamos el ángulo theta al siguiente punto mediante la función atan2 (a, b). Por esas operaciones, estamos estableciendo la velocidad lineal y la angular. Si "i" está fuera del tamaño de la matriz camino para detener el Piero, establecemos theta = 0 y v = 0 .

 

Here we can see the code from MATLAB function.

States and function that we are using:

L - it is the distance between Piero and the control point in which Piero can start performing the next point (accuracy).

v- initial velocity

theta - initial angle

i - control point 

camino(i,1) - distance of i control point on Y axle. 

camino(i,2) - distance of i control point on X axle. 

distancia - the distance between the control point and Piero.

 atan2(a,b) - the result of this function is an angle where a is a sine of this angle and b is cosine.

 lenght(camino) - the size of the matrix camino.

 

 How does this function work?

If we are still in the range of camino matrix - then the program is counting distance to the next point. If the distance is lower than the L (accuracy) we are changing the point to the next one, decrease velocity and we are waiting until Piero will get out of the accuracy zone. After that, we count theta angle to the next point by atan2(a,b) function. By those operations, we are setting the linear velocity and the angular one. If "i" is out of the size of camino matrix in order to stop the Piero we set theta=0 and v=0.

Saliendo de la clase. /Going out of the class.

Animación flash
Detalles

10.3. Resumen. / 10.3. Summary.

Para resumir nuestro programa funciona y pudimos salir de la clase.

Cuando estábamos revisando el programa notamos un extraño comportamiento de Piero. Resulta que estaba conectado a la batería baja de Piero. Es importante verificar la batería una vez, porque si no, Piero podría hacer algunos movimientos no programados o podría hacer los programados pero con peor precisión.

 

To sum up our program works and we were able to get out from the class. 

By the time that we were checking the program we noticed strange behavior of Piero. It turns out it was connected to the low battery of Piero. It is important to check the battery one a while, because if not Piero could do some unprogrammed moves or it could do the programmed ones but with worse precision.