AiStarter User Guide 6AI-Starter Demo
IssueV1.0.3(2018-09-01) AiStarter User Guide Copyright © Yuejiang Technology Co., Ltd
19
6. AI-Starter Demo
6.1 Line Tracking Demo
6.1.1 Description
This demo realizes that AI-Starter tracks line automatically on testing map.
6.1.2 Procedure
Step 1 Turn on AI-Starter.
Step 2 Press down the key start|stop, AI-Starter starts tracking line after buzzer beeps one
time.
Step 3 Press down the key start|stop once agian, AI-Starter stops tracking line after the
buzzer beeps one time.
6.1.3 Code Description
1) Get the current infrared sensor value.
Program 6.1 Get infrared sensor value
void getCurrentIRState(int *irstate)
{
*irstate = 0;
for (int i = 0; i < IR_NUM; i++) {
*irstate |= AIStarter_SmartBotGetIRModuleValue(i) << i;
}
}
2) Get AI-Starter pose.
Program 6.2 Get AI-Starter pose
float getCurrentPos(const int irstate)
{
const float coeff = 0.7;
const int irPos[] = {-30, -18, -6, 6, 18, 30};
static float lastPos;
float curPos;
float readPos;
int total = 0;
int irOffCnt = 0;