Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to define a good camera perspective #794

Open
YitzhakSp opened this issue Mar 8, 2024 · 0 comments
Open

unable to define a good camera perspective #794

YitzhakSp opened this issue Mar 8, 2024 · 0 comments

Comments

@YitzhakSp
Copy link

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()

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant