Gazebo Sim

API Reference

9.0.0
PythonSystemLoader Class Referencefinal

Allows systems to be written in Python. More...

#include <PythonSystemLoader.hh>

Public Member Functions

 ~PythonSystemLoader () final
 
void Configure (const Entity &_entity, const std::shared_ptr< const sdf::Element > &_sdf, EntityComponentManager &_ecm, EventManager &_eventMgr) final
 Configure the system.
 
void PostUpdate (const UpdateInfo &_info, const EntityComponentManager &_ecm) final
 
void PreUpdate (const UpdateInfo &_info, EntityComponentManager &_ecm) final
 
void Reset (const UpdateInfo &_info, EntityComponentManager &_ecm) final
 
void Update (const UpdateInfo &_info, EntityComponentManager &_ecm) final
 
- Public Member Functions inherited from System
 System ()=default
 Constructor.
 
virtual ~System ()=default
 Destructor.
 

Additional Inherited Members

- Public Types inherited from System
using PriorityType = int32_t
 Signed integer type used for specifying priority of the execution order of PreUpdate and Update phases.
 
- Static Public Attributes inherited from System
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

Allows systems to be written in Python.

The convention for a system written in Python supported by the PythonSystemLoader is that it's a Python module providing a get_system function which itself returns an instance of a class that implements the various interfaces in System. The spelling of the interfaces conforms to Python code style guides, so the following name mapping applies

  • configure : Corresponds to System::ISystemConfigure::Configure
  • pre_update : Corresponds to System::ISystemPreUpdate::PreUpdate
  • update : Corresponds to System::ISystemUpdate::Update
  • post_update : Corresponds to System::ISystemPostUpdate::PostUpdate
  • reset : Corresponds to System::ISystemReset::Reset

It is not necessary to implement all the interfaces. PythonSystemLoader will check if the corresponding method is implemented in the Python system and skip it if it's not found.

See examples/scripts/python_api/systems/test_system.py for an example

System Parameters

  • <module_name> : Name of python module to be loaded. The search path includes GZ_SIM_SYSTEM_PLUGIN_PATH as well as PYTHONPATH.

The contents of the <plugin> tag will be available in the configure method of the Python system

Constructor & Destructor Documentation

◆ ~PythonSystemLoader()

~PythonSystemLoader ( )
final

Member Function Documentation

◆ Configure()

void Configure ( const Entity _entity,
const std::shared_ptr< const sdf::Element > &  _sdf,
EntityComponentManager _ecm,
EventManager _eventMgr 
)
finalvirtual

Configure the system.

Parameters
[in]_entityThe entity this plugin is attached to.
[in]_sdfThe SDF Element associated with this system plugin.
[in]_ecmThe EntityComponentManager of the given simulation instance.
[in]_eventMgrThe EventManager of the given simulation instance.

Implements ISystemConfigure.

◆ PostUpdate()

void PostUpdate ( const UpdateInfo _info,
const EntityComponentManager _ecm 
)
finalvirtual

Implements ISystemPostUpdate.

◆ PreUpdate()

void PreUpdate ( const UpdateInfo _info,
EntityComponentManager _ecm 
)
finalvirtual

Implements ISystemPreUpdate.

◆ Reset()

void Reset ( const UpdateInfo _info,
EntityComponentManager _ecm 
)
finalvirtual

Implements ISystemReset.

◆ Update()

void Update ( const UpdateInfo _info,
EntityComponentManager _ecm 
)
finalvirtual

Implements ISystemUpdate.


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