Ejemplo n.º 1
0
    def should_leave_wall(self):  #fn to leave the wall
        (x, y, _
         ) = current_location.current_location()  #copying the current location
        if None in self.encountered_wall_at:  #checking if the robot has encountered the wall previously
            self.encountered_wall_at = (
                x, y)  #saving the current encountred wall location
            self.lh = necessary_heading(
                x, y, self.tx1,
                self.ty1)  #calculating the angle towards destination
            return False
        t_angle = necessary_heading(
            x, y, self.tx1,
            self.ty1)  #calculating the angle towards the destination
        (
            ox, oy
        ) = self.encountered_wall_at  #copying the ecountered wall location data
        od = math.sqrt(
            (ox - self.tx1)**2 + (oy - self.ty1)**
            2)  #calculating distance b/w the goal and wall encounter position
        cd = math.sqrt(
            (x - self.tx1)**2 + (y - self.ty1)**
            2)  #calculating distance b/w the goal and current position
        dt = 0.01  #angle tolerance in the direction towards goal

        if self.lh - dt <= t_angle <= self.lh + dt and not near(
                x, y, ox, oy):  #condition to leave the wall
            if cd < od:
                print "Leaving wall"
                return True
        return False
Ejemplo n.º 2
0
Archivo: bug.py Proyecto: agn-7/bugs
    def should_leave_wall(self):
        (x, y, _) = current_location.current_location()

        if None in self.encountered_wall_at:
            self.encountered_wall_at = (x, y)
            self.lh = necessary_heading(x, y, self.tx, self.ty)
            '''get degree once'''
            return False

        t_angle = necessary_heading(x, y, self.tx, self.ty)
        '''get degree while the robot is following the wall '''

        (ox, oy) = self.encountered_wall_at
        od = math.sqrt((ox - self.tx)**2 + (oy - self.ty)**2)
        '''origin to goal distance'''

        cd = math.sqrt((x - self.tx)**2 + (y - self.ty)**2)
        '''current to goal distance'''

        dt = 0.01

        if self.lh - dt <= t_angle <= self.lh + dt and not near(x, y, ox, oy):
            '''Makes robot placed on origin to goal planned (Bug2 algorithm)'''
            if cd < od:
                print "Leaving wall"
                self.encountered_wall_at = (None, None)
                '''Init for another obstacle'''
                return True
        return False
Ejemplo n.º 3
0
 def should_leave_wall(self):
     (x, y, t) = current_location.current_location()
     dir_to_go = current_location.global_to_local(
         necessary_heading(x, y, *self.goal))
     at = current_dists.at(dir_to_go)
     (_, left) = current_dists.get()
     return at > 10
Ejemplo n.º 4
0
 def should_leave_wall(self):
     (x, y, t) = current_location.current_location()
     g = current_location.global_to_local(
         necessary_heading(x, y, *self.goal))
     at = current_dists.at(g)
     (_, left) = current_dists.get()
     return at > 10  # and left > WALL_PADDING
Ejemplo n.º 5
0
Archivo: bug.py Proyecto: agn-7/bugs
    def should_leave_wall(self):
        print('Im in should_leave_wall of bug0')
        (x, y, t) = current_location.current_location()
        dir_to_go = current_location.global_to_local(
            necessary_heading(x, y, tx, ty))
        '''Direction to goal'''

        print('current_angle:', current_location.current_location()[2])
        print('desired_angle_without_global_to_local:',
              necessary_heading(x, y, tx, ty))
        print('desired_angle:', dir_to_go)
        at = current_dists.at(dir_to_go)
        if at > 10:
            print('flag', self.flag)
            print("Leaving wall in at")
            return True
        return False
Ejemplo n.º 6
0
    def should_leave_wall(self):
        (x, y, _) = current_location.current_location()
        if None in self.encountered_wall_at:
            self.encountered_wall_at = (x, y)
            self.lh = necessary_heading(x, y, self.tx3, self.ty3)
            return False
        t_angle = necessary_heading(x, y, self.tx3, self.ty3)
        (ox, oy) = self.encountered_wall_at
        od = math.sqrt((ox - self.tx3)**2 + (oy - self.ty3)**2)
        cd = math.sqrt((x - self.tx3)**2 + (y - self.ty3)**2)
        dt = 0.01

        if self.lh - dt <= t_angle <= self.lh + dt and not near(x, y, ox, oy):
            if cd < od:
                print "Leaving wall"
                return True
        return False
Ejemplo n.º 7
0
 def should_leave_wall(self):
     (x, y, t) = current_location.current_location()
     dir_to_go = current_location.global_to_local(
         necessary_heading(x, y, tx, ty))
     at = current_dists.at(dir_to_go)
     if at > 10:
         print "Leaving wall"
         return True
     return False
Ejemplo n.º 8
0
    def should_leave_wall(
            self):  #Follows the goal when a leave point is encountered
        (x, y, _) = current_location.current_location()
        if None in self.encountered_wall_at:
            self.encountered_wall_at = (
                x, y
            )  #store current location parameter when robot meets obstacle
            self.lh = necessary_heading(x, y, self.tx, self.ty)
            return False
        t_angle = necessary_heading(x, y, self.tx, self.ty)
        (ox, oy) = self.encountered_wall_at
        od = math.sqrt((ox - self.tx)**2 + (oy - self.ty)**2)
        cd = math.sqrt((x - self.tx)**2 + (y - self.ty)**2)
        dt = 0.01

        if self.lh - dt <= t_angle <= self.lh + dt and not near(x, y, ox, oy):
            if cd < od:
                print "Leaving wall"
                return True
        return False
Ejemplo n.º 9
0
 def should_leave_wall(self):
     (x, y, t) = current_location.current_location()
     dir_to_go = current_location.global_to_local(necessary_heading(x, y,*self.goal))
     at = current_dists.at(dir_to_go)
     (_, left) = current_dists.get()
     return at > 10