if(notself._firstPointSeen):#If you were previously moving straight without obstacles
self._firstPointSeen=(x,y)
velocity=Twist()
ifxandy:
ify>=0:# Point is in the left part of the rectangle -> Turn right
ifxandy:# If there is a point in front at the moment
# 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)