乐高机器人java程序代码_用JAVA编写一个乐高机器人躲避障碍物运动到目标点的程序....
寫出一個可以控制機器人的小程序,使機器人從一邊到一個相對面,并至少跨越一個障礙物.規則如下: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.
展開
總結
以上是生活随笔為你收集整理的乐高机器人java程序代码_用JAVA编写一个乐高机器人躲避障碍物运动到目标点的程序....的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java分布式事务原理_JAVA分布式事
- 下一篇: java的classpath配置文件_J