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


Python Joy.header方法代码示例

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


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

示例1: toPS3Msg

# 需要导入模块: from sensor_msgs.msg import Joy [as 别名]
# 或者: from sensor_msgs.msg.Joy import header [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: motion_interface

# 需要导入模块: from sensor_msgs.msg import Joy [as 别名]
# 或者: from sensor_msgs.msg.Joy import header [as 别名]
def motion_interface():
	rospy.init_node('motion_interface', anonymous = False)
	interface.flushInput()

	# Subscribe to velocity and direction messages
	rospy.Subscriber("/motion_interface/velocity", Float32, velocity_callback)
	rospy.Subscriber("/motion_interface/direction", Float32, direction_callback)
	
	# Perform a loop checking on the enabled status of the drivers
	while not rospy.is_shutdown():
		# Build a message to send to the controller (request packet)
		message = json.dumps({'request' : ['enabled', 'throttle', 'steering']});
		interface.write(message)
		interface.write('\r')
		#rospy.loginfo(message)
		
		# Fetch a JSON message from the controller and process (or atleast attempt to)
		try:
			_object = json.loads(interface.readline());
			enabledPublisher.publish(Bool(_object['enabled']))
			_joy = Joy()
			_joy.header = rospy.Header()
			_joy.axes.append(_object['throttle'])
			_joy.axes.append(_object['steering'])
			joystickPublisher.publish(_joy)
		except json.decoder.JSONDecodeError:
			enabledPublisher.publish(Bool(False))
			rospy.logwarn("Invalid message received")
		except: pass

		rospy.sleep(0.1);
		
	# Perform closing operations (like stopping motors)
	message = json.dumps({'velocity' : 0.0, 'direction' : 0.0})
	interface.write(message)
	interface.write('\r')
开发者ID:Teknoman117,项目名称:ucm-ros-pkg,代码行数:38,代码来源:motion_interface.py


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