if(notself._firstPointSeen):#If you were previously moving straight without obstacles
self._firstPointSeen=(x,y)
velocity=Twist()
velocity=Twist()
ifxandy:
ifxandy:# If there is a point in front at the moment
ify>=0:# Point is in the left part of the rectangle -> Turn right
# Linear movement
ifx<self.MIN_DIST_MOVE_FORWARD:
velocity.linear.x=0.0#If the wall is too close, don't go forward, only rotate
else:
coefficient=(x-self.MIN_DIST_MOVE_FORWARD)/(self.MAX_DIST_MOVE_FORWARD-self.MIN_DIST_MOVE_FORWARD)#linear between 0 (MIN_DIST_MOVE_FORWARD) and 1 (MAX_DIST_MOVE_FORWARD)