本文整理汇总了Python中sensor_msgs.msg.JointState.position[pos]方法的典型用法代码示例。如果您正苦于以下问题:Python JointState.position[pos]方法的具体用法?Python JointState.position[pos]怎么用?Python JointState.position[pos]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sensor_msgs.msg.JointState
的用法示例。
在下文中一共展示了JointState.position[pos]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_joint_state_msg
# 需要导入模块: from sensor_msgs.msg import JointState [as 别名]
# 或者: from sensor_msgs.msg.JointState import position[pos] [as 别名]
def build_joint_state_msg(self):
"""
@brief JointState message builder.
Builds a JointState message with the current position of the finger
joints and its names.
"""
js_msg = JointState()
js_msg.header.stamp = rospy.Time.now()
if self.joint_names == []:
self.joint_names = ["{}.{}".format('hand', attr)
for attr in ORI_ATTRIBUTES] + \
["{}.{}.{}".format(finger, bone, ori)
for finger in FINGER_NAMES
for bone in FINGER_BONES
for ori in ORI_ATTRIBUTES]
LOG.v("Publishing JointState for the following joints: {}".format(self.joint_names), "start_transmit")
js_msg.position = [0.0] * len(self.joint_names)
pos = 0
# Build JointState. First the hand...
for i, attr in enumerate(ORI_ATTRIBUTES):
js_msg.name.append('hand.' + str(attr))
# Roll precision hack
if attr == 'roll':
vector = self.hand.palm_normal
else:
vector = self.hand.direction
js_msg.position[pos] = getattr(vector, attr)
pos += 1
# ...then the fingers
for i, finger_name, finger in \
[(i, finger_name, self.fingers[finger_name]) \
for i, finger_name in enumerate(FINGER_NAMES)]:
# LEAP API v2.0: Skeletal model
# Get bones
for j, bone_name, bone in \
[(j, bone_name, finger.bone(j)) \
for j, bone_name in enumerate(FINGER_BONES)]:
# Fill the joint values one by one
for k, attr in enumerate(ORI_ATTRIBUTES):
joint_name = "{}.{}.{}".format(finger_name, bone_name, attr)
joint_value = getattr(bone.direction, attr)
js_msg.name.append(joint_name)
js_msg.position[pos] = joint_value
pos += 1
# return the JointState message
return js_msg