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


Python Joy.buttons[3]方法代码示例

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


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

示例1: toPS3Msg

# 需要导入模块: from sensor_msgs.msg import Joy [as 别名]
# 或者: from sensor_msgs.msg.Joy import buttons[3] [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
开发者ID:YuOhara,项目名称:jsk_control,代码行数:58,代码来源:joy_status.py

示例2: ready

# 需要导入模块: from sensor_msgs.msg import Joy [as 别名]
# 或者: from sensor_msgs.msg.Joy import buttons[3] [as 别名]
def ready(pub):
	msg = Joy()
	msg.header.stamp = rospy.Time.now()
	valueAxe = 0.0
	valueButton = 0
	standup_time = 20 #2 seconds
	for i in range (0, 20):
		msg.axes.append(valueAxe)
	for e in range (0, 17):
		msg.buttons.append(valueButton)
	rate = rospy.Rate(10)
	time.sleep(1)

	msg.buttons[3] = 1
	i=0
	bo=True
	print "STAND_UP"
	while not rospy.is_shutdown() and bo:
		i=i+1
		if (i>standup_time):
			bo=False
			msg.buttons[3] = 0
		pub.publish(msg)
		rate.sleep()
开发者ID:IkerZamora,项目名称:ros_erle_spider_voice_control,代码行数:26,代码来源:voice_control.py

示例3: publish_joy

# 需要导入模块: from sensor_msgs.msg import Joy [as 别名]
# 或者: from sensor_msgs.msg.Joy import buttons[3] [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)
开发者ID:ironmig,项目名称:Navigator,代码行数:25,代码来源:kill_board_driver.py

示例4: Joy

# 需要导入模块: from sensor_msgs.msg import Joy [as 别名]
# 或者: from sensor_msgs.msg.Joy import buttons[3] [as 别名]
## INITIALIZE ##
################ 
pub = rospy.Publisher('/joy', Joy, queue_size=10)
msg = Joy()
msg.header.stamp = rospy.Time.now()
rate = rospy.Rate(10)
   
valueAxe = 0.0
valueButton = 0
for i in range (0, 20):
 msg.axes.append(valueAxe)
for e in range (0, 17):
 msg.buttons.append(valueButton)


####################
## STAND UP    ##
####################
msg.buttons[3] = 1
i=0
bo=True
standup_time=standup_time/3
while not rospy.is_shutdown() and bo:
 i=i+1
 if (i>standup_time):
   bo=False
   msg.buttons[3] = 0
 pub.publish(msg)
 rate.sleep()
time.sleep(2)
开发者ID:BrzTit,项目名称:blockly,代码行数:32,代码来源:standup_down.py

示例5: talker

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

##PARAMS:
  standup_time=20
  walking_time=120
  turning_time=125

 
  rospy.init_node("joy_simulate", anonymous=True)
  pub = rospy.Publisher("/joy", Joy, queue_size=10)
  msg = Joy()
  msg.header.stamp = rospy.Time.now()
  rate = rospy.Rate(10)
 
################
## INITIALIZE ##
################
  valueAxe = 0.0
  valueButton = 0
  for i in range (0, 20):
    msg.axes.append(valueAxe)
  for e in range (0, 17):
    msg.buttons.append(valueButton)

  time.sleep(1)

####################
## PONERSE EN PIE ##
####################
  msg.buttons[3] = 1
  i=0
  bo=True
  print "STAND_UP"
  while not rospy.is_shutdown() and bo:
    i=i+1
    if (i>standup_time):
      bo=False
      msg.buttons[3] = 0
    pub.publish(msg)
    rate.sleep()

  time.sleep(2)


#################
## ANDAR 30 CM ##
#################
  msg.axes[1] =  1
  i=0
  bo=True
  print "WALKING"
  while not rospy.is_shutdown() and bo:
    i=i+1
    if (i>walking_time):
      bo=False
      msg.axes[1] = 0
    pub.publish(msg)
    rate.sleep()


###########
## GIRAR ##
###########
  msg.axes[2] = -1
  i=0
  bo=True
  print "TURN"
  while not rospy.is_shutdown() and bo:
    i=i+1
    if (i>turning_time):
      bo=False
      msg.axes[2] = 0
    pub.publish(msg)
    rate.sleep()


#################
## ANDAR 30 CM ##
#################
  msg.axes[1] =  1
  i=0
  bo=True
  print "WALKING"
  while not rospy.is_shutdown() and bo:
    i=i+1
    if (i>walking_time):
      bo=False
      msg.axes[1] = 0
    pub.publish(msg)
    rate.sleep()


####################
## SENTARSE ##
####################
  msg.buttons[3] = 1
  i=0
  bo=True
  standup_time=standup_time/3
  print "SEAT_DOWN"
#.........这里部分代码省略.........
开发者ID:IkerZamora,项目名称:ros_erle_spider,代码行数:103,代码来源:demo1.py


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