FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
OBJECTS section

The <OBJECTS> section declares the SimObjects that participate in the simulation. Each SimObject is loaded from a shared library at runtime.

Syntax

Each SimObject is specified by a <Lib /> tag with the following attributes:

Attribute Required Description
LibName Yes Name of the shared library containing the SimObject implementation (without platform-specific prefix/suffix).
SimObject Yes The type name of the SimObject within the library.
Name Yes A unique instance name for this SimObject. Used to reference it in other sections.
*(any other)* No SimObject-specific parameters. Names and types must match the implementation.
<OBJECTS>
<Lib LibName="fhsim_base" SimObject="Body/Mass" Name="mass"
Mass="2000"
Material="Simple/Black"
Scale="0.70"
/>
<Lib LibName="fhsim_base" SimObject="Cable/LinearSpring" Name="spring"
Stiffness="500"
RelaxedLength="2.0"
/>
</OBJECTS>
Note
<Lib> is the only element type the object loader understands. Any other element inside <OBJECTS> is read and then rejected with "The simulation object of class ... was not found."

How it works

  • Parameters: The parameters which are specific to a type of SimObject should be described in the documentation for that SimObject. Parameter names and types must match the implementation. If a SimObject has a numeric parameter called Mass, then Mass="20.0" is valid. Parameters with a default value in the implementation can be omitted. A parameter given twice on the same element keeps the last value and logs a warning.
  • Variable substitution and arithmetic: Every attribute here — LibName and Name included — goes through $Variable substitution and then the arithmetic evaluator, so Mass="2*1000" is valid. See VARIABLES section and Arithmetic in attribute values for the exact rules.

How LibName is resolved

LibName is not searched for on a system library path. It is turned into a relative file path and looked up against the working directory, which is the directory FhSim has selected at startup — see Path resolution.

  1. Directory. If LibName contains a / or \, everything before the last one is used as the directory. Otherwise the directory is the literal subdirectory SimObjectLibraries.
  2. Decoration. The remaining name is decorated unless it already ends in .dll (Windows) or .so (Linux). The build configuration appends, in order: Vis for a visualisation build, _static for a static build, _d for a debug build, and then the platform extension. On Linux the prefix lib is added.
  3. Two candidates. FhSim then tries the decorated name, and if that file does not exist, the same name with fhsim_ inserted before it. If neither exists the run stops with an error naming both paths tried.

Because of step 3, LibName="base" and LibName="fhsim_base" both find the same library: a release Linux build without visualisation tries SimObjectLibraries/libbase.so and then SimObjectLibraries/libfhsim_base.so. The examples in this manual use the full fhsim_base spelling.

Note
Decoration means a library must match the FhSim build configuration. On Windows, LibName="fhsim_base" resolves to fhsim_baseVis_d.dll from a debug visualisation build, fhsim_baseVis.dll from a release visualisation build and fhsim_base.dll from a release build without visualisation. Mixing variants in one installation does not work.

See also