Node that provides a time service to keep other nodes in sync. More...
#include <time_server.h>
Public Member Functions | |
TimeServer () | |
Private Member Functions | |
void | init () |
Initializes the node. | |
bool | service (time_server::time_srv::Request &req, time_server::time_srv::Response &res) |
Callback for time service request. | |
Private Attributes | |
ros::NodeHandle | n_ |
ros::Duration | offset_ |
ros::ServiceServer | service_ |
Node that provides a time service to keep other nodes in sync.
The clock starts at 0, and begins the first time the service is called.
Definition at line 21 of file time_server.h.
TimeServer::TimeServer | ( | ) | [inline] |
Definition at line 24 of file time_server.h.
void TimeServer::init | ( | ) | [private] |
Initializes the node.
Advertises the service and starts the spin loop.
Definition at line 14 of file time_server.cpp.
bool TimeServer::service | ( | time_server::time_srv::Request & | req, |
time_server::time_srv::Response & | res | ||
) | [private] |
Callback for time service request.
This method is called automatically when the node receives a service request. The node responds with the current clock time and the difference between the request time and the actual time.
If this is the first request received, the node starts its clock (from 0).
req | the client request |
res | the server response |
Definition at line 33 of file time_server.cpp.
ros::NodeHandle TimeServer::n_ [private] |
Definition at line 31 of file time_server.h.
ros::Duration TimeServer::offset_ [private] |
Definition at line 33 of file time_server.h.
ros::ServiceServer TimeServer::service_ [private] |
Definition at line 32 of file time_server.h.