Manual

www.nexusrobot.com Robot Kits manual
67
The radius the car moves
float radian=0
The radian the car moves
unsigned int uptime=500
The time the car used to stop
Return: The time the car used to moves and stop
void demoActions(unsigned int speedMMPS=100,unsigned int duration=5000,unsigned int
uptime=500,bool debug=false)
A function for the car demo action
void R2WD::demoActions(unsigned int speedMMPS,unsigned int duration,unsigned int uptime,bool
debug) {
unsigned int (R2WD::*carAction[])(unsigned int speedMMPS)={
&R2WD::setCarAdvance, // set car to moves advance
&R2WD::setCarBackoff, //set car to moves back off
&R2WD::setCarRotateLeft, //set car to moves as rotate left
&R2WD::setCarRotateRight, ////set car to moves as rotate right
};
unsigned int (R2WD::*carAction2[])(unsigned int speedMMPS,unsigned int radiusMM)={
&R2WD::setCarUpperLeft, //set the car moves as upper left
&R2WD::setCarLowerLeft, //set the car moves as Lower left
&R2WD::setCarUpperRight, //set the car moves as upper right
&R2WD::setCarLowerRight, //set the car moves as lower right
};
for(int i=0;i<8;++i) { //the demo have 8 actions
if(i<4) { //the first four action
(this->*carAction[i])(0);
setCarSpeedMMPS(speedMMPS,uptime); // speedMMPS=100 set the car’s speed is
100
} else { //the last four action
(this->*carAction2[i-4])(0,500);