本文整理汇总了Python中sensor_msgs.msg.Joy.buttons[7]方法的典型用法代码示例。如果您正苦于以下问题:Python Joy.buttons[7]方法的具体用法?Python Joy.buttons[7]怎么用?Python Joy.buttons[7]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sensor_msgs.msg.Joy
的用法示例。
在下文中一共展示了Joy.buttons[7]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: toPS3Msg
# 需要导入模块: from sensor_msgs.msg import Joy [as 别名]
# 或者: from sensor_msgs.msg.Joy import buttons[7] [as 别名]
def toPS3Msg(self):
joy = Joy()
joy.header = self.orig_msg.header
joy.buttons = [0] * 17
joy.axes = [0] * 20
if self.center:
joy.buttons[16] = 1
if self.select:
joy.buttons[0] = 1
if self.start:
joy.buttons[3] = 1
if self.L3:
joy.buttons[1] = 1
if self.R3:
joy.buttons[2] = 1
if self.square:
joy.axes[15] = -1.0
joy.buttons[15] = 1
if self.up:
joy.axes[4] = -1.0
joy.buttons[4] = 1
if self.down:
joy.axes[6] = -1.0
joy.buttons[6] = 1
if self.left:
joy.axes[7] = -1.0
joy.buttons[7] = 1
if self.right:
joy.axes[5] = -1.0
joy.buttons[5] = 1
if self.triangle:
joy.axes[12] = -1.0
joy.buttons[12] = 1
if self.cross:
joy.axes[14] = -1.0
joy.buttons[14] = 1
if self.circle:
joy.axes[13] = -1.0
joy.buttons[13] = 1
if self.L1:
joy.axes[10] = -1.0
joy.buttons[10] = 1
if self.R1:
joy.axes[11] = -1.0
joy.buttons[11] = 1
if self.L2:
joy.axes[8] = -1.0
joy.buttons[8] = 1
if self.R2:
joy.axes[9] = -1.0
joy.buttons[9] = 1
joy.axes[0] = self.left_analog_x
joy.axes[1] = self.left_analog_y
joy.axes[2] = self.right_analog_x
joy.axes[3] = self.right_analog_y
return joy
示例2: publish_joy
# 需要导入模块: from sensor_msgs.msg import Joy [as 别名]
# 或者: from sensor_msgs.msg.Joy import buttons[7] [as 别名]
def publish_joy(self):
'''
Publishes current stick/button state as a Joy object, to be handled by navigator_emergency.py node
'''
current_joy = Joy()
current_joy.axes.extend([0] * 4)
current_joy.buttons.extend([0] * 16)
for stick in self.sticks:
if self.sticks[stick] >= 0x8000: # Convert 2's complement hex to signed decimal if negative
self.sticks[stick] -= 0x10000
current_joy.axes[0] = np.float32(self.sticks['UD']) / 2048
current_joy.axes[1] = np.float32(self.sticks['LR']) / 2048
current_joy.axes[3] = np.float32(self.sticks['TQ']) / 2048
current_joy.buttons[7] = np.int32(self.buttons['START'])
current_joy.buttons[3] = np.int32(self.buttons['Y'])
current_joy.buttons[2] = np.int32(self.buttons['X'])
current_joy.buttons[0] = np.int32(self.buttons['A'])
current_joy.buttons[1] = np.int32(self.buttons['B'])
current_joy.buttons[11] = np.int32(self.buttons['DL']) # Dpad Left
current_joy.buttons[12] = np.int32(self.buttons['DR']) # Dpad Right
current_joy.header.frame_id = "/base_link"
current_joy.header.stamp = rospy.Time.now()
self.joy_pub.publish(current_joy)