Gazebo | Ignition | Community
Ask Your Question
0

splinting a complex SDF into several smaller SDFs.

asked 2018-12-17 08:16:32 -0600

I'm starting now and to facilitate my studies I would like to split SDF files into groups, separated by folders, but I do not want to create a template for each SDF.Is it possible in the same model I have several SDFs, and one main that I load is too?Thankful.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-12-17 10:54:51 -0600

chapulina gravatar image

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):

model.erb:

<%
  # 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)
  end
%>

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

link1.erb

<link name="link1">
 ...
</link>

Then run erb model.erb > model.sdf.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-12-17 08:16:32 -0600

Seen: 292 times

Last updated: Dec 17 '18