gpt4 book ai didi

ros - 如何使用 tf_remap?

转载 作者:行者123 更新时间:2023-12-03 18:03:24 34 4
gpt4 key购买 nike

我有一个 rosbag其中一个/tf主题被记录。
我需要重新映射所有 tf那个包中的框架指的是名为 /world 的框架引用名为 /vision 的新框架.我尝试了以下操作,但不幸的是它不起作用:

rosrun tf tf_remap _mappings:='[{old: /world, new: /vision}]'
我错过了什么吗?
我还尝试从启动文件中执行此操作:
    <launch>
<node pkg="tf" type="tf_remap" name="tf_remapper" output="screen">
<rosparam param="mappings">
- {old: "/world",
new: "/vision"}
</rosparam>
</node>
</launch>
结果一样...
我发现有人说,除了运行 tf_remap节点, rosbag应该按如下方式运行:
rosbag play x.bag /tf:=/tf_old
也这样做了......仍然无法正常工作。 tf_frame s还是指 /world而不是 /vision .
任何帮助将不胜感激!

编辑
这是为了澄清更多我想要实现的目标:
我想要的是重新映射包中记录的所有帧并引用 /world ,并使它们引用 /vision反而。应该没有 /world包的重新映射输出中的帧。在代码的其他地方,我将定义名为 /world 的框架。及其与 /vision 的关系.

最佳答案

您可以使用 rosbag python/c++ API 编辑包文件的内容。这是一个使用 python 的示例,它只会将包中记录的/tf msgs 中的/world 的任何实例替换为/vision。

import rosbag
from copy import deepcopy
import tf

bagInName = '___.bag'
bagIn = rosbag.Bag(bagInName)
bagOutName = '___fixed.bag'
bagOut = rosbag.Bag(bagOutName,'w')
with bagOut as outbag:
for topic, msg, t in bagIn.read_messages():
if topic == '/tf':
new_msg = deepcopy(msg)
for i,m in enumerate(msg.transforms): # go through each frame->frame tf within the msg.transforms
if m.header.frame_id == "/world":
m.header.frame_id = "/vision"
new_msg.transforms[i] = m
if m.child_frame_id == "/world":
m.child_frame_id = "/vision"
new_msg.transforms[i] = m

outbag.write(topic, new_msg, t)
else:
outbag.write(topic, msg, t)

bagIn.close()
bagOut.close()

关于ros - 如何使用 tf_remap?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32254799/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com