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


Python tf2_ros.TransformBroadcaster方法代码示例

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


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

示例1: publish_pose_as_transform

# 需要导入模块: import tf2_ros [as 别名]
# 或者: from tf2_ros import TransformBroadcaster [as 别名]
def publish_pose_as_transform(pose, reference_frame, name, seconds=1):
    """
    Publish a pose as a transform so that it is visualised in rviz.
    pose                -> A geometry_msgs.msg/Pose to be converted into a transform and published
    reference_frame     -> A string defining the reference_frame of the pose
    name                -> A string defining the child frame of the transform
    seconds             -> An int32 that defines the duration the transform will be broadcast for
    """

    # Create a broadcast node and a stamped transform to broadcast
    br = tf2_ros.TransformBroadcaster()
    t = gmsg.TransformStamped()

    # Prepare broadcast message
    t.header.frame_id = reference_frame
    t.child_frame_id = name

    # Copy in pose values to transform
    t.transform.translation = pose.position
    t.transform.rotation = pose.orientation

    # Call the publish_stamped_transform function
    publish_stamped_transform(t, seconds) 
开发者ID:dougsm,项目名称:ggcnn_kinova_grasping,代码行数:25,代码来源:transforms.py

示例2: publish_stamped_transform

# 需要导入模块: import tf2_ros [as 别名]
# 或者: from tf2_ros import TransformBroadcaster [as 别名]
def publish_stamped_transform(stamped_transform, seconds=1):
    """
    Publish a stamped transform for debugging purposes.
        stamped_transform       -> A geometry_msgs/TransformStamped to be published
        seconds                 -> An int32 that defines the duration the transform will be broadcast for
    """
    # Create broadcast node
    br = tf2_ros.TransformBroadcaster()

    # Publish once first.
    stamped_transform.header.stamp = rospy.Time.now()
    br.sendTransform(stamped_transform)

    # Publish transform for set time.
    i = 0
    iterations = seconds/0.05
    while not rospy.is_shutdown() and i < iterations:
        stamped_transform.header.stamp = rospy.Time.now()
        br.sendTransform(stamped_transform)
        rospy.sleep(0.05)
        i += 1 
开发者ID:dougsm,项目名称:mvp_grasp,代码行数:23,代码来源:tf_helpers.py

示例3: __init__

# 需要导入模块: import tf2_ros [as 别名]
# 或者: from tf2_ros import TransformBroadcaster [as 别名]
def __init__(self):
        """
        Constructor
        """
        if MISSING_IMPORT is not None:
            raise pybullet.error(MISSING_IMPORT)

        self.spin_thread = None
        self._wrapper_termination = False
        self.image_bridge = CvBridge()
        self.front_info_msg = dict()
        self.bottom_info_msg = dict()
        self.depth_info_msg = dict()
        self.roslauncher = None
        self.transform_broadcaster = tf2_ros.TransformBroadcaster()
        atexit.register(self.stopWrapper) 
开发者ID:softbankrobotics-research,项目名称:qibullet,代码行数:18,代码来源:ros_wrapper.py

示例4: main

# 需要导入模块: import tf2_ros [as 别名]
# 或者: from tf2_ros import TransformBroadcaster [as 别名]
def main(_):
    """ Main function, starts predictor.
    """
    print('main')
    rospy.init_node('costar_hyper_prediction')
    predictor = CostarHyperPosePredictor()

    broadcaster = tf2.TransformBroadcaster()
    transform_name = 'predicted_goal_' + predictor.ee_frame
    rospy.loginfo('costar_hyper_prediction transform predictions will be broadcast as: ' + str(transform_name))
    update_rate = 0.25
    rate = rospy.Rate(update_rate)
    progbar = tqdm()

    while not rospy.is_shutdown():
        rate.sleep()
        start_time = time.clock()
        prediction_xyz_qxyzw, prediction_input_data_time = predictor()
        tick_time = time.clock()

        b_to_e = TransformStamped()
        b_to_e.header.stamp = prediction_input_data_time
        b_to_e.header.frame_id = predictor.base_link
        b_to_e.child_frame_id = transform_name
        b_to_e.transform.translation.x = prediction_xyz_qxyzw[0]
        b_to_e.transform.translation.y = prediction_xyz_qxyzw[1]
        b_to_e.transform.translation.z = prediction_xyz_qxyzw[2]
        b_to_e.transform.rotation.x = prediction_xyz_qxyzw[3]
        b_to_e.transform.rotation.y = prediction_xyz_qxyzw[4]
        b_to_e.transform.rotation.z = prediction_xyz_qxyzw[5]
        b_to_e.transform.rotation.w = prediction_xyz_qxyzw[6]
        broadcaster.sendTransform(b_to_e)
        update_time = time.clock()

        # figure out where the time has gone
        time_str = ('Total tick + log time: {:04} sec, '
                    'Robot Prediction: {:04} sec, '
                    'Sending Results: {:04} sec'.format(update_time - start_time, tick_time - start_time, update_time - tick_time))
        verify_update_rate(update_time_remaining=rate.remaining(), update_rate=update_rate, info=time_str)
        progbar.update() 
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:42,代码来源:costar_hyper_prediction.py

示例5: __debug_loop

# 需要导入模块: import tf2_ros [as 别名]
# 或者: from tf2_ros import TransformBroadcaster [as 别名]
def __debug_loop(self):
        """
        Debug loop that will run in a separate thread.
        (tfBuffer should be threadsafe)
        """
        broadcaster = tf2_ros.TransformBroadcaster()
        rviz_marker_pub = rospy.Publisher('/visualization_marker', Marker,
                                          queue_size=1000)
        rate = rospy.Rate(5)
        while not self.__debug_stop_event.is_set() and not rospy.is_shutdown():
            if self.__debug_current_ws is None:
                print "Could not publish debug tf, no workspace set."
                rate.sleep()
                continue

            try:
                broadcaster.sendTransform(
                    self.__tf_buffer.lookup_transform(
                        "base_link", self.__debug_current_ws.name,
                        rospy.Time(0))
                )
                broadcaster.sendTransform(
                    self.__tf_buffer.lookup_transform(
                        self.__debug_current_ws.name, "object_base",
                        rospy.Time(0))
                )
                broadcaster.sendTransform(
                    self.__tf_buffer.lookup_transform(
                        "object_base", "tool_link_target", rospy.Time(0))
                )
            except tf2_ros.LookupException as e:
                print "Could not publish debug tf: ", e

            for i in range(4):  # Iterate over the 4 markers defining the workspace
                msg = Marker()
                msg.header.frame_id = "base_link"
                msg.id = i
                msg.type = 2  # It correspond to a sphere which will be drawn

                msg.pose.position.x = self.__debug_current_ws.points[i][0]
                msg.pose.position.y = self.__debug_current_ws.points[i][1]
                msg.pose.position.z = self.__debug_current_ws.points[i][2]

                msg.scale.x = 0.005
                msg.scale.y = 0.005
                msg.scale.z = 0.005

                msg.color.r = 1.0 if i == 0 or i == 3 else 0.0
                msg.color.g = 1.0 if i == 1 or i == 3 else 0.0
                msg.color.b = 1.0 if i == 2 or i == 3 else 0.0
                msg.color.a = 1.0

                rviz_marker_pub.publish(msg)

        rate.sleep() 
开发者ID:NiryoRobotics,项目名称:niryo_one_ros,代码行数:57,代码来源:transform_handler.py


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