bipedal locomotion framework
A suite of libraries for achieving bipedal locomotion on humanoid robots
BipedalLocomotion::System::RosClock Class Referencefinal

RosClock implements the IClock interface using ros functions. More...

#include <System/RosImplementation/include/BipedalLocomotion/System/RosClock.h>

Public Member Functions

std::chrono::nanoseconds now () final
 Get ROS current time. More...
 
void sleepFor (const std::chrono::nanoseconds &sleepDuration) final
 Blocks the execution of the current thread for at least the specified sleepDuration. More...
 
void sleepUntil (const std::chrono::nanoseconds &sleepTime) final
 Blocks the execution of the current thread until specified sleepTime has been reached. More...
 
void yield () final
 Provides a hint to the implementation to reschedule the execution of threads, allowing other threads to run.
 
- Public Member Functions inherited from BipedalLocomotion::System::IClock
virtual ~IClock ()=default
 Destructor.
 

Additional Inherited Members

- Protected Member Functions inherited from BipedalLocomotion::System::IClock
 IClock ()=default
 The constructor is protected. More...
 

Detailed Description

RosClock implements the IClock interface using ros functions.

The clock can be easily used as follows

#include <chrono>
#include <memory>
int main(int argc, char *argv[])
{
// Change the clock
BipedalLocomotion::System::ClockBuilder::setFactory(std::make_shared<BipedalLocomotion::System::RosClockFactory>(argc, argv));
// Add a sleep
auto start = BipedalLocomotion::clock().now();
foo();
auto end = BipedalLocomotion::clock().now();
std::chrono::duration<double, std::milli> elapsed = end - start;
return 0;
}
static bool setFactory(std::shared_ptr< ClockFactory > factory)
Set a custom factory.
Definition: Clock.cpp:19
virtual void sleepFor(const std::chrono::nanoseconds &sleepDuration)=0
Blocks the execution of the current thread for at least the specified sleepDuration.
virtual std::chrono::nanoseconds now()=0
Get the current time.
System::IClock & clock()
Get the clock singleton.
Definition: Clock.cpp:11

Member Function Documentation

◆ now()

std::chrono::nanoseconds RosClock::now ( )
finalvirtual

Get ROS current time.

Returns
the current time computed from rclcpp::Clock::now()
Note
BipedalLocomotion::clock().now().count() returns a double containing the seconds since epoch.

Implements BipedalLocomotion::System::IClock.

◆ sleepFor()

void RosClock::sleepFor ( const std::chrono::nanoseconds &  sleepDuration)
finalvirtual

Blocks the execution of the current thread for at least the specified sleepDuration.

Parameters
timeduration to sleep

Implements BipedalLocomotion::System::IClock.

◆ sleepUntil()

void RosClock::sleepUntil ( const std::chrono::nanoseconds &  sleepTime)
finalvirtual

Blocks the execution of the current thread until specified sleepTime has been reached.

Parameters
timeto block until

Implements BipedalLocomotion::System::IClock.


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