EasyManua.ls Logo

Dobot AiStarter - 6.3 White Balance Calibration Demo; 6.3.1 Description; 6.3.2 Procedure; 6.3.3 Code Description

Dobot AiStarter
41 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
AiStarter User Guide 6AI-Starter Demo
IssueV1.0.32018-09-01 AiStarter User Guide Copyright © Yuejiang Technology Co., Ltd
20
//calculate the car position offset
for (int i = 0; i < IR_NUM; i++) {
if (irstate & (1 << i)) {
total += irPos[i];
irOffCnt++;
}
}
if (irOffCnt) {
readPos = total / irOffCnt;
}
else {
readPos = lastPos;
}
//calculate the current position
curPos = (1 - coeff) * lastPos + coeff * readPos;
lastPos = curPos;
return curPos;
}
3) Set AI-Starter speed.
Program 6.3 Set AI-Starter speed
void setCarSpeed(const float curPos)
{
const int baseSpeed = 50; //rpm
const float kp = 1;
const float ki = 0.06;
const float kd = 0.0;
const float errorsumLimit = 50;
float error = curPos;
static float lastError;
static float errorsum;
float errorChange;
int speedLeftWheel;
int speedRightWheel;

Table of Contents

Related product manuals