ROSaic
Data Structures | Functions | Variables
io_comm_mosaic Namespace Reference

Data Structures

class  AbstractCallbackHandler
 
class  AsyncManager
 This is the central interface between this ROS driver and the mosaic receiver(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 configuration of the mosaic (and beyond) device(s) More...
 
class  Manager
 Interface (in C++ terms), that could be used for any I/O manager, synchronous and asynchronous alike. More...
 
class  mosaicMessage
 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, either using the TOW as transmitted with the SBF block, or using the current time. More...
 

Variables

static const uint32_t baudrates []
 Possible baudrates for mosaic. 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_mosaic::TimestampSBF ( uint32_t  TOW,
bool  use_GNSS 
)

Calculates the timestamp, in the Unix Epoch time format, either using the TOW as transmitted with the SBF block, or using the current time.

Parameters
[in]TOWNumber of milliseconds that elapsed since the beginning of the current GPS week as transmitted by the SBF block
[in]use_GNSS_timeIf 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 leap_seconds parameter accordingly as soon as the next leap second is inserted into the UTC time.

Definition at line 599 of file mosaicMessage.cpp.

References leap_seconds, string_utilities::ToDouble(), and parsing_utilities::UTCtoUnix().

Referenced by io_comm_mosaic::mosaicMessage::Read(), and StringValues_Initialize().

600 {
601  if (use_GNSS)
602  {
603  uint16_t hh = (TOW%(1000*60*60*24))/(60*60*1000);
604  uint16_t mm = ((TOW%(1000*60*60*24))-hh*(60*60*1000))/(60*1000);
605  uint16_t ss = ((TOW%(1000*60*60*24))-hh*(60*60*1000)-mm*(60*1000))/(1000);
606  uint16_t hs = ((TOW%(1000*60*60*24))-hh*(60*60*1000)-mm*(60*1000)-ss*1000)/10; // hundredths of a second
607  if (ss >= leap_seconds)
608  {
609  ss = ss - leap_seconds;
610  }
611  else
612  {
613  if (mm >= 1)
614  {
615  --mm;
616  ss = 60 - (leap_seconds - ss);
617  }
618  else
619  {
620  if (hh >= 1)
621  {
622  --hh;
623  mm = 59;
624  ss = 60 - (leap_seconds - ss);
625  }
626  else
627  {
628  hh = 23;
629  mm = 59;
630  ss = 60 - (leap_seconds - ss);
631  }
632  }
633  }
634  boost::format fmt = boost::format("%02u%02u%02u.%02u") % hh % mm % ss % hs;
635  std::string utc_string = fmt.str();
636  //ROS_DEBUG("UTC string is %s", utc_string.c_str());
637  double utc_double;
638  string_utilities::ToDouble(utc_string, utc_double);
639  time_t unix_time_seconds = parsing_utilities::UTCtoUnix(utc_double); // This only deals with full seconds.
640  uint32_t unix_time_nanoseconds = (static_cast<uint32_t>(utc_double*100)%100)*10000000; // This works since there are two digits after the decimal point in the utc_double.
641  ros::Time time_obj(unix_time_seconds, unix_time_nanoseconds);
642  return time_obj;
643  }
644  else
645  {
646  time_t time_now = time(NULL);
647  ros::Time time_obj((uint32_t) time_now, 0);
648  return time_obj;
649  }
650 }
bool ToDouble(const std::string &string, double &value)
Interprets the contents of "string" as a floating point number of type double, stores its value in "v...
time_t UTCtoUnix(double utc_double)
Converts UTC time from the without-colon-delimiter format, type double, to Unix Epoch time (a number-...
uint32_t leap_seconds
The number of leap seconds that have been inserted into the UTC time.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ baudrates

const uint32_t io_comm_mosaic::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 mosaic.

Definition at line 107 of file communication_core.hpp.

Referenced by io_comm_mosaic::Comm_IO::InitializeSerial().