User manual

RP6 ROBOT SYSTEM - 4. Programmierung des RP6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "RP6RobotBaseLib.h"
void acsStateChanged(void)
{
writeString_P("ACS status hat sich geändert! L: ");
if(obstacle_left) // Hindernis links
writeChar('o');
else
writeChar(' ');
writeString_P(" | R: ");
if(obstacle_right) // Hindernis rechts
writeChar('o');
else
writeChar(' ');
if(obstacle_left && obstacle_right) // Mitte?
writeString_P(" MITTE!");
writeChar('\n');
statusLEDs.LED6 = obstacle_left && obstacle_right; // Mitte?
statusLEDs.LED3 = statusLEDs.LED6;
statusLEDs.LED5 = obstacle_left; // Hindernis links
statusLEDs.LED4 = (!obstacle_left); // LED5 invertiert!
statusLEDs.LED2 = obstacle_right; // Hindernis rechts
statusLEDs.LED1 = (!obstacle_right); // LED2 invertiert!
updateStatusLEDs();
}
int main(void)
{
initRobotBase();
writeString_P("\nRP6 ACS - Testprogramm\n");
writeString_P("_____________________\n\n");
setLEDs(0b111111);
mSleep(1000);
setLEDs(0b001001);
// ACS Event Handler registrieren:
ACS_setStateChangedHandler(acsStateChanged);
powerON(); // ACS Empfänger einschalten (und Encoder etc.)
setACSPwrMed(); // ACS auf mittlere Sendeleistung stellen.
while(true)
{
task_ACS(); // ständig die task_ACS Funktion aufrufen!
}
return 0;
}
In diesem Beispiel sieht man auch nochmal sehr schön wie man die LEDs einzeln set-
zen kann.
Wenn man das Programm ausführt, sollte man den RP6 natürlich am Rechner ange-
- 95 -