当前位置: 首页>>代码示例>>Python>>正文


Python msg.Joy方法代码示例

本文整理汇总了Python中sensor_msgs.msg.Joy方法的典型用法代码示例。如果您正苦于以下问题:Python msg.Joy方法的具体用法?Python msg.Joy怎么用?Python msg.Joy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sensor_msgs.msg的用法示例。


在下文中一共展示了msg.Joy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from sensor_msgs import msg [as 别名]
# 或者: from sensor_msgs.msg import Joy [as 别名]
def __init__(self):
        """
        Create HeadLiftJoy object.

        """
        # params
        self._head_axes = rospy.get_param('~head_axes', 3)
        self._lift_axes = rospy.get_param('~lift_axes', 3)
        self._head_button = rospy.get_param('~head_button', 4)
        self._lift_button = rospy.get_param('~lift_button', 5)

        # pubs
        self._head_pub = rospy.Publisher('head_angle', Float64, queue_size=1)
        self._lift_pub = rospy.Publisher('lift_height', Float64, queue_size=1)

        # subs
        self._joy_sub = rospy.Subscriber('joy', Joy, self._joy_cb, queue_size=1) 
开发者ID:OTL,项目名称:cozmo_driver,代码行数:19,代码来源:head_lift_joy.py

示例2: _joy_cb

# 需要导入模块: from sensor_msgs import msg [as 别名]
# 或者: from sensor_msgs.msg import Joy [as 别名]
def _joy_cb(self, msg):
        """
        The joy/game-pad message callback.

        :type   msg:    Joy
        :param  msg:    The incoming joy message.

        """
        if msg.buttons[self._head_button] == 1:
            angle_deg = ((msg.axes[self._head_axes] + 1.0) / 2.0) * SUM_HEAD_ANGLE + MIN_HEAD_ANGLE
            rospy.logdebug('Send head angle: {} degrees.'.format(angle_deg))
            self._head_pub.publish(data=angle_deg)

        if msg.buttons[self._lift_button] == 1:
            lift_mm = abs(msg.axes[self._lift_axes]) * SUM_LIFT_HEIGHT + MIN_LIFT_HEIGHT
            rospy.logdebug('Send lift height: {} mm.'.format(lift_mm))
            self._lift_pub.publish(data=abs(msg.axes[self._lift_axes])) 
开发者ID:OTL,项目名称:cozmo_driver,代码行数:19,代码来源:head_lift_joy.py

示例3: __init__

# 需要导入模块: from sensor_msgs import msg [as 别名]
# 或者: from sensor_msgs.msg import Joy [as 别名]
def __init__(self):
        rospy.loginfo("Tianbot Racecar JoyTeleop Initializing...")
        self._twist = Twist()
        self._twist.linear.x = 1500
        self._twist.angular.z = 90
        self._deadman_pressed = False
        self._zero_twist_published = False

        self._cmd_vel_pub = rospy.Publisher('~/car/cmd_vel', Twist, queue_size=5)
        self._joy_sub = rospy.Subscriber('/joy', Joy, self.joy_callback)
        self._timer = rospy.Timer(rospy.Duration(0.05), self.joystick_controller)
        self._axis_throttle = 1

        _joy_mode = rospy.get_param("~joy_mode", "D").lower()
        if _joy_mode == "d":
            self._axis_servo = 2
        if _joy_mode == "x":
            self._axis_servo = 3

        self._throttle_scale = rospy.get_param("~throttle_scale", 0.5)
        self._servo_scale = rospy.get_param("~servo_scale", 1) 
开发者ID:tianbot,项目名称:tianbot_racecar,代码行数:23,代码来源:racecar_joy.py

示例4: __init__

# 需要导入模块: from sensor_msgs import msg [as 别名]
# 或者: from sensor_msgs.msg import Joy [as 别名]
def __init__(self):
        self.evadeSet = False
        self.controller = XBox360()
        self.bridge = CvBridge()
        self.throttle = 0
        self.grid_img = None
        ##self.throttleLock = Lock()
        print "evasion"
        rospy.Subscriber("/lidargrid", Image, self.gridCB, queue_size=1)
        rospy.Subscriber("/cmd_vel", TwistStamped , self.twistCB , queue_size = 1)
        rospy.Subscriber("/joy", Joy, self.joyCB, queue_size=5)
        self.pub_img = rospy.Publisher("/steering_img", Image)
        self.pub_twist = rospy.Publisher("/lidar_twist", TwistStamped, queue_size=1)
        self.sound = rospy.Publisher("/sound_server/speech_synth", String, queue_size=1)        
        rospy.init_node ('lidar_cmd',anonymous=True)
        rospy.spin() 
开发者ID:DJTobias,项目名称:Cherry-Autonomous-Racecar,代码行数:18,代码来源:lidarEvasion.py

示例5: cmdRouter

# 需要导入模块: from sensor_msgs import msg [as 别名]
# 或者: from sensor_msgs.msg import Joy [as 别名]
def cmdRouter(self):     
        if self.joy_time+self.joy_timeout >= time.time():  ## If last joy message was recieved less than 2 seconds ago Joystick controlled      
            rospy.loginfo("Joy cmd")
            rospy.loginfo(self.joy_time+self.joy_timeout)
            rospy.loginfo(time.time())
            self.vel_pub.publish(self.joy_cmd) 
        elif self.lid_time+self.lid_timeout >= time.time(): ##else if last lidar twist was recieved less than 0.3 seconds ago lidar evasion controlled
            self.vel_pub.publish(self.lid_cmd)  
            rospy.loginfo("LIDAR cmd")
        elif self.cnn_time+self.cnn_timeout >= time.time(): ## else if last neural twist was recieved less than 0.1 seconds ago neural net controlled
            self.vel_pub.publish(self.cnn_cmd)
            rospy.loginfo("CNN cmd")
        else:                                               ##else if no command, neutral throttle and steering
            self.joy_cmd.twist.linear.x = 0.5
            self.joy_cmd.twist.angular.z = 0.5
            self.vel_pub.publish(self.joy_cmd)
            rospy.loginfo("Joy cmd else") 
开发者ID:DJTobias,项目名称:Cherry-Autonomous-Racecar,代码行数:19,代码来源:cmdControl.py

示例6: __init__

# 需要导入模块: from sensor_msgs import msg [as 别名]
# 或者: from sensor_msgs.msg import Joy [as 别名]
def __init__(self):
        print "dataRecorder"
        self.record = False
        self.twist = None
        self.twistLock = Lock()
        self.bridge = CvBridge()
        self.globaltime = None
        self.controller = XBox360()
        ##rospy.Subscriber("/camera/depth/points" , PointCloud2, self.ptcloudCB)
        rospy.Subscriber("/camera/depth/image_rect_raw_drop", Image, self.depthCB)
        rospy.Subscriber("/camera/rgb/image_rect_color_drop", Image, self.streamCB)
        #rospy.Subscriber("/camera/rgb/image_rect_mono_drop", Image, self.streamCB)  ##for black and white images see run.launch and look at the drop fps nodes near the bottom
        rospy.Subscriber("/lidargrid", Image, self.lidargridCB)
        rospy.Subscriber("/cmd_vel", TwistStamped, self.cmd_velCB)
        rospy.Subscriber("/joy", Joy ,self.joyCB)
        self.sound = rospy.Publisher("/sound_server/speech_synth", String, queue_size=1)
        rospy.init_node('dataRecorder',anonymous=True)
        rospy.spin() 
开发者ID:DJTobias,项目名称:Cherry-Autonomous-Racecar,代码行数:20,代码来源:dataRecorder.py

示例7: __init__

# 需要导入模块: from sensor_msgs import msg [as 别名]
# 或者: from sensor_msgs.msg import Joy [as 别名]
def __init__(self):
        rospy.loginfo("runner.__init__")
        # ----------------------------
        self.sess = tf.InteractiveSession()
        self.model = cnn_cccccfffff()
        saver = tf.train.Saver()
        saver.restore(self.sess, "/home/ubuntu/catkin_ws/src/car/scripts/model.ckpt")
        rospy.loginfo("runner.__init__: model restored")
        # ----------------------------
        self.bridge = CvBridge()
        self.netEnable = False
        self.controller = XBox360()
        rospy.Subscriber("/camera/rgb/image_rect_color", Image, self.runCB)
        rospy.Subscriber("/joy", Joy ,self.joyCB)
        self.pub_twist = rospy.Publisher("/neural_twist", TwistStamped, queue_size=1)
        self.sound = rospy.Publisher("/sound_server/speech_synth", String, queue_size=1)
        rospy.init_node('neural_cmd',anonymous=True)
        rospy.spin() 
开发者ID:DJTobias,项目名称:Cherry-Autonomous-Racecar,代码行数:20,代码来源:runModel.py

示例8: __init__

# 需要导入模块: from sensor_msgs import msg [as 别名]
# 或者: from sensor_msgs.msg import Joy [as 别名]
def __init__(self, args):
        if len(args)==1 or len(args)==2:
            self.max_speed = float(args[0])
            self.max_steering_angle = float(args[len(args)-1])
            cmd_topic = 'ackermann_cmd'
        elif len(args) == 3:
            self.max_speed = float(args[0])
            self.max_steering_angle = float(args[1])
            cmd_topic = '/' + args[2]
        else:
            self.max_speed = 0.2
            self.max_steering_angle = 0.7
            cmd_topic = 'ackermann_cmd'

        self.speed = 0
        self.steering_angle = 0
        self.joy_sub = rospy.Subscriber('/joy', Joy, self.joy_callback)
        self.drive_pub = rospy.Publisher(cmd_topic, AckermannDrive,
                                         queue_size=1)
        rospy.Timer(rospy.Duration(1.0/5.0), self.pub_callback, oneshot=False)
        rospy.loginfo('ackermann_drive_joyop_node initialized') 
开发者ID:gkouros,项目名称:ackermann-drive-teleop,代码行数:23,代码来源:joyop.py

示例9: __init__

# 需要导入模块: from sensor_msgs import msg [as 别名]
# 或者: from sensor_msgs.msg import Joy [as 别名]
def __init__(self, ID, use_joy, joystick_topic, flow_motion=True):
    
        Controller.__init__(self, ID)
        self.use_joy = use_joy

        if self.use_joy:
            self.joy_sub = rospy.Subscriber(joystick_topic, Joy, self.joy_cb)
        else:
            print("------ JOYSTICK NOT BEING USED BY CONTROLLER NODE ------")
        self.curr_joy = None

        self.cmd = -1 # -1 : NONE

        self.is_flow_motion = True#flow_motion

    #Override 
开发者ID:gkahn13,项目名称:GtS,代码行数:18,代码来源:JoyController.py

示例10: __init__

# 需要导入模块: from sensor_msgs import msg [as 别名]
# 或者: from sensor_msgs.msg import Joy [as 别名]
def __init__(self, fig, gs, rows, cols, actions_arr):
        """
        Constructs an ActionPanel assuming actions_arr is an array of
        fully initialized actions.
        Each action must have: key, name, func.
        Each action can have: axis_pos, keyboard_binding, ps3_binding.
        """
        assert len(actions_arr) <= rows*cols, 'Too many actions to put into gridspec.'

        self._fig = fig
        self._gs = gridspec.GridSpecFromSubplotSpec(rows, cols, subplot_spec=gs)
        self._axarr = [plt.subplot(self._gs[i]) for i in range(len(actions_arr))]
        
        # Read keyboard_bindings and ps3_bindings from config
        self._actions = {action.key: action for action in actions_arr}
        for key, action in self._actions.items():
            if key in config['keyboard_bindings']:
                action.kb = config['keyboard_bindings'][key]
            if key in config['ps3_bindings']:
                action.pb = config['ps3_bindings'][key]

        self._buttons = None
        self._initialize_buttons()
        self._cid = self._fig.canvas.mpl_connect('key_press_event', self.on_key_press)
        if ROS_ENABLED:
            self._ps3_count = 0
            rospy.Subscriber(config['ps3_topic'], Joy, self.ps3_callback) 
开发者ID:alexlee-gk,项目名称:visual_dynamics,代码行数:29,代码来源:action_panel.py

示例11: _on_joy

# 需要导入模块: from sensor_msgs import msg [as 别名]
# 或者: from sensor_msgs.msg import Joy [as 别名]
def _on_joy(self, msg):
        """ callback for messages from joystick input
        Args:
              msg(Joy): a joystick input message
        """
        raise NotImplementedError() 
开发者ID:RethinkRobotics,项目名称:intera_sdk,代码行数:8,代码来源:joystick.py

示例12: __init__

# 需要导入模块: from sensor_msgs import msg [as 别名]
# 或者: from sensor_msgs.msg import Joy [as 别名]
def __init__(self,options=None):     
        self.options = options
           
        self.joy_scale = [-1,1,-1,1,1] #RPYTY
        self.trim_roll = 0
        self.trim_pitch = 0
        self.max_angle = 30
        self.max_yawangle = 200
        
        
        self.max_thrust = 80.
        self.min_thrust = 25.
        self.max_thrust_raw = percentageToThrust(self.max_thrust)
        self.min_thrust_raw = percentageToThrust(self.min_thrust)       
        self.old_thurst_raw = 0
        
        self.slew_limit = 45
        self.slew_rate = 30
        self.slew_limit_raw = percentageToThrust(self.slew_limit)            
        self.slew_rate_raw = percentageToThrust(self.slew_rate)   
        
        self.dynserver = None
        self.prev_cmd = None
        self.curr_cmd = None
        self.yaw_joy = True
        
        self.sub_joy   = rospy.Subscriber("/joy", JoyMSG, self.new_joydata)
        self.sub_tf    = tf.TransformListener()         
        self.pub_tf    = tf.TransformBroadcaster()    
        self.pub_cfJoy = rospy.Publisher("/cfjoy", CFJoyMSG)
        
        # Dynserver               
        
        self.dynserver = DynamicReconfigureServer(CFJoyCFG, self.reconfigure) 
开发者ID:omwdunkley,项目名称:crazyflieROS,代码行数:36,代码来源:joy_driver.py

示例13: __init__

# 需要导入模块: from sensor_msgs import msg [as 别名]
# 或者: from sensor_msgs.msg import Joy [as 别名]
def __init__(self):
        self.throttleInitialized = False
        self.joy_timeout = 2.0
        self.lid_timeout = 0.30
        self.cnn_timeout = 0.1
        self.joy_time = time.time()
        self.lid_time = time.time()
        self.cnn_time = time.time()
        self.controller = XBox360()
        self.joy_cmd = TwistStamped()
        self.lid_cmd = TwistStamped()
        self.cnn_cmd = TwistStamped()
        self.cruiseControl = False
        self.cruiseThrottle = 0.5
        self.steeringAngle = 0.5
        self.throttle = 0.5
        self.trim = 0.0
        ##self.throttleLock = Lock()
        print "cmd_control"
       
        rospy.Subscriber("/imu", Imu, self.imuCB, queue_size=5)
        rospy.Subscriber("/lidar_twist", TwistStamped, self.lidarTwistCB, queue_size=5)
        rospy.Subscriber("/neural_twist", TwistStamped, self.neuralTwistCB, queue_size=5)
        rospy.Subscriber("/joy", Joy, self.joyCB, queue_size=5)
        self.vel_pub = rospy.Publisher("/cmd_vel", TwistStamped, queue_size = 1) 
        #self.state_pub = rospy.Publisher("/joint_states", JointState, queue_size=1)
        self.sound = rospy.Publisher("/sound_server/speech_synth", String, queue_size=1)        
        rospy.init_node ('cmd_control',anonymous=True)
        rate = rospy.Rate(66)
        while not rospy.is_shutdown():
            self.cmdRouter()
            rate.sleep() 
开发者ID:DJTobias,项目名称:Cherry-Autonomous-Racecar,代码行数:34,代码来源:cmdControl.py

示例14: joy_listener

# 需要导入模块: from sensor_msgs import msg [as 别名]
# 或者: from sensor_msgs.msg import Joy [as 别名]
def joy_listener():

    # start node
    rospy.init_node("turtlesim_joy", anonymous=True)

    # subscribe to joystick messages on topic "joy"
    rospy.Subscriber("joy", Joy, tj_callback, queue_size=1)

    # keep node alive until stopped
    rospy.spin()

# called when joy message is received 
开发者ID:PacktPublishing,项目名称:ROS-Robotics-By-Example,代码行数:14,代码来源:turtlesim_joy.py

示例15: __init__

# 需要导入模块: from sensor_msgs import msg [as 别名]
# 或者: from sensor_msgs.msg import Joy [as 别名]
def __init__(self):
        self.joy_enabled = False
        self.joint_mode = JointMode()

        joy_subscriber = rospy.Subscriber('joy', Joy, self.callback_joy)

        self.joystick_server = rospy.Service(
            '/niryo_one/joystick_interface/enable', SetInt, self.callback_enable_joystick)

        self.joystick_enabled_publisher = rospy.Publisher('/niryo_one/joystick_interface/is_enabled',
                                                          Bool, queue_size=1)

        rospy.Timer(rospy.Duration(2), self.publish_joystick_enabled) 
开发者ID:NiryoRobotics,项目名称:niryo_one_ros,代码行数:15,代码来源:joystick_interface.py


注:本文中的sensor_msgs.msg.Joy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。