MuJoCoで地形をカスタマイズしたい!
強化学習でシミュレーション環境といえばMuJoCoですが,やってるうちに地形をいじりたいな〜と思ってリファレンスを軽く読んだので残しておきます.
gray scale画像から読み込む
MuJoCoのリファレンスによると,gray scale画像から地形情報を読み込めるらしいです.
やってみました.
やり方
- gray scale 画像を作る(terrain4.png)

- xmlファイルをいじる
assetの部分.主にhfieldの部分.
ant.xml
<asset>
<texture builtin="gradient" height="100" rgb1="1 1 1" rgb2="0 0 0" type="skybox" width="100"/>
<texture builtin="flat" height="1278" mark="cross" markrgb="1 1 1" name="texgeom" random="0.01" rgb1="0.8 0.6 0.4" rgb2="0.8 0.6 0.4" type="cube" width="127"/>
<texture builtin="checker" height="100" name="texplane" rgb1="0.2 0.4 0.6" rgb2="0.8 0.8 0.8" type="2d" width="100"/>
<material name="MatPlane" reflectance="0.5" shininess="1" specular="1" texrepeat="60 60" texture="texplane"/>
<material name="geom" texture="texgeom" texuniform="true"/>
<hfield name="mytilted" file="terrain4.png" nrow="0" ncol="0" size="50 50 3 0.1" />
</asset>
worldbodyの部分
ant.xml
<geom conaffinity="1" condim="3" hfield="mytilted" material="MatPlane" name="floor" pos="0 0 0" rgba="0.8 0.9 0.8 1" type="hfield"/>