可以沿北/南或東/西軸移動,因為旋轉限制為90度。在
您可以觀察到,任何移動都將具有北/南分量和東/西分量。在
如果你的動作一致,那么你離下一步只有90度的距離:1. turn east or west
橫坐標和縱坐標的位置關系。2. move east or west
3. turn north or south
4. move north or south
5. You should be at your target
坐標先讀橫坐標還是縱坐標?6. turn east or west
7. move east or west
8. turn north or south
9. move north or south
橫坐標和縱坐標怎么表示?10. you should be at your (next) target
。。。等等
如果我們假設你的機器人開始朝北,那么你的回路應該先轉向東/西,然后移動,然后轉向北/南。在
開始吧。這可能是您的全局數據和主代碼。在
橫坐標是哪個?^{pr2}$
如果我們假設x是東/西,y是北/南,那么對于move_robot,你可以得到這樣的結果:def move_robot(new_pos):
"""
Move robot from ``Robot_pos`` to ``new_pos`` given. The robot
python怎么用、is assumed to be facing either north or south upon entry, so
east/west movement is done first.
"""
delta_x = ...
python升級pip命令、turn_robot(EAST or WEST)
forward( some amount )
# similarly for Y
你必須在你的turn_robot()代碼中稍微聰明一點,以優化你開始時是朝著積極還是消極的方向轉彎。不過,它應該總是一個90度的旋轉。在
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态