Turtlebot does as the task requires, but I am not given the mark (ROS Prerequisite exam)

I am not awarded the mark for main method even though my turtlebot does exactly as is told and stops at the opening

This is my code and where the turtlebot stops when the code runs. Also, why am i not getting the mark for get_laser_readings? 719 corresponds with the left and 0 corresponds with the right.

If these are spoilers for the exam, please feel free to delete. Thanks!

Hello @izzatfadzlon ,

Could you please send me your exam files to aezquerro@theconstructsim.com so that I can check them personally?

Thanks,

hi @albertoezquerro , i’ve sent the files to your email. Thanks!

Hello @izzatfadzlon ,

The problem is with your ExamControl class code. You are declaring a global variable outside the class:

rc = RobotControl()

Therefore, when your class is imported from another script (the correction script in this case), it won’t work properly because it won’t be able to find this rc variable.

So, you need to declare everything inside the class like this:

class ExamControl:
    def __init__(self):
        self.rc = RobotControl()
        self.left = self.rc.get_laser(719)
        self.right = self.rc.get_laser(0)

Best,

2 Likes