Submitted version of the thesis - Airlab, the Artificial Intelligence ...
Submitted version of the thesis - Airlab, the Artificial Intelligence ...
Submitted version of the thesis - Airlab, the Artificial Intelligence ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
100 Appendix B. Documentation <strong>of</strong> <strong>the</strong> programming<br />
u8 motor2_speed;<br />
u8 motor3_speed;<br />
/* Private function prototypes -----------------------------------------------*/<br />
void Init_Motors(void);<br />
void Calculate_Order(s16* speed, u8 size);<br />
void Position_Camera(u8 position);<br />
void Set_Directions(u8 Motor1, u8 Motor2, u8 Motor3);<br />
void Stop_Motor(u8 Motor);<br />
void Bumpers(u8 bumper[6]);<br />
void Set_Speed(s16* speed, u8 mod);<br />
void Stop_Servo(void);<br />
void Turn(u8 direction);<br />
/* Private functions ---------------------------------------------------------*/<br />
void Set_Speed(s16* speed, u8 mod) {<br />
u8 direction[NUM_MOTORS];<br />
u8 k;<br />
for (k = 0; k < NUM_MOTORS; k++) {<br />
direction[k] = (speed[k] > 0) ? 1 : 0, speed[k]<br />
=Abs(speed[k]);<br />
}<br />
for (k = 0; k < NUM_MOTORS; k++) {<br />
}<br />
if (speed[k] == 0) {<br />
Stop_Motor(k);<br />
}<br />
if (speed[k] > 2500)<br />
speed[k] = 2500;<br />
for (k = 0; k < NUM_MOTORS; k++) {<br />
if (speed[k] != 0)<br />
speed[k] = (speed[k] / 75 * mod) + 90;<br />
}<br />
Set_Directions(direction[0], direction[1], direction[2]);<br />
motor1_speed = (u8) speed[0];<br />
motor2_speed = (u8) speed[1];<br />
motor3_speed = (u8) speed[2];<br />
#ifdef NO_DEBUG<br />
Print_Int(motor1_speed,"m1 applied");<br />
Print_Int(motor2_speed,"m2 applied");<br />
Print_Int(motor3_speed,"m3 applied");