Giter Club home page Giter Club logo

Comments (6)

realquantumcookie avatar realquantumcookie commented on June 18, 2024 1

Thanks guys! I just composed a pull request.
One more thing I want to point out is that dm_control's Physics class also supports a scene_callback keyword argument which can be very handy when rendering (e.g. using this argument to draw out arrows representing force vectors without adding actual arrows in the simulated environment). I can also make a pull request for this :) But do we need it?

from shimmy.

elliottower avatar elliottower commented on June 18, 2024

Not familiar with the details of how exactly to do multiple camera angles but we would be happy to accept a PR for this.

I would say to use a separate keyword argument to accomplish this rather than modifying render_mode because that’s reserved for toggling between human rendering/unrendered envs.

from shimmy.

pseudo-rnd-thoughts avatar pseudo-rnd-thoughts commented on June 18, 2024

@realquantumcookie Is it possible in dm-control? If so, could you provide some example code for it?

from shimmy.

realquantumcookie avatar realquantumcookie commented on June 18, 2024

@realquantumcookie Is it possible in dm-control? If so, could you provide some example code for it?

What I meant is we compose multiple calls to physics.render() and stich the images together.

def _internal_render(
      self,
      mode='rgb_array',
      height: int = HEIGHT,
      width: int = WIDTH,
      camera_id: typing.Optional[typing.Union[str, int]] = None,
      scene_callback = None
  ):
      assert mode in [
          'human', 'rgb_array'
      ], 'only support rgb_array and human mode, given %s' % mode
      if mode == "human":
          self._get_viewer().render()
          return
      else:
          physics = self._env.physics
          if camera_id is not None:
              return physics.render(
                  camera_id=camera_id,
                  height=height,
                  width=width,
              )
          # If no camera_id is specified, render all cameras in a grid.
          num_cameras = physics.model.ncam
          num_columns = int(math.ceil(math.sqrt(num_cameras)))
          num_rows = int(math.ceil(float(num_cameras) / num_columns))
          frame = np.zeros((num_rows * height, num_columns * width, 3), dtype=np.uint8)
          for col in range(num_columns):
              for row in range(num_rows):
                  camera_id = row * num_columns + col
                  if camera_id >= num_cameras:
                      break
                  subframe = physics.render(
                      camera_id=camera_id, height=height, width=width, scene_callback=scene_callback, scene_option=_SCENE_OPTION
                  )
                  frame[
                      row * height : (row + 1) * height, col * width : (col + 1) * width
                  ] = subframe
          return frame

from shimmy.

pseudo-rnd-thoughts avatar pseudo-rnd-thoughts commented on June 18, 2024

Wow, impressive code.
Yes I think we would be happy to include if you make a PR for the change.

I think we might want an additional render type, multi-camera maybe specify that this is different from rgb_array or human.

from shimmy.

pseudo-rnd-thoughts avatar pseudo-rnd-thoughts commented on June 18, 2024

Sure, it is nice to enable all of the fancy dm-control features for the compatibility wrapper

from shimmy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.