Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Servo.cpp@18:daba0b3777c0, 2019-06-07 (annotated)
- Committer:
- SolalNathan
- Date:
- Fri Jun 07 01:11:01 2019 +0000
- Revision:
- 18:daba0b3777c0
formatage du code en differents modules
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SolalNathan | 18:daba0b3777c0 | 1 | #include "SaphTeamRacing.h" |
SolalNathan | 18:daba0b3777c0 | 2 | |
SolalNathan | 18:daba0b3777c0 | 3 | float angle_servo(float *direction) |
SolalNathan | 18:daba0b3777c0 | 4 | { |
SolalNathan | 18:daba0b3777c0 | 5 | // Calcul basé sur la régression expérimental pour obetenir l'angle |
SolalNathan | 18:daba0b3777c0 | 6 | // le pwm à donner au moteur en fonction de l'angle voulue |
SolalNathan | 18:daba0b3777c0 | 7 | |
SolalNathan | 18:daba0b3777c0 | 8 | float x, y; |
SolalNathan | 18:daba0b3777c0 | 9 | double angle, pwm; |
SolalNathan | 18:daba0b3777c0 | 10 | x = direction[0]; |
SolalNathan | 18:daba0b3777c0 | 11 | y = direction[1]; |
SolalNathan | 18:daba0b3777c0 | 12 | angle = atan2(y, x); // récupration de l'angle en radian |
SolalNathan | 18:daba0b3777c0 | 13 | angle = angle*180/3.14; // conversion en degrés |
SolalNathan | 18:daba0b3777c0 | 14 | pwm = -13.30*angle + 1376.75; // Formule issue de la régression linéaire |
SolalNathan | 18:daba0b3777c0 | 15 | |
SolalNathan | 18:daba0b3777c0 | 16 | return pwm; |
SolalNathan | 18:daba0b3777c0 | 17 | } |