Différences entre les versions de « Code (CDR2020) »
Aller à la navigation
Aller à la recherche
| Ligne 1 : | Ligne 1 : | ||
= Fonction Main = | |||
#Initialisation | |||
##Drivers | |||
##Codeurs | |||
##Broches | |||
##Pavillons | |||
##Timers et tikers | |||
## Capteurs à ultrasons | |||
#Debug | |||
##PC et Blutooth | |||
#Choix de la statégie | |||
##Bleu ou jaune | |||
#Boucle infinie | |||
##Le match n'a pas encore commencé | |||
##Début du match | |||
#Compteur global | |||
= Fonction Asservissement = | |||
<code> | <code> | ||
Fonction Asservissement() | Fonction Asservissement() | ||
Version du 10 novembre 2020 à 15:56
Fonction Main
- Initialisation
- Drivers
- Codeurs
- Broches
- Pavillons
- Timers et tikers
- Capteurs à ultrasons
- Debug
- PC et Blutooth
- Choix de la statégie
- Bleu ou jaune
- Boucle infinie
- Le match n'a pas encore commencé
- Début du match
- Compteur global
Fonction Asservissement
Fonction Asservissement()
Appel fonction odométrie
distanceCible
Si y > yC
Alors signe = -1
Sinon signe = 1
Si (xC >= x)
consigneOrientation = signe * acos((abs(xC-x))/distanceCible);
Sinon
consigneOrientation = signe * (3.1415 - acos((abs(xC-x))/distanceCible));
Selon l'action
Cas 1 : Robot arrêté
Appel fonction moteur_éteint
Cas 2 : Rotation
Appel fonction moteur_activé
// Si on doit reculer
Si (objRecule[indiceStrategie]==1)
Alors consigneOrientation = consigneOrientation
+ 3.1415
Si(consigneOrientation>3.1415)
Alors consigneOrientation-=2*3.1415
Si consigneOrientation<-3.1415
Alors consigneOrientation+=2*3.1415
// Choix du sens de rotation
sens_orientation = 0
Si orientation < 0
Alors sens_orientation = orientation + 2.0f*3.1415f
Sinon
Alors sens_orientation = orientation
sens_consigne = 0
Si (orientation_consigne <0)
Alors sens_consigne = orientation_consigne + (2.0f*3.1415f)
Sinon
Alors sens_consigne = orientation_consigne
choix_sens = sens_consigne - sens_orientation