机器人灭火程序.pdf
int i=1,s=1;void main()while(1)SetMoto(1,60);SetMoto(3,60);wait(1);break;while(i=1)if(AI(2)300)turnright();else goline();if(AI(2)350&AI(1)450&AI(2)350&AI(1)250)i+;/第二次转弯。while(i=3)if(AI(2)540)Stop();wait(0.8);if(AI(9)90|AI(10)90|AI(11)350)Stop();wait(2);break;while(i=4)if(s=1)SetMoto(1,-70);SetMoto(3,70);wait(0.2);s+;SetMoto(1,-70);SetMoto(3,70);wait(0.001);if(AI(5)250&AI(0)250)i+;/出第一个房间。while(i=5)if(AI(0)400&(AI(2)250)turnright();else if(AI(0)620&s=2)SetMoto(1,60);SetMoto(3,50);wait(0.3);s+;goline();if(AI(6)545)Stop();wait(0.8);if(AI(9)90|AI(10)90|AI(11)330)Stop();wait(2);break;while(i=6)if(s=3)SetMoto(1,70);SetMoto(3,-70);wait(0.2);s+;SetMoto(1,70);SetMoto(3,-70);wait(0.001);if(AI(2)200&AI(3)200)i+;/出第二个房间。SetMoto(1,70);SetMoto(3,70);wait(0.3);while(i=7)if(AI(2)350&AI(5)250)i+;/第四次大转弯。Stop();wait(2);while(i=8)if(AI(2)350)turnright();else goline();if(AI(6)525)Stop();wait(0.8);if(AI(9)90|AI(10)90|AI(11)350)turnright();else goback();if(AI(5)350)i+;/出第三个房间。while(i=10)if(AI(2)350&AI(0)550)Stop();wait(0.8);fire();i+;else goline();void revise1()if(AI(0)650)SetMoto(1,60);SetMoto(3,45);wait(0.001);else SetMoto(1,45);SetMoto(3,60);wait(0.001);void revise()SetMoto(1,-40);SetMoto(3,-40);wait(0.6);if(AI(0)AI(2)SetMoto(1,50);SetMoto(3,10);wait(0.6);else SetMoto(1,10);SetMoto(3,50);wait(0.6);void fire()SetMoto(1,50);SetMoto(3,30);wait(0.4);Stop();while(1)if(AI(9)AI(11)SetMoto(1,50);SetMoto(3,10);wait(0.1);if(AI(6)520|AI(10)600)revise();if(AI(0)700|AI(2)700)revise1();void goback()SetMoto(1,-50);SetMoto(3,-50);wait(0.001);void turnright()SetMoto(1,70);SetMoto(3,0);wait(0.001);void turnleft()SetMoto(1,0);SetMoto(3,70);wait(0.001);2 0 10.0 5.16陈华成2 0 10.0 5.16陈华成