Gazebo Sim

API Reference

10.6.0
TimelinePublisher Class Reference

Publishes messages and calls services at fixed points in simulation time, optionally looping. It plays a scripted sequence, such as joint position targets or velocity commands, without an external script. Keyframes follow simulation time, so pausing or stepping the simulation also pauses or steps the timeline, and the timeline starts over when the world is reset or the simulation time goes back. The timeline starts on the first unpaused step after the system is loaded, so a model spawned during the simulation starts its timeline when it appears. More...

#include <TimelinePublisher.hh>

Public Member Functions

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

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

Publishes messages and calls services at fixed points in simulation time, optionally looping. It plays a scripted sequence, such as joint position targets or velocity commands, without an external script. Keyframes follow simulation time, so pausing or stepping the simulation also pauses or steps the timeline, and the timeline starts over when the world is reset or the simulation time goes back. The timeline starts on the first unpaused step after the system is loaded, so a model spawned during the simulation starts its timeline when it appears.

System Parameters

  • <loop>: Whether the timeline starts over after <period> seconds. Defaults to false.
  • <period>: Length of the timeline in seconds. Defaults to the time of the last keyframe, so the last keyframe and the first keyframe of the next cycle fire on the same step. Must be greater than zero when looping. If the last keyframe is later than the period, the period is extended to it. If a step covers more than one cycle, for example because the period is shorter than the step, only the latest cycle fires.
  • <keyframe>: A point in the timeline. The time attribute is the time in seconds since the start of the timeline. This element can be repeated, and keyframes may be listed in any order. Keyframes with the same time fire in the order they are listed. Each keyframe contains any number of:
    • <output>: Message to publish. The topic attribute is the topic to publish on and the type attribute is the message type (e.g. gz.msgs.Double). The content of the element is the message in the protobuf text format.
    • <service>: Service to call. The name attribute is the service name, reqType and repType are the request and response message types, timeout is the timeout in milliseconds (defaults to 1000) and reqMsg is the request in the protobuf text format. Instead of the reqMsg attribute, a long request can be the content of the element. Service calls are made in order from a worker thread, so they never block the simulation, but their effect isn't tied to an exact step. When a new cycle starts, calls still waiting from before the previous cycle are dropped, so a slow service can't make the calls fall further and further behind. Calls still waiting when the world is reset are dropped. Removing the system waits for the call in progress, up to its timeout.

Example

Move a joint back and forth, repeating every 4 seconds:

<plugin filename="gz-sim-timeline-publisher-system"
name="systems::TimelinePublisher">
<loop>true</loop>
<period>4</period>
<keyframe time="0">
<output topic="/model/arm/joint/j1/0/cmd_pos" type="gz.msgs.Double">
data: 1.0
</output>
</keyframe>
<keyframe time="2">
<output topic="/model/arm/joint/j1/0/cmd_pos" type="gz.msgs.Double">
data: -1.0
</output>
</keyframe>
</plugin>

Constructor & Destructor Documentation

◆ TimelinePublisher()

Constructor.

◆ ~TimelinePublisher()

~TimelinePublisher ( )
override

Destructor.

Member Function Documentation

◆ Configure()

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

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.

◆ PreUpdate()

void PreUpdate ( const UpdateInfo &  _info,
EntityComponentManager &  _ecm 
)
overridevirtual

Implements ISystemPreUpdate.

◆ Reset()

void Reset ( const UpdateInfo &  _info,
EntityComponentManager &  _ecm 
)
overridevirtual

Implements ISystemReset.


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