Home | Tutorials | Wiki | Issues
Ask Your Question

Revision history [back]

Do you want to split them in the model level, or an even lower level, like links?

If you want to split by models, you can put each model in a directory, then include them all into the same world SDF using the <include> tag. You can use the same idea to nest models into each other.

If you want a more granular split, you won't be able to do it without using another script language, since SDF doensn't support top-level tags besides <world>, <model>, <light> and <actor>.

Personally, I like using ERB (sudo apt install ruby2.3 ruby2.3-dev or the latest available version):


  # Relative path from where the script is being run to the script's directory
  DIR = File.dirname(__FILE__)

  # Helper function to import another erb file
  def fromFile filename
    return ERB.new(File.read(filename), nil, nil, '_sub01').result(binding)

<model name="model_name">
    <%= fromFile(DIR + "/link1.erb") %>
    <%= fromFile(DIR + "/link2.erb") %>
    <%= fromFile(DIR + "/link3.erb") %>


<link name="link1">

Then run erb model.erb > model.sdf.