Personal tools
Document Actions

Lego2C++ demo

by Naomi Fitter last modified 2011-10-28 15:01

Click here to get the file

Size 1 kB - File type text/plain

File contents

		switch (runstate)
		{//robot control
			case 0://forward
				igvc.usevis=false;
				if (clock()-starttime>5000 || bump(igvc.dist))
				{
					runstate=1;
					starttime=clock();
				}
				else
				{
					igvc.Xvel=igvc.LimVel;
					igvc.Zturn=0;
				}
				break;
			case 1://back up
				if (clock()-starttime>1000)
				{
					runstate=2;
					starttime=clock();
				}
				else
				{
					igvc.Xvel=-igvc.LimVel;
					igvc.Zturn=0;
				}
				break;
			case 2://turn
				if (clock()-starttime>1500)
				{
					runstate=0;
					starttime=clock();
				}
				else
				{
					igvc.Xvel=0;
					igvc.Zturn=igvc.LimTurn;
				}
				break;
			default:
				igvc.Xvel=0;
				igvc.Zturn=0;
				cub1.stop();
		}//end robot control
		igvc.DoSomeRoboting();