Unit 6: MicroProject - Odometry TurtleBot

So, I achieved to escape the maze just modifying a little bit the code…what I’ve done is looking/turning not at 90º but at 45º degrees, so at every curve needs to process twice to change it direction (45 + 45 degrees).

Anyway, I know that this is not the best solution, so if anyone has any idea of how to improve it please just comment. I will start now the course of “ROS basics in 5 days”, i guess it will help me to find a more coherent solution that takes in to account the odometry of the robot.

Also I do not understand why when i ask the robot to rotate 45º, it turns 315º instead, it’s a little bit silly problem but i don’t know either why it is doing that.

from robot_control_class import RobotControl
class GetOutofHere:
    def __init__(self): 
        self.rc = RobotControl()

    def go_ahead(self):          
        laserFront = self.rc.get_laser(360)
        while laserFront > 1:
                self.rc.move_straight()
                laserFront = self.rc.get_laser(360)
        self.rc.stop_robot()
        print ("Measured distance to wall:", laserFront)
       

    def have_a_look(self):
        laserLeft = self.rc.get_laser(180)
        print ("The distance measured in the left side is: ", laserLeft)
        laserRight = self.rc.get_laser(540)
        print ("The distance measured in the right side is: ", laserRight)

        if laserLeft > laserRight:
            print ("The chosen path is TURN RIGHT")
            self.rc.rotate(-45)           
        else:
            print ("The chosen path is TURN LEFT")
            self.rc.rotate(45)

counter = 0

while counter < 10:   

    step1 = GetOutofHere()
    step1.go_ahead()

    step2 = GetOutofHere()
    step2.have_a_look()

    counter += 1
1 Like