
Robot's source code
Dependencies: mbed
Asserv_Plan_B/planB.cpp@64:6489bcfc1173, 2015-04-09 (annotated)
- Committer:
- sype
- Date:
- Thu Apr 09 17:40:53 2015 +0000
- Revision:
- 64:6489bcfc1173
- Parent:
- 62:454cd844fe1e
- Child:
- 67:0bdf181586b5
update asserv B
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jagang | 62:454cd844fe1e | 1 | #include "planB.h" |
Jagang | 62:454cd844fe1e | 2 | |
Jagang | 62:454cd844fe1e | 3 | aserv_planB::aserv_planB(Odometry &odometry,Motor &motorL,Motor &motorR) : m_odometry(odometry), m_motorL(motorL), m_motorR(motorR) |
Jagang | 62:454cd844fe1e | 4 | { |
sype | 64:6489bcfc1173 | 5 | consigne_g = 10.0; |
sype | 64:6489bcfc1173 | 6 | consigne_d = 10.0; |
sype | 64:6489bcfc1173 | 7 | vitesse_g = 0; |
sype | 64:6489bcfc1173 | 8 | vitesse_d = 0; |
sype | 64:6489bcfc1173 | 9 | erreur_g = 0; |
sype | 64:6489bcfc1173 | 10 | erreur_d = 0; |
sype | 64:6489bcfc1173 | 11 | cmd_g = 0; |
sype | 64:6489bcfc1173 | 12 | cmd_d = 0; |
sype | 64:6489bcfc1173 | 13 | Kp = 0.05; |
sype | 64:6489bcfc1173 | 14 | } |
sype | 64:6489bcfc1173 | 15 | |
sype | 64:6489bcfc1173 | 16 | void aserv_planB::control_speed() |
sype | 64:6489bcfc1173 | 17 | { |
sype | 64:6489bcfc1173 | 18 | vitesse_g = m_odometry.getVitLeft(); |
sype | 64:6489bcfc1173 | 19 | vitesse_d = m_odometry.getVitRight(); |
Jagang | 62:454cd844fe1e | 20 | |
sype | 64:6489bcfc1173 | 21 | erreur_g = consigne_g - vitesse_g; |
sype | 64:6489bcfc1173 | 22 | cmd_g = erreur_g*Kp; |
sype | 64:6489bcfc1173 | 23 | |
sype | 64:6489bcfc1173 | 24 | erreur_d = consigne_d - vitesse_d; |
sype | 64:6489bcfc1173 | 25 | cmd_d = erreur_d*Kp; |
sype | 64:6489bcfc1173 | 26 | |
sype | 64:6489bcfc1173 | 27 | m_motorL.setSpeed(cmd_g); |
sype | 64:6489bcfc1173 | 28 | m_motorR.setSpeed(cmd_d); |
Jagang | 62:454cd844fe1e | 29 | } |
Jagang | 62:454cd844fe1e | 30 | |
Jagang | 62:454cd844fe1e | 31 | void aserv_planB::update(float dt) |
Jagang | 62:454cd844fe1e | 32 | { |
Jagang | 62:454cd844fe1e | 33 | |
Jagang | 62:454cd844fe1e | 34 | } |