mujoco-py
mujoco-py copied to clipboard
unable to define a good camera perspective
I have a problem with camera setting. Getting either black screen or useless camera perspective (an image that is not informative), when rendering my model. Please help me to find a camera setting that will give a nice view from position (1, 0, 1.5). here is my xml that includes 3 cameras (none of them gives satisfying view, as mentioned above).
(tmp.xml)
<mujoco>
<option gravity="0 0 0" />
<!--<option gravity="0 0 0" /> -->
<worldbody>
<light diffuse=".5 .5 .5" pos="0 0 3" dir="0 0 -1"/>
<geom type="plane" size="2 2 0.1" rgba="0 0.9 0 1"/>
<body pos="0 0 0.1">
<joint type="free"/>
<geom type="cylinder" size="0.05 0.5" rgba="1 0 0 1"/>
</body>
<camera name="cam_1" pos="1 0 2" euler="0 20 20"/>
<camera name="cam_2" pos="1 0 2" euler="-10 0 0"/>
<camera name="cam_3" pos="1.0 0 2" euler="0 0 15"/>
</worldbody>
</mujoco>
here is the code of the program itself:
import mujoco_py
import os
# Load the model from the XML file
model = mujoco_py.load_model_from_path("tmp.xml")
sim = mujoco_py.MjSim(model)
# Create a viewer to visualize the simulation
viewer = mujoco_py.MjViewer(sim)
camera_index = model.camera_name2id("cam_1")
viewer.cam.fixedcamid = camera_index
viewer.cam.type = mujoco_py.generated.const.CAMERA_FIXED
while True:
sim.step()
viewer.render()
`