示例#1
0
 def __init__(self, target_sim=False):
     if target_sim:
         topic = '/turtle1/cmd_vel'
     else:
         topic = '/cmd_vel_mux/input/teleop'
     super(DirectionController, self).__init__(topic, Twist, 1 / 10.0)
     self.key_listener = DirectionalKeyListener(
         callback=self.on_key_pressed,
         direction_mappings=DirectionController.KEY_BINDINGS)
示例#2
0
 def __init__(self, target_sim=False):
     if target_sim: 
         topic = '/turtle1/cmd_vel' 
     else:
         topic = '/cmd_vel_mux/input/teleop'
     super(DirectionController, self).__init__(topic, Twist, 1/10.0)
     self.key_listener = DirectionalKeyListener(callback=self.on_key_pressed, 
                                                direction_mappings=DirectionController.KEY_BINDINGS)
示例#3
0
class DirectionController(ThreadedPublisher):

    LINEAR_SPD = 0.15
    ANGULAR_SPD = 0.5

    KEY_BINDINGS = {
        ord('a'): Twist(Vector3(LINEAR_SPD,0,0), 
                        Vector3(0,0,ANGULAR_SPD)),
        ord('z'): Twist(Vector3(LINEAR_SPD,0,0), 
                        Vector3(0,0,0)),
        ord('e'): Twist(Vector3(LINEAR_SPD,0,0), 
                        Vector3(0,0,-ANGULAR_SPD)),
        ord('q'): Twist(Vector3(0,0,0), 
                        Vector3(0,0,ANGULAR_SPD)),
        ord('s'): Twist(Vector3(-LINEAR_SPD,0,0),
                        Vector3(0,0,0)),
        ord('d'): Twist(Vector3(0,0,0), 
                        Vector3(0,0,-ANGULAR_SPD)),
        ord('w'): Twist(Vector3(-LINEAR_SPD,0,0),
                        Vector3(0,0,-ANGULAR_SPD)),
        ord('x'): Twist(Vector3(-LINEAR_SPD,0,0),
                        Vector3(0,0,ANGULAR_SPD)),
        ord(' '): Twist(Vector3(0,0,0), 
                        Vector3(0,0,0))
    }

    def __init__(self, target_sim=False):
        if target_sim: 
            topic = '/turtle1/cmd_vel' 
        else:
            topic = '/cmd_vel_mux/input/teleop'
        super(DirectionController, self).__init__(topic, Twist, 1/10.0)
        self.key_listener = DirectionalKeyListener(callback=self.on_key_pressed, 
                                                   direction_mappings=DirectionController.KEY_BINDINGS)

    def loop(self):
        ''' Replace this thread's loop with the listener's activation '''
        self.key_listener.activate()

    def on_key_pressed(self, direction, key, listener):
        ''' Listener style, to be used with DirectionalKeyListener '''
        self.publish(direction)
示例#4
0
class DirectionController(ThreadedPublisher):

    LINEAR_SPD = 0.15
    ANGULAR_SPD = 0.5

    KEY_BINDINGS = {
        ord('a'): Twist(Vector3(LINEAR_SPD, 0, 0), Vector3(0, 0, ANGULAR_SPD)),
        ord('z'): Twist(Vector3(LINEAR_SPD, 0, 0), Vector3(0, 0, 0)),
        ord('e'): Twist(Vector3(LINEAR_SPD, 0, 0), Vector3(0, 0,
                                                           -ANGULAR_SPD)),
        ord('q'): Twist(Vector3(0, 0, 0), Vector3(0, 0, ANGULAR_SPD)),
        ord('s'): Twist(Vector3(-LINEAR_SPD, 0, 0), Vector3(0, 0, 0)),
        ord('d'): Twist(Vector3(0, 0, 0), Vector3(0, 0, -ANGULAR_SPD)),
        ord('w'): Twist(Vector3(-LINEAR_SPD, 0, 0),
                        Vector3(0, 0, -ANGULAR_SPD)),
        ord('x'): Twist(Vector3(-LINEAR_SPD, 0, 0), Vector3(0, 0,
                                                            ANGULAR_SPD)),
        ord(' '): Twist(Vector3(0, 0, 0), Vector3(0, 0, 0))
    }

    def __init__(self, target_sim=False):
        if target_sim:
            topic = '/turtle1/cmd_vel'
        else:
            topic = '/cmd_vel_mux/input/teleop'
        super(DirectionController, self).__init__(topic, Twist, 1 / 10.0)
        self.key_listener = DirectionalKeyListener(
            callback=self.on_key_pressed,
            direction_mappings=DirectionController.KEY_BINDINGS)

    def loop(self):
        ''' Replace this thread's loop with the listener's activation '''
        self.key_listener.activate()

    def on_key_pressed(self, direction, key, listener):
        ''' Listener style, to be used with DirectionalKeyListener '''
        self.publish(direction)