robot-control-stack icon indicating copy to clipboard operation
robot-control-stack copied to clipboard

MuJoCo Camera Integration

Open juelg opened this issue 2 years ago • 5 comments

In order to access the camera frame recorded in the simulation in python we need an integration between mujoco cameras and rcsss.

There is already a camera interface defined here which should be used as a simple API to expose the latest camera frame.

Currently, the simulation model and its state are stored in the model and data attributes in the FR3 sim class. An example of its usage can be seen in the simulation gym env. Both model and state should be given to a SimCamera (which inherits from Camera) object which implements the code to render a frame from the simulation.

The following references might be useful:

  • The MuJoCo documentation for visualization can be found here
  • This code and especially the function read_pixels() implements a renderer.

For now it is fine to only expose the latest image (render the camera image only upon request) from a single camera. Later on we can also think about how to index multiple cameras and how to save a fixed frame rate into a buffer. The latter would allow the caller to also access the history of past observations.

juelg avatar May 24 '24 13:05 juelg

I need assistance in running the example environment. I get the following issue.

branch: master cmd: (rcs) nava@multihead:~/robot-control-stack$ python python/rcsss/envs/sim.py

python traceback: `Traceback (most recent call last): File "/home/nava/robot-control-stack/python/rcsss/envs/sim.py", line 29, in robot = sim.FR3("models/mjcf/scene.xml", "models/urdf/fr3_from_panda.urdf", render=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nava/robot-control-stack/python/rcsss/sim.py", line 12, in init super().init(self.model._address, self.data._address, rlmdl, render) TypeError: init(): incompatible constructor arguments. The following argument types are supported: 1. rcsss._core.sim.FR3(mjmdl: str, rlmdl: str, render: Optional[bool] = None)

Invoked with: 114853120, 180029184, 'models/urdf/fr3_from_panda.urdf', True `

suman1209 avatar May 24 '24 14:05 suman1209

Have you also installed the latest version (with pip install -e .)?

juelg avatar May 24 '24 14:05 juelg

I did at the start, let me retry and let you know.

suman1209 avatar May 24 '24 14:05 suman1209

Have you also installed the latest version (with pip install -e .)?

I removed the existing build directory and used did a 'pip install -e .' and I get the following issue. Am I supposed to run anything else before the pip install? I attached the error.log for your reference CMakeError.log

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building editable for rcsss Failed to build rcsss ERROR: Could not build wheels for rcsss, which is required to install pyproject.toml-based projects

suman1209 avatar May 24 '24 14:05 suman1209

Hi Tobias, Could you please have a look at this branch, I have pushed an initial implementation, there are few things I need to discuss, at the moment I wish to ensure that I am on the right track. Thanks

suman1209 avatar May 31 '24 14:05 suman1209