Fork de Timer après le match à 61 points

Dependencies:   RoboClaw mbed

Fork of Timer by ARES

deplacement.cpp

Committer:
IceTeam
Date:
2016-05-06
Revision:
86:0c5e9ac3d8d8
Child:
88:e4de39dd3e2e

File content as of revision 86:0c5e9ac3d8d8:

#include "entete.h"

void GotoDist(float timer) {
    Timer t;
    
    roboclaw.SpeedAccelM1(accel_dista, vitesse_dista);
    roboclaw.SpeedAccelM2(accel_dista, vitesse_dista);
    
    t.reset();
    t.start();
    
    while (t.read() < timer) {
        if (Ravance != 1) {
            roboclaw.ForwardM1(0);
            roboclaw.ForwardM2(0);
            t.stop();
            while (Ravance != 1);
            roboclaw.SpeedAccelM1(accel_dista, vitesse_dista);
            roboclaw.SpeedAccelM2(accel_dista, vitesse_dista);
            t.start();
        }
    }
    
    roboclaw.ForwardM1(0);
    roboclaw.ForwardM2(0);
    
    t.stop();
    t.reset();
    
    wait(waiting_time);
}

void GotoThet (float timer, int signe) {
    Timer t;
    
    if (signe < 0) {
        roboclaw.SpeedAccelM1(accel_dista, vitesse_dista);
        roboclaw.SpeedAccelM2(-accel_dista, -vitesse_dista);
    }
    else {
        roboclaw.SpeedAccelM1(-accel_dista, -vitesse_dista);
        roboclaw.SpeedAccelM2(accel_dista, vitesse_dista);
    }
    
    t.reset();
    t.start();
    
    while (t.read() < timer) {
        if (Ravance != 1) {
            roboclaw.ForwardM1(0);
            roboclaw.ForwardM2(0);
            t.stop();
            while (Ravance != 1);
            t.start();
        }
        if (signe < 0) {
            roboclaw.SpeedAccelM1(accel_dista, vitesse_dista);
            roboclaw.SpeedAccelM2(-accel_dista, -vitesse_dista);
        }
        else {
            roboclaw.SpeedAccelM1(-accel_dista, -vitesse_dista);
            roboclaw.SpeedAccelM2(accel_dista, vitesse_dista);
        }
    }
    
    roboclaw.ForwardM1(0);
    roboclaw.ForwardM2(0);
    
    t.stop();
    t.reset();
    
    wait(waiting_time);
}