(floor_size=None, terrain=False, rangefinders=False,
               walls_and_ball=False)
return etree.tostring(mjcf, pretty_print=True)
Returns the model XML string.
Returns the model XML string.
Returns the model XML string .
def make_model(floor_size=None, terrain=False, rangefinders=False,
               walls_and_ball=False):
  """Returns the model XML string."""
  xml_string = common.read_model('quadruped.xml')
  parser = etree.XMLParser(remove_blank_text=True)
  mjcf = etree.XML(xml_string, parser)

  # Set floor size.
  if floor_size is not None:
    floor_geom = mjcf.find('.//geom[@name=\'floor\']')
    floor_geom.attrib['size'] = f'{floor_size} {floor_size} .5'

  # Remove walls, ball and target.
  if not walls_and_ball:
    for wall in _WALLS:
      wall_geom = xml_tools.find_element(mjcf, 'geom', wall)
      wall_geom.getparent().remove(wall_geom)

    # Remove ball.
    ball_body = xml_tools.find_element(mjcf, 'body', 'ball')
    ball_body.getparent().remove(ball_body)

    # Remove target.
    target_site = xml_tools.find_element(mjcf, 'site', 'target')
    target_site.getparent().remove(target_site)

  # Remove terrain.
  if not terrain:
    terrain_geom = xml_tools.find_element(mjcf, 'geom', 'terrain')
    terrain_geom.getparent().remove(terrain_geom)

  # Remove rangefinders if they're not used, as range computations can be
  # expensive, especially in a scene with heightfields.
  if not rangefinders:
    rangefinder_sensors = mjcf.findall('.//rangefinder')
    for rf in rangefinder_sensors:
      rf.getparent().remove(rf)

  return etree.tostring(mjcf, pretty_print=True)
def make_model ( floor_size = None , terrain = False , rangefinders = False , walls_and_ball = False ) : xml_string = common . read_model ( 'quadruped.xml' ) parser = etree . XMLParser ( remove_blank_text = True ) mjcf = etree . XML ( xml_string , parser ) # Set floor size. if floor_size is not None : floor_geom = mjcf . find ( './/geom[@name=\'floor\']' ) floor_geom . attrib [ 'size' ] = f'{floor_size} {floor_size} .5' # Remove walls, ball and target. if not walls_and_ball : for wall in _WALLS : wall_geom = xml_tools . find_element ( mjcf , 'geom' , wall ) wall_geom . getparent ( ) . remove ( wall_geom ) # Remove ball. ball_body = xml_tools . find_element ( mjcf , 'body' , 'ball' ) ball_body . getparent ( ) . remove ( ball_body ) # Remove target. target_site = xml_tools . find_element ( mjcf , 'site' , 'target' ) target_site . getparent ( ) . remove ( target_site ) # Remove terrain. if not terrain : terrain_geom = xml_tools . find_element ( mjcf , 'geom' , 'terrain' ) terrain_geom . getparent ( ) . remove ( terrain_geom ) # Remove rangefinders if they're not used, as range computations can be # expensive, especially in a scene with heightfields. if not rangefinders : rangefinder_sensors = mjcf . findall ( './/rangefinder' ) for rf in rangefinder_sensors : rf . getparent ( ) . remove ( rf ) return etree . tostring ( mjcf , pretty_print = True )