0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【初心者向け】Genesisって何?

Posted at

Genesisとは?

2024年末にリリースされ、各分野から注目された物理シミュレータです。
注目理由としては、

  • 高速で並列学習が可能
  • 剛体だけではなく、軟体もシミュレーション可能
  • APIがシンプル

が挙げられます。
そのため、ロボット分野やCG業界などで幅広く注目されています。
特に、現実世界の43万倍で高速シミュレーションであり、既存シミュレーターを遥かに凌駕しており、シミュレータの移行を悩んでいる人もいるでしょう。

詳細な比較結果は以下のページに記載されていますが、公式のベンチマークでは圧倒的な差となっています。

使用すべき?移行すべき?

結論から述べると、個人的にはMuJoCoPybulletのようなGPUでの動作が難しいシミュレーターを使用している場合ならば移行すべきだと思います。

その一方で、GPUで処理が行えるIssac GymIssac Simなどを用いて既にプロジェクトを遂行している場合は、次回からの移行か同一シミュレーターの継続使用がおすすめです。

環境構築

筆者は以下の環境で構築しました。
仮想環境の構築は、Mambaで行いました。
MambaはAnacondaをC++で実装したパッケージマネージャーであり、Anacondaと同じコマンドを用いて高速で環境構築ができるのでおすすめです。

型番 & Version
CPU AMD Ryzen9 5950X
GPU RTX 3090
OS Windows 11
WSL 2.3.26.0
Python 3.10
mamba create -n genesis python=3.10
mamba activate genesis

ライブラリは公式ドキュメント通りに、pipでインストールしました。

pip install genesis-world
pip install torch torchvision torchaudio

とりあえず動かしてみる

Genesisの主な流れは、以下の4段階です。

  1. 初期化
  2. entityの追加
  3. build
  4. stepで進める

以下のコードは、Computer Vision分野でおなじみのStanford Bunnyの周りをカメラが回り続けるコードです。
Genesisでは、cam.render(depth=True, segmentation=True)でRGBやDepthイメージ、セグメンテーションが一括で取得可能です。

import torch
import genesis  as gs

########################### Initialize ##########################

gs.init(backend=gs.gpu)

scene = gs.Scene(
    vis_options = gs.options.VisOptions(
        show_world_frame = False,   # Show xyz axes
        world_frame_size = 1.0,
        show_link_frame  = False,
        show_cameras     = False,
        plane_reflection = True,
        ambient_light    = (0.1, 0.1, 0.1),
    ),
)

cam = scene.add_camera(
    res    = (200, 200),
    pos    = (0.0, -1.0, 0.7),
    lookat = (0, 0, 0.7),
    fov    = 45,
    GUI    = True,
)

########################### entities ##########################
plane = scene.add_entity(
    gs.morphs.Plane()
)

bunny = scene.add_entity(
    morph=gs.morphs.Mesh(
        file="meshes/bunny.obj",
        pos=(0, 0, 0.7),
        fixed=True,
    )
)

########################## build ##########################

scene.build(n_envs = 1, env_spacing = (2.0, 2.0))
cam.render(depth=True, segmentation=False)

for i in range(1_000):
    scene.step()

    # change camera position
    cam.set_pose(
        pos = (3.0 * torch.sin(torch.deg2rad(torch.tensor(i*30))), 3.0 * torch.cos(torch.deg2rad(torch.tensor(i*30))), 0.7),
        lookat = (0, 0, 0.7),
    )
    img, depth, seg, normal = cam.render(depth=True, segmentation=True, normal=True)

genesis_render.png

Videotogif (1).gif

参考文献

公式ドキュメント

プロジェクトページ

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?