我如何在使用Meshcat时可视化Drake中的坐标框架?

huangapple go评论144阅读模式
英文:

How do I visualize coordinate frames in Drake using Meshcat?

问题

我如何在Meshcat中查看Drake的坐标框架?我只找到了与Drake Visualizer相关的这个相关问题,但在查找Meshcat的等效代码方面遇到了麻烦。

我已经取得了一些进展,并使用以下代码在原点添加了一个坐标框架:

AddFrameTriadIllustration(scene_graph=scene_graph, plant=plant, frame_id=plant.world_frame_id())

然而,我想要在我的机器人末端执行器处显示一个坐标框架。我在确定如何获取不是world_frame_id的框架ID方面遇到了困难。

英文:

How can I view coordinate frames from Drake in Meschcat? I only found this related question about Drake Visualizer but had trouble finding the equivalent code for Meshcat.

I have made some progress and got a coordinate frame at the origin using

    AddFrameTriadIllustration(scene_graph=scene_graph, plant=plant, frame_id=plant.world_frame_id())

However, I want a coordinate frame displayed at my robot's end effector. I'm having trouble determining how to obtain a frame id that's not the world_frame_id.

答案1

得分: 1

要可视化一个相对于SceneGraph框架偏移的框架,请调用pydrake.visualization.AddFrameTriadIllustration。如果基本框架是世界框架,那么您提供的X_FT将是您试图可视化的物体的世界姿态。

这里有一个示例用法链接来可视化_所有_现有的框架。

如果链接失效,下面是代码片段。

# https://github.com/RobotLocomotion/drake/blob/v1.19.0/bindings/pydrake/visualization/_model_visualizer.py#L257-L274
if self._visualize_frames:
    # 找到所有框架并将其绘制出来。
    # 使用解析的长度来绘制框架。
    # 世界框架比其余框架绘制得更粗。
    inspector = self._builder.scene_graph().model_inspector()
    for frame_id in inspector.GetAllFrameIds():
        world_id = self._builder.scene_graph().world_frame_id()
        radius = self._triad_radius * (
            3 if frame_id == world_id else 1
            )
        AddFrameTriadIllustration(
            plant=self._builder.plant(),
            scene_graph=self._builder.scene_graph(),
            frame_id=frame_id,
            length=self._triad_length,
            radius=radius,
            opacity=self._triad_opacity,
        )
英文:

To visualize a frame that's offset from a SceneGraph frame, call pydrake.visualization.AddFrameTriadIllustration. If the base frame is the world frame, then the X_FT you provide would be the world pose of what you're trying to visualize.

Here's a link to a sample usage to visualize all of the existing frames.

In case the link disappears, the snippet is reproduced below.

# https://github.com/RobotLocomotion/drake/blob/v1.19.0/bindings/pydrake/visualization/_model_visualizer.py#L257-L274
if self._visualize_frames:
    # Find all the frames and draw them.
    # The frames are drawn using the parsed length.
    # The world frame is drawn thicker than the rest.
    inspector = self._builder.scene_graph().model_inspector()
    for frame_id in inspector.GetAllFrameIds():
        world_id = self._builder.scene_graph().world_frame_id()
        radius = self._triad_radius * (
            3 if frame_id == world_id else 1
            )
        AddFrameTriadIllustration(
            plant=self._builder.plant(),
            scene_graph=self._builder.scene_graph(),
            frame_id=frame_id,
            length=self._triad_length,
            radius=radius,
            opacity=self._triad_opacity,
        )

huangapple
  • 本文由 发表于 2023年7月14日 05:10:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76683262.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定