马上注册 登录
中文乐高 返回首页

zhshshyang的个人空间 https://bbs.cmnxt.com/?61499 [收藏] [复制] [分享] [RSS]

日志

扫地机器人的循边

已有 804 次阅读2018-7-7 06:42

task main() { /* */ short touched_count = 0; const short wall_count = 4; const float speed = 100; /* four walls should be touched */ while(touched_count < wall_count){ // starts to go forward setMotorSpeed(leftMotor, speed); setMotorSpeed(rightMotor, speed); // loop untill touched a wall while(getBumperValue(bumpSwitch) == 1){ ++touched_count; // backward a little setMotorSpeed(leftMotor, -speed); setMotorSpeed(rightMotor, -speed); sleep(300); // turn left 90 degrees setMotorSpeed(leftMotor, -speed); setMotorSpeed(rightMotor, speed); sleep(470); // when the speed is 100, it is exact 90 degrees } } /* */ stopAllMotors(); }

路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 马上注册

手机版|中文乐高 ( 桂ICP备13001575号-7 )

GMT+8, 2026-4-5 14:43 , Processed in 0.260705 second(s), 18 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

返回顶部