写出一个可以控制机器人的小程序,使机器人从一边到一个相对面,并至少跨越一个障碍物.规则如下:1,障碍物必须设置在机器人行走的路线上.2,空间的基本配置如插图3,不能用轨道之类的东西...

写出一个可以控制机器人的小程序,使机器人从一边到一个相对面,并至少跨越一个障碍物.

规则如下:

1,障碍物必须设置在机器人行走的路线上.

2,空间的基本配置如插图

3, 不能用轨道之类的东西引导机器人.

4,机器人可以触碰到障碍物.

程序需要包含下列的指令:

stop(); 停止 或等待下一个指令

This stops both motors, but then moves onto the next instruction if you want it stop and wait use halt().

forward(time1); 前进 (1/1000秒)

This moves the robot forward for time1 milliseconds

spinRight(time1); 向右旋转 (1/1000秒)

This moves the robot in a tight circle to the right using both motors time1 milliseconds (1/1000th of second)

turnRight(time1); 向右转 (1/1000秒)

This moves the robot in a looser circle than spinRight() to the right using both motors time1 milliseconds (1/1000th of second)

spinLeft(time1); 向左旋转(1/1000秒)

This moves the robot in a tight circle to the left using one motor for time1 milliseconds (1/1000th of second)

turnLeft(time1);向左转 (1/1000秒)

This moves the robot in a looser circle than spinLeft() to the left using one motor for time1 milliseconds (1/1000th of second)

backward(time1); 向后(1/1000秒)

This moves the robot backward time1 milliseconds (1/1000th of second)

bumpIt(int time1) 触碰传感器的端口为1和3:如果碰到任何一个的传感器是true ,则机器人返回

Using both touch sensors on ports 1 and 3 : If either touch sensor is true then move the robot backwards.

bumper(x) 触碰传感器的端口为X : 如果被接通返回为ture

Using a touch sensor on port x: Returns true if contact is made.

checkBumpers() 触碰传感器的端口为1和3: 如果任意一个接通则为true并返回,否则为false.

Using both touch sensors on ports 1 and 3 : If either touch sensor makes contact then true is returned else false is.

checkLight(x) 触碰传感器的端口为X:如果感应器在一般标准以上则为true并返回

Uses a light sensor on port x: Returns true if the sensor is above the line

halt() 机器人停止运行直到按下 view按钮

Stops the robot until the view button is pressed

change_direction(A,B,C)A,设置为持续,B电源接通左发动机,C电源接通右发动机

A sets the duration, B power to left motor and C power to the right motor

checkLight_x(X)

which produces true value for light levels measured to be between 33 and 42 by the light sensor on port X.

measureLight(X)

Returns the light level as an integer for a particular sensor port X.

展开

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐