#ifndef VARIABLE_H
#define VARIABLE_H

#define MIN(a,b) ((a)>(b)?(b):(a))
#define MAX(a,b) ((a)<(b)?(b):(a))
#define DEGTORAD(a) (a/360*2*M_PI)
#define ANGLETOPULSE(a) (a*500)/124+1500

#ifndef NULL
#define NULL 0
#endif

//#define ROBOTHW
//#define CAPTEURS déjà mis dans asservissement

//HCTL_HANDLER
#define HCTL_BCL 1875000

//MOTEUR
#define NUM_TIMER_MOTEUR 4
#define PERIOD_TIMER_MOTEUR 71
#define PRESCALER_TIMER_MOTEUR 20000
#define CLOCK_TIMER_MOTEUR Timer::Div1

//TRAPEZOIDALCOMMAND
#define DISTANCE_ARRET 15
#define ANGLE_ARRET 0.01

//ASSERVISSEMENT
#define SEUIL_COLISION 3.5
#define MS_BETWEEN_UPDATE 10
#define CPT_BEFORE_RAZ 8500
#define LINEARE_DUTY_MAX 0.40
#define LINEARE_DUTY_MIN -0.40
#define ANGULARE_DUTY_MAX 0.50
#define ANGULARE_DUTY_MIN -0.50

//CAPTEURS
#define SEUIL_DETECTION 2000.

//COMMAND
#define VITESSE_LINEAIRE_MAX 3.
#define VITESSE_ANGULAIRE_MAX 0.01
#define ACCELERATION_LINEAIRE_MAX 0.05
#define ACCELERATION_ANGULAIRE_MAX (2*M_PI/5000.0)

//ODOMETRIE
#define TAILLE_ENTRAXE 273
#define RAYON_ROUE 40.326
#define NBR_TICK_PAR_TOUR 8192

//PIDFILTERANGLE
#define FILTER_ANGLE_KP 1.1
#define FILTER_ANGLE_KD 35
#define FILTER_ANGLE_KI 0.1
#define FILTER_ANGLE_COEF 0.83

//PIDFILTERLINEAIRE
#define FILTER_LINEAIRE_KP 0.01
#define FILTER_LINEAIRE_KD 0.3
#define FILTER_LINEAIRE_KI 0.02
#define FILTER_LINEAIRE_COEF 0.83

//ROUE
#define RAPPORT_OK 0.05
#define RAPPORT_SUPPLEMENTAIRE 0.08

//SERVO
#define NUMERO_TIMER_SERVO 3
#define FREQUENCE_SERVO 1e6

//STRATEGIE
#define INSTRUCTION_COLLISION 128
#define POS_DEPART_X 225
#define POS_DEPART_Y 200

#endif
