Gazebo Sim

API Reference

9.0.0

Base class for a System. More...

#include <gz/sim/System.hh>

Public Types

using PriorityType = int32_t
 Signed integer type used for specifying priority of the execution order of PreUpdate and Update phases.
 

Public Member Functions

 System ()=default
 Constructor.
 
virtual ~System ()=default
 Destructor.
 

Static Public Attributes

static constexpr PriorityType kDefaultPriority = {0}
 Default priority value for execution order of the PreUpdate and Update phases.
 
static constexpr std::string_view kPriorityElementName
 Name of the XML element from which the priority value will be parsed.
 

Detailed Description

Base class for a System.

A System operates on Entities that have certain Components. A System will only operate on an Entity if it has all of the required Components.

Systems are executed in three phases, with each phase for a given step corresponding to the entities at time UpdateInfo::simTime:

  • PreUpdate
    • Has read-write access to world entities and components.
    • This is where systems say what they'd like to happen at time UpdateInfo::simTime.
    • Can be used to modify state before physics runs, for example for applying control signals or performing network syncronization.
  • Update
    • Has read-write access to world entities and components.
    • Used for physics simulation step (i.e., simulates what happens at time UpdateInfo::simTime).
  • PostUpdate
    • Has read-only access to world entities and components.
    • Captures everything that happened at time UpdateInfo::simTime.
    • Used to read out results at the end of a simulation step to be used for sensor or controller updates.

The PreUpdate and Update phases are executed sequentially in the same thread, while the PostUpdate phase is executed in parallel in multiple threads. The order of execution of PreUpdate and Update phases can be controlled by specifying a signed integer Priority value for the System in its XML configuration. The default Priority value is zero, and smaller values are executed earlier. Systems with the same Priority value are executed in the order in which they are loaded.

It's important to note that UpdateInfo::simTime does not refer to the current time, but the time reached after the PreUpdate and Update calls have finished. So, if any of the *Update functions are called with simulation paused, time does not advance, which means the time reached after PreUpdate and Update is the same as the starting time. This explains why UpdateInfo::simTime is initially 0 if simulation is started paused, while UpdateInfo::simTime is initially UpdateInfo::dt if simulation is started un-paused.

Member Typedef Documentation

◆ PriorityType

using PriorityType = int32_t

Signed integer type used for specifying priority of the execution order of PreUpdate and Update phases.

Constructor & Destructor Documentation

◆ System()

System ( )
default

Constructor.

◆ ~System()

virtual ~System ( )
virtualdefault

Destructor.

Member Data Documentation

◆ kDefaultPriority

constexpr PriorityType kDefaultPriority = {0}
staticconstexpr

Default priority value for execution order of the PreUpdate and Update phases.

◆ kPriorityElementName

constexpr std::string_view kPriorityElementName
staticconstexpr
Initial value:
=
{"gz:system_priority"}

Name of the XML element from which the priority value will be parsed.


The documentation for this class was generated from the following file: