# Help ! Python Micro Project : I keep crashing into corner?

``````from robot_control_class import RobotControl
ro = RobotControl()
stop_flag =1
las = ro.get_laser_full()
las_max = max(las)
inde=las.index(las_max)
left = ro.get_laser(719)
right = ro.get_laser(0)
while(stop_flag):
if(not(ro.get_laser(360)<las_max+0.5 and ro.get_laser(360)>las_max-0.5)):
if(inde<360):
ro.turn ('clockwise', 0.2, 1)
else:
ro.turn ('counter-clockwise', 0.2, 1)
else:
ro.move_straight_time('forward', 0.5, 1)
las = ro.get_laser_full()
las_max = max(las)
inde=las.index(las_max)
print(las_max)
print(inde)
print(ro.get_laser(360))

left = ro.get_laser(719)
right = ro.get_laser(0)

if(left == float('inf') and right ==float('inf') and straight==float('inf')):
stop_flag =0
ro.stop_robot()
``````

I am basically finding the direction in which large free space that exists, then I am turning the robot to face that direction and move forward for few seconds. For some weird reason robot seems to think the direction of corner is free from obstacle?

Hi @vasank1958,

Did you mean that the robot is not turning when it gets to the corner?

If so, then you need to review your turning logic, ensuring that the laser reading at which you expect the robot to turn is workable. You could do this by checking the exact laser reading when the robot is crashing into the corner.

Thank You ,i have solved it . I forgot to add a repelling effect when closer to walls.

1 Like