I add my answer and also I would like to know how can improve my code, hoping to get some feedback from the community.

Also I would like to leave a question.
is there any code where for navigation use use some kind of control system like PID??

``````from robot_control_class import RobotControl

robotControl = RobotControl()

def move_robot():

right = robotControl.get_laser(10)
front = robotControl.get_laser(360)
left = robotControl.get_laser(709)

print ("distance from right {}", right)
print ("distance from front {}", front)
print ("distance from left {}", left)

diff_distance_right_left = right-left

if front == float("inf") and right == float("inf") and left == float("inf"):
robotControl.stop_robot()
print ("I'm free")
return False
elif front <= 1.2 and diff_distance_right_left >= 0.5:
robotControl.stop_robot()
print ("Roatating 45 degrees")
robotControl.rotate(45)
elif front <= 1.2 and diff_distance_right_left <= 0.5:
robotControl.stop_robot()
print ("Roatating -45 degrees")
robotControl.rotate(-45)
elif front > 1.2:
robotControl.move_straight()
elif diff_distance_right_left >= 0: # this is when it get stuck
robotControl.stop_robot()
print ("Roatating 15 degrees")
robotControl.rotate(15)
elif diff_distance_right_left <= 0: # this is when it get stuck
robotControl.stop_robot()
print ("Roatating -30 degrees")
robotControl.rotate(-30)

return True

while move_robot():
print("I just want to get out of here")

robotControl.stop_robot()
``````

Hi @smunoze ,

Welcome to our community.

With regards to PID (proportional–integral–derivative controller), in the ROS Perception in 5 Days course we talk about using the pid ROS package for following a line (if you consider that navigation).

Related to your script, could you be more specific on what problems you experienced with the code? What problems happen when you run it? Is it slow, or it does not work?

Regarding the PID is just the answer that I been looking for. I will definitely check the course in the future.

Related to the code, it works. (The simulation when you try to turn 90 degrees the robot doesn’t do it perfectly). Just want to know if maybe you consider any improvement. (always is good to receive a feedback).