我有一个rosbag在其中一个/tf主题记录.
我需要重新映射tf那个引用命名框架的框架中的所有框架,/world以引用一个名为的新框架/vision.我尝试了以下但不幸的是没有工作:
rosrun tf tf_remap _mappings:='[{old: /world, new: /vision}]'
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?
我也尝试从启动文件中执行此操作:
<launch>
<node pkg="tf" type="tf_remap" name="tf_remapper" output="screen">
<rosparam param="mappings">
- {old: "/world",
new: "/vision"}
</rosparam>
</node>
</launch>
Run Code Online (Sandbox Code Playgroud)
结果相同......
我发现有人说,除了运行tf_remap节点外,rosbag还应运行如下:
rosbag play x.bag /tf:=/tf_old
Run Code Online (Sandbox Code Playgroud)
也做到了......仍然无法正常工作.
该tf_frames的仍参照/world,而不是/vision.
任何帮助将非常感谢!
这是为了澄清我想要实现的更多内容:
我想要的是重新映射包中记录的所有帧并参考/world,并使它们引用/vision./world袋子的重新映射输出中应该没有框架.在代码的其他地方,我将定义命名的框架/world及其与之关系/vision.
您可以使用 rosbag python/c++ API 编辑 bag 文件的内容。这是一个 python 示例,它将在您的包记录的 /tf 消息中将 /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()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2442 次 |
| 最近记录: |