Exemplo n.º 1
0
  def draw_robot(self, draw_path=True, text_info=''):
    """Create a new frame and draw a representation of the robot in it"""
    x,y,phi = self.state.get_pose()
    if self.viewer:
      f = Frame.Frame()

      if draw_path:
        f.add_lines(color='black',
                    alpha=0.5,
                    lines=[self.path[:]],
                    linewidth=0.02)
      
      # Draw start and goal
      f.add_circle(self.init,
                   color='green',
                   alpha=0.5,
                   radius=0.05)
      for g in self.goals:
        f.add_circle(g,
                     color='blue',
                     alpha=0.5,
                     radius=0.05)

      # Our robot representation is built of an arrow head
      # with two wheels.
      poly = Shapes.arrow_head_polygon((x, y),
                                       phi,
                                       scale=0.02)
      f.add_polygons([poly],
                     color="red",
                     alpha=0.5)
      wheels = Shapes.rectangle_pair((x,y),
                                     5.,2.,7.,
                                     angle=phi,
                                     scale=0.02)
      f.add_polygons(wheels,
                     color="black",
                     alpha=0.5)

      # Add some anotation
      f.add_text(pos=(-0.5,-0.5), size=0.1, text="Time=%.2fs"%self.time,color="darkgreen")
      dy = -0.6
      for i,s in enumerate(text_info.split('\n')):
        f.add_text(pos=(-0.5,dy-0.1*i), size=0.07,
                   text=s,color="darkgreen")

      self.viewer.add_frame(f)
      time.sleep(0.01)
Exemplo n.º 2
0
  def draw_robot(self, draw_path=True, text_info=''):
    """Create a new frame and draw a representation of the robot in it"""
    x,y,phi = self.state.get_pose()
    phi_d = self.get_dir_to_goal()
    if self.viewer:
      f = Frame.Frame()
      if draw_path:
        f.add_lines(color=Color.Color("black"),
                    lines=[self.path[:]],
                    linewidth=0.01)
      
      # Draw start and goal
      for p,color in ( (self.init, "green"),
                       (self.goal, "blue") ):
        if p:
          f.add_circle(p,
                       color=color,
                       alpha=0.5,
                       radius=0.05)

      # Our robot representation is built of an arrow head
      # with two wheels.
      poly = Shapes.arrow_head_polygon((x, y),
                                       phi,
                                       scale=0.02)
      f.add_polygons([poly],
                     color="red",
                     alpha=0.5)
      wheels = Shapes.rectangle_pair((x,y),
                                     5.,2.,7.,
                                     angle=phi,
                                     scale=0.02)
      f.add_polygons(wheels,
                     color="black",
                     alpha=0.5)

      # Add some anotation
      f.add_text(pos=(-0.5,-0.5), size=0.1, text="Time=%.2fs"%self.time,color="darkgreen")
      dy = -0.6
      for i,s in enumerate(text_info.split('\n')):
        f.add_text(pos=(-0.5,dy-0.1*i), size=0.07,
                   text=s,color="darkgreen")

      self.viewer.add_frame(f)
      time.sleep(0.01)
Exemplo n.º 3
0
  def draw_robot(self, draw_path=True):
    """Create a new frame and draw a representation of the robot in it"""
    if self.viewer:
      f = Frame.Frame()
      if draw_path:
        f.add_lines(color=Color.Color("black"),
                    lines=[self.path[:]],
                    linewidth=0.01)
      
      # Draw start and goal
      for p,color in ( (self.init, "green"),
                       (self.goal, "blue") ):
        if p:
          f.add_circle(p,
                       color=color,
                       alpha=0.5,
                       radius=0.05)

      # Our robot representation is built of an arrow head
      # with two wheels.
      poly = Shapes.arrow_head_polygon((self.x, self.y),
                                       self.phi,
                                       scale=0.02)
      f.add_polygons([poly],
                     color=Color.Color("red"),
                     alpha=0.5)
      wheels = Shapes.rectangle_pair((self.x,self.y),
                                     5.,2.,7.,
                                     angle=self.phi,
                                     scale=0.02)
      f.add_polygons(wheels,
                     color=Color.Color("black"),
                     alpha=0.5)

      # Add some anotation
      f.add_text(pos=(-0.5,-0.5),
                 size=0.1,
                 text="Time=%.2fs"%(self.time),
                 color=Color.Color("darkgreen"))

      self.viewer.add_frame(f)
      time.sleep(0.01)
Exemplo n.º 4
0
    def draw_robot(self, draw_path=True):
        """Create a new frame and draw a representation of the robot in it"""
        if self.viewer:
            f = Frame.Frame()
            if draw_path:
                f.add_lines(color=Color.Color("black"),
                            lines=[self.path[:]],
                            linewidth=0.01)

            # Draw start and goal
            for p, color in ((self.init, "green"), (self.goal, "blue")):
                if p:
                    f.add_circle(p, color=color, alpha=0.5, radius=0.05)

            # Our robot representation is built of an arrow head
            # with two wheels.
            poly = Shapes.arrow_head_polygon((self.x, self.y),
                                             self.phi,
                                             scale=0.02)
            f.add_polygons([poly], color=Color.Color("red"), alpha=0.5)
            wheels = Shapes.rectangle_pair((self.x, self.y),
                                           5.,
                                           2.,
                                           7.,
                                           angle=self.phi,
                                           scale=0.02)
            f.add_polygons(wheels, color=Color.Color("black"), alpha=0.5)

            # Add some anotation
            f.add_text(pos=(-0.5, -0.5),
                       size=0.1,
                       text="Time=%.2fs" % (self.time),
                       color=Color.Color("darkgreen"))

            self.viewer.add_frame(f)
            time.sleep(0.01)
Exemplo n.º 5
0
                   polygons = [[(x,100),
                                (x+10,100),
                                (x+5,110)],
                               [(x+30,100),
                                (x+40,100),
                                (x+35,110)],
                               ])
    arw = Shapes.arrow_head_polygon((x,-25),
                                    scale=10)
    rect = Shapes.rotated_rectangle((x,-150),
                                    width=50,
                                    height=10,
                                    angle=-1.0*i/N * math.pi*2,
                                    )
    wheels = Shapes.rectangle_pair((x,-25),
                                   5.,2.,7.,
                                   left_angle = 1.0*i/N * math.pi*2,
                                   scale=10)
    f.add_polygons(polygons = [arw,
                               rect],
                   color="cyan",
                   alpha=0.5)
    f.add_polygons(polygons = wheels,
                   color="black",
                   alpha=0.7)

    f.add_text(pos=(250,200),
               face="Serif 18",
               markup=("<big>Frame %d</big>\n"%i
                       + "A <b>bold</b> line\n"
                         "Greek: &#945;\n"
                         "<span fgcolor=\"red\">R</span>"