ROSaic
Data Structures | Functions | Variables
io_comm_rx Namespace Reference

Data Structures

class  AbstractCallbackHandler
 
class  AsyncManager
 This is the central interface between ROSaic and the Rx(s), managing I/O operations such as reading messages and sending commands.. More...
 
class  CallbackHandler
 Abstract class representing a generic callback handler, includes high-level functionality such as wait. More...
 
class  CallbackHandlers
 Represents ensemble of (to be constructed) ROS messages, to be handled at once by this class. More...
 
class  Comm_IO
 Handles communication with and configuration of the mosaic (and beyond) receiver(s) More...
 
class  Manager
 Interface (in C++ terms), that could be used for any I/O manager, synchronous and asynchronous alike. More...
 
class  RxMessage
 Can search buffer for messages, read/parse them, and so on. More...
 

Functions

ros::Time timestampSBF (uint32_t tow, bool use_gnss)
 Calculates the timestamp, in the Unix Epoch time format This is either done using the TOW as transmitted with the SBF block (if "use_gnss" is true), or using the current time. More...
 

Variables

static const uint32_t BAUDRATES []
 Possible baudrates for the Rx. More...
 

Detailed Description

This namespace is for the communication interface, handling all aspects related to serial and TCP/IP communication..

Function Documentation

◆ timestampSBF()

ros::Time io_comm_rx::timestampSBF ( uint32_t  tow,
bool  use_gnss 
)

Calculates the timestamp, in the Unix Epoch time format This is either done using the TOW as transmitted with the SBF block (if "use_gnss" is true), or using the current time.

Parameters
[in]tow(Time of Week) Number of milliseconds that elapsed since the beginning of the current GPS week as transmitted by the SBF block
[in]use_gnssIf true, the TOW as transmitted with the SBF block is used, otherwise the current time
Returns
ros::Time object containing seconds and nanoseconds since last epoch

If the current time shall be employed, it is calculated via the time(NULL) function found in the <ctime> library At the time of writing the code (2020), the GPS time was ahead of UTC time by 18 (leap) seconds. Adapt the g_leap_seconds ROSaic parameter accordingly as soon as the next leap second is inserted into the UTC time.

Definition at line 768 of file rx_message.cpp.

References parsing_utilities::convertUTCtoUnix(), g_leap_seconds, and string_utilities::toDouble().

Referenced by io_comm_rx::RxMessage::read().

769 {
770  if (use_gnss)
771  {
772  uint16_t hh = (tow%(1000*60*60*24))/(60*60*1000);
773  uint16_t mm = ((tow%(1000*60*60*24))-hh*(60*60*1000))/(60*1000);
774  uint16_t ss = ((tow%(1000*60*60*24))-hh*(60*60*1000)-mm*(60*1000))/(1000);
775  uint16_t hs = ((tow%(1000*60*60*24))-hh*(60*60*1000)-mm*(60*1000)-ss*1000)/10; // hundredths of a second
776  if (ss >= g_leap_seconds)
777  {
778  ss = ss - g_leap_seconds;
779  }
780  else
781  {
782  if (mm >= 1)
783  {
784  --mm;
785  ss = 60 - (g_leap_seconds - ss);
786  }
787  else
788  {
789  if (hh >= 1)
790  {
791  --hh;
792  mm = 59;
793  ss = 60 - (g_leap_seconds - ss);
794  }
795  else
796  {
797  hh = 23;
798  mm = 59;
799  ss = 60 - (g_leap_seconds - ss);
800  }
801  }
802  }
803  boost::format fmt = boost::format("%02u%02u%02u.%02u") % hh % mm % ss % hs;
804  std::string utc_string = fmt.str();
805  //ROS_DEBUG("UTC string is %s", utc_string.c_str());
806  double utc_double;
807  string_utilities::toDouble(utc_string, utc_double);
808  time_t unix_time_seconds = parsing_utilities::convertUTCtoUnix(utc_double); // This only deals with full seconds.
809  // The following works since there are two digits after the decimal point in the utc_double:
810  uint32_t unix_time_nanoseconds = (static_cast<uint32_t>(utc_double*100)%100)*10000000;
811  ros::Time time_obj(unix_time_seconds, unix_time_nanoseconds);
812  return time_obj;
813  }
814  else
815  {
816  return ros::Time::now();
817  }
818 }
uint32_t g_leap_seconds
The number of leap seconds that have been inserted into the UTC time.
bool toDouble(const std::string &string, double &value)
Interprets the contents of "string" as a floating point number of type double It stores the "string"&#39;...
time_t convertUTCtoUnix(double utc_double)
Converts UTC time from the without-colon-delimiter format to Unix Epoch time (a number-of-seconds-sin...
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ BAUDRATES

const uint32_t io_comm_rx::BAUDRATES[]
static
Initial value:
= {1200, 2400, 4800, 9600, 19200, 38400, 57600,
115200, 230400, 460800, 500000, 576000, 921600,
1000000, 1152000, 1500000, 2000000, 2500000,
3000000, 3500000, 4000000}

Possible baudrates for the Rx.

Definition at line 93 of file communication_core.hpp.

Referenced by io_comm_rx::Comm_IO::initializeSerial().