-
Notifications
You must be signed in to change notification settings - Fork 0
/
movimiento.h
89 lines (79 loc) · 1.82 KB
/
movimiento.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#pragma once
#include "util_unique_ptr.h"
#include "util_tiempo.h"
namespace movimiento
{
/**
* Clase auxiliar para informar sobre la velocidad a
* la que desea que ande cada motor.
*/
struct vel_mot
{
float izq, der;
vel_mot()
: izq(0), der(0)
{}
/**
* Izquierda y derecha respectivamente.
*/
vel_mot(float, float);
};
/**
* Clase auxiliar que define un movimiento.
* Cada movimiento puede tener sub movimientos y cuando
* éste termina se vuelve automáticamente a actualizar el
* movimiento padre.
*/
class sub_mov
{
friend class movimiento;
util::micros_t comienzo_ = 0;
util::unique_ptr<sub_mov> padre_;
bool terminado_ = false;
bool terminado() const;
protected:
/**
* Funcion que al ser llamada cambia el estado del
* movimiento a terminado.
*/
void terminar();
/**
* Agrega un submovimiento.
*/
void agregar_sub(util::unique_ptr<sub_mov>);
/**
* Llamada por actualizar().
* El argumento es la cantidad de microsegundos que pasaron
* desde la última actualización.
*/
virtual vel_mot actualizar_imp(util::micros_t) = 0;
public:
virtual ~sub_mov(){}
/**
* Retorna el estado de los motores necesario para cumplir el
* movimiento.
*/
vel_mot actualizar();
};
/**
* Es una interfaz de más alto nivel para moverse.
* Llama a los motores en la implementación.
*/
class movimiento
{
friend class sub_mov;
util::unique_ptr<sub_mov> mov_;
public:
/**
* Los parametros son representan un punto de destino en coordenadas
* cartesianas y un ángulo en radianes respecto al sistema de coordenadas
* actual en el que se quiere estar orientado.
*/
void mover(float, float, float);
/**
* Función para la integración con el contenedor de componentes.
* Actualiza los motores de acuerdo con dónde se quiere viajar y una estimación de dónde estamos.
*/
void actualizar();
};
}