我检查了第一和第二作品很棒第三,我得到错误的
robotcontrol.turn_right(90)
AttributeError: RobotControl实例没有属性'turn_right'
My Code:
from robot_control_class import RobotControl
robotcontrol = RobotControl()
# First, it starts moving the robot forwards while it captures the laser readings in front of the robot.
a = robotcontrol.get_laser(360)
# Then, it checks if the distance to the wall is less than 1 meter. If it is, it stops the robot.
while a > 1:
robotcontrol.move_straight()
a = robotcontrol.get_laser(360)
print ("Current distance to wall: %f" % a)
robotcontrol.stop_robot()
# third, it turns the robot 90 degrees to the right and starts moving it forwards again.
robotcontrol.turn_right(90)
robotcontrol.move_straight()
我假设您正在使用arnaldojr/Python-3-for-Robotics。查看源代码,您可以看到没有称为turn_right
的方法。你需要用turn(self, clockwise, speed, time)
代替。
比如
robotcontrol.turn("clockwise", 90, 1, 1)
应该能解决你的问题。