當前位置: 首頁>>代碼示例>>Python>>正文


Python InteractiveMarkerControl.markers方法代碼示例

本文整理匯總了Python中visualization_msgs.msg.InteractiveMarkerControl.markers方法的典型用法代碼示例。如果您正苦於以下問題:Python InteractiveMarkerControl.markers方法的具體用法?Python InteractiveMarkerControl.markers怎麽用?Python InteractiveMarkerControl.markers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在visualization_msgs.msg.InteractiveMarkerControl的用法示例。


在下文中一共展示了InteractiveMarkerControl.markers方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: publish_gripper

# 需要導入模塊: from visualization_msgs.msg import InteractiveMarkerControl [as 別名]
# 或者: from visualization_msgs.msg.InteractiveMarkerControl import markers [as 別名]
def publish_gripper(server, pose_stamped, name):
    """Publishes a marker representing a gripper.

    Code taken from action_step_marker.py in PR2/PbD.

    Args:
      server: An InteractiveMarkerServer
      pose_stamped: A PoseStamped giving the wrist_roll_link pose.
      name: string, a unique name for this gripper.
    """
    # Set angle of meshes based on gripper open vs closed.
    angle = 28 * math.pi / 180.0  # Fully open.
    STR_MESH_GRIPPER_FOLDER = 'package://pr2_description/meshes/gripper_v0/'
    STR_GRIPPER_PALM_FILE = STR_MESH_GRIPPER_FOLDER + 'gripper_palm.dae'
    STR_GRIPPER_FINGER_FILE = STR_MESH_GRIPPER_FOLDER + 'l_finger.dae'
    STR_GRIPPER_FINGERTIP_FILE = STR_MESH_GRIPPER_FOLDER + 'l_finger_tip.dae'

    # Make transforms in preparation for meshes 1, 2, and 3.
    # NOTE(mbforbes): There are some magic numbers in here that are
    # used a couple times. Seems like a good candidate for
    # refactoring to constants, but I think they're more clear if
    # left in here as (a) they likely won't be changed, and (b) it's
    # easier to understand the computations with them here.
    transform1 = tf.transformations.euler_matrix(0, 0, angle)
    transform1[:3, 3] = [0.07691, 0.01, 0]
    transform2 = tf.transformations.euler_matrix(0, 0, -angle)
    transform2[:3, 3] = [0.09137, 0.00495, 0]
    t_proximal = transform1
    t_distal = tf.transformations.concatenate_matrices(transform1, transform2)

    # Create mesh 1 (palm).
    mesh1 = Marker()
    mesh1.header.frame_id = pose_stamped.header.frame_id
    mesh1.mesh_use_embedded_materials = True
    mesh1.type = Marker.MESH_RESOURCE
    mesh1.scale.x = 1.0
    mesh1.scale.y = 1.0
    mesh1.scale.z = 1.0
    mesh1.mesh_resource = STR_GRIPPER_PALM_FILE
    mesh1.pose = pose_stamped.pose

    # Create mesh 2 (finger).
    mesh2 = Marker()
    mesh2.mesh_use_embedded_materials = True
    mesh2.type = Marker.MESH_RESOURCE
    mesh2.scale.x = 1.0
    mesh2.scale.y = 1.0
    mesh2.scale.z = 1.0
    mesh2.mesh_resource = STR_GRIPPER_FINGER_FILE
    mesh2.pose = _get_pose_from_transform(t_proximal)

    # Create mesh 3 (fingertip).
    mesh3 = Marker()
    mesh3.mesh_use_embedded_materials = True
    mesh3.type = Marker.MESH_RESOURCE
    mesh3.scale.x = 1.0
    mesh3.scale.y = 1.0
    mesh3.scale.z = 1.0
    mesh3.mesh_resource = STR_GRIPPER_FINGERTIP_FILE
    mesh3.pose = _get_pose_from_transform(t_distal)

    # Make transforms in preparation for meshes 4 and 5.
    quat = tf.transformations.quaternion_multiply(
        tf.transformations.quaternion_from_euler(math.pi, 0, 0),
        tf.transformations.quaternion_from_euler(0, 0, angle))
    transform1 = tf.transformations.quaternion_matrix(quat)
    transform1[:3, 3] = [0.07691, -0.01, 0]
    transform2 = tf.transformations.euler_matrix(0, 0, -angle)
    transform2[:3, 3] = [0.09137, 0.00495, 0]
    t_proximal = transform1
    t_distal = tf.transformations.concatenate_matrices(transform1, transform2)

    # Create mesh 4 (other finger).
    mesh4 = Marker()
    mesh4.mesh_use_embedded_materials = True
    mesh4.type = Marker.MESH_RESOURCE
    mesh4.scale.x = 1.0
    mesh4.scale.y = 1.0
    mesh4.scale.z = 1.0
    mesh4.mesh_resource = STR_GRIPPER_FINGER_FILE
    mesh4.pose = _get_pose_from_transform(t_proximal)

    # Create mesh 5 (other fingertip).
    mesh5 = Marker()
    mesh5.mesh_use_embedded_materials = True
    mesh5.type = Marker.MESH_RESOURCE
    mesh5.scale.x = 1.0
    mesh5.scale.y = 1.0
    mesh5.scale.z = 1.0
    mesh5.mesh_resource = STR_GRIPPER_FINGERTIP_FILE
    mesh5.pose = _get_pose_from_transform(t_distal)

    # Append all meshes we made.
    control = InteractiveMarkerControl()
    control.markers = [mesh1, mesh2, mesh3, mesh4, mesh5]
    control.interaction_mode = InteractiveMarkerControl.NONE
    interactive_marker = InteractiveMarker()
    interactive_marker.controls = [control]
    interactive_marker.header.frame_id = pose_stamped.header.frame_id
    interactive_marker.pose = pose_stamped.pose
#.........這裏部分代碼省略.........
開發者ID:hcrlab,項目名稱:push_pull,代碼行數:103,代碼來源:visualization.py


注:本文中的visualization_msgs.msg.InteractiveMarkerControl.markers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。