(self, direction, net_rgba=(1, 1, 1, .15), make_net=True, **kwargs)
Builds the goalposts and net.

    Args:
      direction: Is the goal oriented towards positive or negative x-axis.
      net_rgba: rgba value of the net geoms.
      make_net: Where to add net geoms.
      **kwargs: arguments of PositionDetector superclass, see therein.

    Raises:
      ValueError: If either `pos` or `size` arrays are not of length 3.
      ValueError: If direction in not 1 or -1.
Builds the goalposts and net.
Builds the goalposts and net .
def _build(self, direction, net_rgba=(1, 1, 1, .15), make_net=True, **kwargs):
    """Builds the goalposts and net.

    Args:
      direction: Is the goal oriented towards positive or negative x-axis.
      net_rgba: rgba value of the net geoms.
      make_net: Where to add net geoms.
      **kwargs: arguments of PositionDetector superclass, see therein.

    Raises:
      ValueError: If either `pos` or `size` arrays are not of length 3.
      ValueError: If direction in not 1 or -1.
    """
    if len(kwargs['size']) != 3 or len(kwargs['pos']) != 3:
      raise ValueError('Only 3D Goals are supported.')
    if direction not in [1, -1]:
      raise ValueError('direction must be either 1 or -1.')
    # Flip both x and y, to maintain left / right name correctness.
    self._direction = np.array((direction, direction, 1))
    self._make_net = make_net

    # Force the underlying PositionDetector to a non visible site group.
    kwargs['visible'] = False
    # Make a Position_Detector.
    super()._build(retain_substep_detections=True, **kwargs)

    # Add goalpost geoms.
    size = kwargs['size']
    pos = kwargs['pos']
    self._goalpost_radius = _goalpost_radius(size)
    self._goal_geoms = []
    for geom_name, unit_fromto in _GOALPOSTS.items():
      geom_fromto = _goalpost_fromto(unit_fromto, size, pos, self._direction)
      geom_size = (_post_radius(geom_name, self._goalpost_radius),)
      self._goal_geoms.append(
          self._mjcf_root.worldbody.add(
              'geom',
              type='capsule',
              name=geom_name,
              size=geom_size,
              fromto=geom_fromto,
              rgba=self.goalpost_rgba))

    # Add net meshes and geoms.
    if self._make_net:
      net_vertices = self._make_net_vertices()
      self._net_geoms = []
      for name, vertex in net_vertices.items():
        mesh = self._mjcf_root.asset.add('mesh', name=name, vertex=vertex)
        geom = self._mjcf_root.worldbody.add('geom', type='mesh', mesh=mesh,
                                             name=name, rgba=net_rgba,
                                             contype=0, conaffinity=0)
        self._net_geoms.append(geom)
def _build ( self , direction , net_rgba = ( 1 , 1 , 1 , .15 ) , make_net = True , * * kwargs ) : if len ( kwargs [ 'size' ] ) != 3 or len ( kwargs [ 'pos' ] ) != 3 : raise ValueError ( 'Only 3D Goals are supported.' ) if direction not in [ 1 , - 1 ] : raise ValueError ( 'direction must be either 1 or -1.' ) # Flip both x and y, to maintain left / right name correctness. self . _direction = np . array ( ( direction , direction , 1 ) ) self . _make_net = make_net # Force the underlying PositionDetector to a non visible site group. kwargs [ 'visible' ] = False # Make a Position_Detector. super ( ) . _build ( retain_substep_detections = True , * * kwargs ) # Add goalpost geoms. size = kwargs [ 'size' ] pos = kwargs [ 'pos' ] self . _goalpost_radius = _goalpost_radius ( size ) self . _goal_geoms = [ ] for geom_name , unit_fromto in _GOALPOSTS . items ( ) : geom_fromto = _goalpost_fromto ( unit_fromto , size , pos , self . _direction ) geom_size = ( _post_radius ( geom_name , self . _goalpost_radius ) , ) self . _goal_geoms . append ( self . _mjcf_root . worldbody . add ( 'geom' , type = 'capsule' , name = geom_name , size = geom_size , fromto = geom_fromto , rgba = self . goalpost_rgba ) ) # Add net meshes and geoms. if self . _make_net : net_vertices = self . _make_net_vertices ( ) self . _net_geoms = [ ] for name , vertex in net_vertices . items ( ) : mesh = self . _mjcf_root . asset . add ( 'mesh' , name = name , vertex = vertex ) geom = self . _mjcf_root . worldbody . add ( 'geom' , type = 'mesh' , mesh = mesh , name = name , rgba = net_rgba , contype = 0 , conaffinity = 0 ) self . _net_geoms . append ( geom )