(self,
             name='walker',
             marker_rgba=None,
             camera_control=False,
             camera_resolution=(28, 28),
             roll_gear=-60,
             steer_gear=55,
             walker_id=None,
             initializer=None)
Build a BoxHead.

    Args:
      name: name of the walker.
      marker_rgba: RGBA value set to walker.marker_geoms to distinguish between
        walkers (in multi-agent setting).
      camera_control: If `True`, the walker exposes two additional actuated
        degrees of freedom to control the egocentric camera height and tilt.
      camera_resolution: egocentric camera rendering resolution.
      roll_gear: gear determining forward acceleration.
      steer_gear: gear determining steering (spinning) torque.
      walker_id: (Optional) An integer in [0-10], this number will be shown on
        the walker's head. Defaults to `None` which does not show any number.
      initializer: (Optional) A `WalkerInitializer` object.

    Raises:
      ValueError: if received invalid walker_id.
Build a BoxHead.
Build a BoxHead .
def _build(self,
             name='walker',
             marker_rgba=None,
             camera_control=False,
             camera_resolution=(28, 28),
             roll_gear=-60,
             steer_gear=55,
             walker_id=None,
             initializer=None):
    """Build a BoxHead.

    Args:
      name: name of the walker.
      marker_rgba: RGBA value set to walker.marker_geoms to distinguish between
        walkers (in multi-agent setting).
      camera_control: If `True`, the walker exposes two additional actuated
        degrees of freedom to control the egocentric camera height and tilt.
      camera_resolution: egocentric camera rendering resolution.
      roll_gear: gear determining forward acceleration.
      steer_gear: gear determining steering (spinning) torque.
      walker_id: (Optional) An integer in [0-10], this number will be shown on
        the walker's head. Defaults to `None` which does not show any number.
      initializer: (Optional) A `WalkerInitializer` object.

    Raises:
      ValueError: if received invalid walker_id.
    """
    super()._build(initializer=initializer)
    xml_path = os.path.join(_ASSETS_PATH, 'boxhead.xml')
    self._mjcf_root = mjcf.from_xml_string(resources.GetResource(xml_path, 'r'))
    if name:
      self._mjcf_root.model = name

    if walker_id is not None and not 0 <= walker_id <= _MAX_WALKER_ID:
      raise ValueError(_INVALID_WALKER_ID.format(walker_id))

    self._walker_id = walker_id
    if walker_id is not None:
      png_bytes = _asset_png_with_background_rgba_bytes(
          'digits/%02d.png' % walker_id, marker_rgba)
      head_texture = self._mjcf_root.asset.add(
          'texture',
          name='head_texture',
          type='2d',
          file=mjcf.Asset(png_bytes, '.png'))
      head_material = self._mjcf_root.asset.add(
          'material', name='head_material', texture=head_texture)
      self._mjcf_root.find('geom', 'head').material = head_material
      self._mjcf_root.find('geom', 'head').rgba = None

      self._mjcf_root.find('geom', 'top_down_cam_box').material = head_material
      self._mjcf_root.find('geom', 'top_down_cam_box').rgba = None

    self._body_texture = self._mjcf_root.asset.add(
        'texture',
        name='ball_body',
        type='cube',
        builtin='checker',
        rgb1=marker_rgba[:-1] if marker_rgba else '.4 .4 .4',
        rgb2='.8 .8 .8',
        width='100',
        height='100')
    self._body_material = self._mjcf_root.asset.add(
        'material', name='ball_body', texture=self._body_texture)
    self._mjcf_root.find('geom', 'shell').material = self._body_material

    # Set corresponding marker color if specified.
    if marker_rgba is not None:
      for geom in self.marker_geoms:
        geom.set_attributes(rgba=marker_rgba)

    self._root_joints = None
    self._camera_control = camera_control
    self._camera_resolution = camera_resolution
    if not camera_control:
      for name in ('camera_pitch', 'camera_yaw'):
        self._mjcf_root.find('actuator', name).remove()
        self._mjcf_root.find('joint', name).remove()
    self._roll_gear = roll_gear
    self._steer_gear = steer_gear
    self._mjcf_root.find('actuator', 'roll').gear[0] = self._roll_gear
    self._mjcf_root.find('actuator', 'steer').gear[0] = self._steer_gear

    # Initialize previous action.
    self._prev_action = np.zeros(shape=self.action_spec.shape,
                                 dtype=self.action_spec.dtype)
def _build ( self , name = 'walker' , marker_rgba = None , camera_control = False , camera_resolution = ( 28 , 28 ) , roll_gear = - 60 , steer_gear = 55 , walker_id = None , initializer = None ) : super ( ) . _build ( initializer = initializer ) xml_path = os . path . join ( _ASSETS_PATH , 'boxhead.xml' ) self . _mjcf_root = mjcf . from_xml_string ( resources . GetResource ( xml_path , 'r' ) ) if name : self . _mjcf_root . model = name if walker_id is not None and not 0 <= walker_id <= _MAX_WALKER_ID : raise ValueError ( _INVALID_WALKER_ID . format ( walker_id ) ) self . _walker_id = walker_id if walker_id is not None : png_bytes = _asset_png_with_background_rgba_bytes ( 'digits/%02d.png' % walker_id , marker_rgba ) head_texture = self . _mjcf_root . asset . add ( 'texture' , name = 'head_texture' , type = '2d' , file = mjcf . Asset ( png_bytes , '.png' ) ) head_material = self . _mjcf_root . asset . add ( 'material' , name = 'head_material' , texture = head_texture ) self . _mjcf_root . find ( 'geom' , 'head' ) . material = head_material self . _mjcf_root . find ( 'geom' , 'head' ) . rgba = None self . _mjcf_root . find ( 'geom' , 'top_down_cam_box' ) . material = head_material self . _mjcf_root . find ( 'geom' , 'top_down_cam_box' ) . rgba = None self . _body_texture = self . _mjcf_root . asset . add ( 'texture' , name = 'ball_body' , type = 'cube' , builtin = 'checker' , rgb1 = marker_rgba [ : - 1 ] if marker_rgba else '.4 .4 .4' , rgb2 = '.8 .8 .8' , width = '100' , height = '100' ) self . _body_material = self . _mjcf_root . asset . add ( 'material' , name = 'ball_body' , texture = self . _body_texture ) self . _mjcf_root . find ( 'geom' , 'shell' ) . material = self . _body_material # Set corresponding marker color if specified. if marker_rgba is not None : for geom in self . marker_geoms : geom . set_attributes ( rgba = marker_rgba ) self . _root_joints = None self . _camera_control = camera_control self . _camera_resolution = camera_resolution if not camera_control : for name in ( 'camera_pitch' , 'camera_yaw' ) : self . _mjcf_root . find ( 'actuator' , name ) . remove ( ) self . _mjcf_root . find ( 'joint' , name ) . remove ( ) self . _roll_gear = roll_gear self . _steer_gear = steer_gear self . _mjcf_root . find ( 'actuator' , 'roll' ) . gear [ 0 ] = self . _roll_gear self . _mjcf_root . find ( 'actuator' , 'steer' ) . gear [ 0 ] = self . _steer_gear # Initialize previous action. self . _prev_action = np . zeros ( shape = self . action_spec . shape , dtype = self . action_spec . dtype )