Need help with the project: ‘MoveRobot’ object has no attribute ‘get_front_laser’

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):

    def all_laser(self):

    def stop(self):

    def rotate(self):
    def first_run(self):
        while self.laser_straight() > 1:

r1 = MoveRobot('forward', 'clockwise', 1, 3)

Hi, I don’t see anything refering to get_front_laser in the code you shared. If you want to import a method from a class, then you have to have it listed in the class.

If you are going to use classes, then I recommend taking the ROS Basics Python course, there is a unit dedicated to them. You don’t need to have the rest completed to take a look at it.

Hi @smtafe ,

I see that you are not instantiating an object of the RobotControl class

I recommend you to do:

self.robotcontrol = RobotControl()

instead of the current:

self.robotcontrol = RobotControl

This way you shouldn’t have any errors trying to access methods if they exist.

1 Like

Thanks i missed that

1 Like

I can do this without using classes, just thought i would try to use them. Ill just learn them again down the line