예제 #1
0
 def __arm_notified (self):
     if self.arm_cyl.pos > .9:
         push_point = (vector (self.robot_position.pos)
                 + vector.polar (self.robot_position.angle - pi / 2, side + 100)
                 - vector.polar (self.robot_position.angle, 100))
         gift = self.table.nearest (push_point, level = 0, max = 150)
         if gift is not None and hasattr (gift, 'state'):
             gift.state = True
             gift.notify ()
     self.notify ()
예제 #2
0
 def inside (self, a):
     """If A is inside obstacle, return True."""
     # Map point in obstacle coordinates.
     u = vector.polar (self.angle, 1)
     o = vector (self.pos)
     a = vector (a)
     oa = a - o
     x = oa * u / (.5 * self.dim[0])
     y = oa * u.normal () / (.5 * self.dim[1])
     return x > -1 and x < 1 and y > -1 and y < 1
예제 #3
0
파일: clamps.py 프로젝트: TLoebner/apbteam
 def __door_notified (self):
     self.door = self.door_cylinder.pos # 1. is open.
     if self.door > 0.5 and self.load:
         for e in self.load:
             e.pos = (vector (self.robot_position.pos)
                     - vector.polar (self.robot_position.angle
                         + random.uniform (-pi/8, pi/8),
                         200 + random.uniform (0, 70)))
             e.notify ()
         self.load = [ ]
     self.notify ()
예제 #4
0
파일: cannon.py 프로젝트: TLoebner/apbteam
 def __pot_notified (self):
     self.firing = self.pot.wiper[0] > .5
     if self.cherries and self.firing:
         m = TransMatrix ()
         m.translate (self.robot_position.pos)
         m.rotate (self.robot_position.angle)
         hit = vector (*m.apply (self.cannon_hit))
         for c in self.cherries:
             c.pos = hit + vector.polar (random.uniform (-pi, pi),
                     random.uniform (0, 50))
             c.notify ()
         self.table.cherries.cherries.extend (self.cherries)
         self.table.cherries.notify ()
         self.cherries = [ ]
     self.notify ()
예제 #5
0
 def intersect (self, a, b):
     """If the segment [AB] intersects the obstacle, return distance from a
     to intersection point, else, return None."""
     if self.pos is None or self.angle is None:
         return None
     # Find intersection with each rectangle segments.  There is at most
     # two intersections, return the nearest.
     u = vector.polar (self.angle, self.dim[0] / 2.)
     v = vector.polar (self.angle + pi / 2, self.dim[1] / 2.)
     o = vector (self.pos)
     p1 = o + u + v
     p2 = o - u + v
     p3 = o - u - v
     p4 = o + u - v
     found = None
     for c, d in ((p1, p2), (p2, p3), (p3, p4), (p4, p1)):
         i = simu.utils.intersect.segment_segment (a, b, c, d)
         if i is not None:
             if found is not None:
                 found = min (found, i)
                 break
             else:
                 found = i
     return found