So I’m trying to use the class method to get the robot to move with using the laser but it isn’t working, I still don’t understand using classes fully but I did copy a bit from the previous exercise to help me. The error is
AttributeError: ‘MoveRobot’ object has no attribute ‘get_front_laser’
I have tried to use get_front_laser as well but get the same no attribute error, I have defined it under MoveRobot so shouldn’t it be there?
Here is my code, Any help would be great,
#!/usr/bin/env python
from robot_control_class import RobotControl
class MoveRobot:
def __init__(self, motion, clockwise, speed, time):
self.robotcontrol = RobotControl
self.motion = motion
self.clockwise = clockwise
self.speed = speed
self.time = time
self.time_turn = 7.0 # This is an estimate time in which the robot will rotate 90 degrees
def move_straight(self):
self.robotcontrol.move_straight_time(self.motion, self.speed, self.time)
def turn(self):
self.robotcontrol.turn(self.clockwise, self.speed, self.time_turn)
def laser_straight(self):
self.get_laser(360)
def all_laser(self):
self.get_laser_full()
def stop(self):
self.stop_robot()
def rotate(self):
self.rotate()
def first_run(self):
while self.laser_straight() > 1:
self.move_straight()
else:
self.stop()
r1 = MoveRobot('forward', 'clockwise', 1, 3)
r1.first_run()