Différences entre les versions de « Code (CDR2020) »
Aller à la navigation
Aller à la recherche
(Page créée avec « Go ») |
|||
| Ligne 1 : | Ligne 1 : | ||
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 | |||
Version du 10 novembre 2020 à 13:51
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