Gazebo Transport

API Reference

14.0.0
NetworkClock Class Reference

A Clock interface implementation that uses gz::msgs::Clock messages distributed across the network. More...

#include <Clock.hh>

Public Types

enum class  TimeBase : int64_t { REAL , SIM , SYS }
 Network clock time bases. More...
 

Public Member Functions

 NetworkClock (const std::string &_topicName, const TimeBase _timeBase=TimeBase::SIM)
 Constructor that sets the initial time range option.
 
 ~NetworkClock () override
 Destructor.
 
bool IsReady () const override
 Checks whether the clock is ready to be used or not.
 
void SetTime (const std::chrono::nanoseconds _time)
 Sets and distributes the given clock time.
 
std::chrono::nanoseconds Time () const override
 Gets clock time.
 
- Public Member Functions inherited from Clock
virtual ~Clock ()=default
 Virtual destructor.
 

Detailed Description

A Clock interface implementation that uses gz::msgs::Clock messages distributed across the network.

Member Enumeration Documentation

◆ TimeBase

enum class TimeBase : int64_t
strong

Network clock time bases.

Enumerator
REAL 

Use Clock message real time field as time base.

SIM 

Use Clock message sim time field as time base.

SYS 

Use Clock message sys time field as time base.

Constructor & Destructor Documentation

◆ NetworkClock()

NetworkClock ( const std::string _topicName,
const TimeBase  _timeBase = TimeBase::SIM 
)
explicit

Constructor that sets the initial time range option.

Parameters
[in]_topicNameName of the gz::msgs::Clock type topic to be used
[in]_timeBaseTime base for this clock, defaults to simulation time

◆ ~NetworkClock()

~NetworkClock ( )
override

Destructor.

Member Function Documentation

◆ IsReady()

bool IsReady ( ) const
overridevirtual

Checks whether the clock is ready to be used or not.

Returns
True if clock is ready to be used, false otherwise

Implements Clock.

◆ SetTime()

void SetTime ( const std::chrono::nanoseconds  _time)

Sets and distributes the given clock time.

Parameters
[in]_timeThe clock time to be set
Remarks
No clock arbitration is performed

◆ Time()

std::chrono::nanoseconds Time ( ) const
overridevirtual

Gets clock time.

Returns
Current clock time, in nanoseconds

Implements Clock.


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