小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
动手学ros2中第7章的坐标变换发布监听python实现的课程演示代码报错
-
import rclpy
from rclpy.node import Node
from geometry_msgs.msg import TransformStamped
from tf2_ros import StaticTransformBroadcaster
rclpy.init()
node = Node("transform_node")
static_tf_pub = StaticTransformBroadcaster(node)
t = TransformStamped()
t.header.stamp = node.get_clock().now().to_msg()
#parent-name:基坐标系B
t.header.frame_id = 'B'
#child-name:相机坐标系C
t.header.frame_id = 'C'
#平移关系,单位m
t.transform.translation.x = 0.0
t.transform.translation.y = 0.0
t.transform.translation.z = 3.0
#旋转关系,四元数形式,我们需要将欧拉角的形式转换成四元数
t.transform.rotation.x = 1.0
t.transform.rotation.y = 0.0
t.transform.rotation.z = 0.0
t.transform.rotation.w = 0.0
static_tf_pub.sendTransform(t)
!ros2 run tf2_ros tf2_echo B C
就从这一步监听坐标关系执行开始报错
[INFO] [1692175408.030060629] [tf2_echo]: Waiting for transform B -> Invalid frame ID "B" passed to canTransform argument target_frame - frame does not exist
Error: TF_NO_CHILD_FRAME_ID: Ignoring transform from authority "Authority undetectable" because child_frame_id not set
at line 217 in /tmp/binarydeb/ros-rolling-tf2-0.21.0/src/buffer_core.cpp
[INFO] [1692175409.999420236] [tf2_echo]: Waiting for transform B -> Invalid frame ID "B" passed to canTransform argument target_frame - frame does not exist
然后就一直循环报错提示目标帧不存在
想问问这是哪里有问题呢? -