Пример #1
0
void save_td(Archive& ar, const posix_time::time_duration& td)
{
    TimeResTraitsSize h = boost::numeric_cast<TimeResTraitsSize>(td.hours());
    TimeResTraitsSize m = boost::numeric_cast<TimeResTraitsSize>(td.minutes());
    TimeResTraitsSize s = boost::numeric_cast<TimeResTraitsSize>(td.seconds());
    posix_time::time_duration::fractional_seconds_type fs = td.fractional_seconds();
    ar & make_nvp("time_duration_hours", h);
    ar & make_nvp("time_duration_minutes", m);
    ar & make_nvp("time_duration_seconds", s);
    ar & make_nvp("time_duration_fractional_seconds", fs);
}
void save(Archive & ar, 
          const posix_time::time_duration& td, 
          unsigned int version)
{
  typename posix_time::time_duration::hour_type h = td.hours();
  typename posix_time::time_duration::min_type m = td.minutes();
  typename posix_time::time_duration::sec_type s = td.seconds();
  typename posix_time::time_duration::fractional_seconds_type fs = td.fractional_seconds();
  ar & make_nvp("time_duration_hours", h);
  ar & make_nvp("time_duration_minutes", m);
  ar & make_nvp("time_duration_seconds", s);
  ar & make_nvp("time_duration_fractional_seconds", fs);
}
Пример #3
0
posix_time::time_duration mul(
	const posix_time::time_duration &time,
	double rhs)
{
	return posix_time::time_duration(0, 0, 0,
		posix_time::time_duration::fractional_seconds_type(
			(double)time.ticks() * rhs + 0.5));
}
Пример #4
0
posix_time::time_duration div(
	const posix_time::time_duration &time,
	double divisor)
{
	return posix_time::time_duration(0, 0, 0,
		posix_time::time_duration::fractional_seconds_type(
			(double)time.ticks() / divisor + 0.5));
}
Пример #5
0
void save(Archive & ar, 
          const posix_time::time_duration& td, 
          unsigned int /*version*/)
{
  // serialize a bool so we know how to read this back in later
  bool is_special = td.is_special();
  ar & make_nvp("is_special", is_special);
  if(is_special) {
    std::string s = to_simple_string(td);
    ar & make_nvp("sv_time_duration", s);
  }
  else {
    typename posix_time::time_duration::hour_type h = td.hours();
    typename posix_time::time_duration::min_type m = td.minutes();
    typename posix_time::time_duration::sec_type s = td.seconds();
    typename posix_time::time_duration::fractional_seconds_type fs = td.fractional_seconds();
    ar & make_nvp("time_duration_hours", h);
    ar & make_nvp("time_duration_minutes", m);
    ar & make_nvp("time_duration_seconds", s);
    ar & make_nvp("time_duration_fractional_seconds", fs);
  }
}
Пример #6
0
static int getMicroseconds( const posix_time::time_duration &dur )
{
	static long ticksPerSecond = posix_time::time_duration::ticks_per_second();
	long fractionalSeconds = dur.fractional_seconds();

	static const int oneMillion = 1000000;

	/// Prevent over/underflow
	if ( ticksPerSecond > oneMillion )
	{
		return fractionalSeconds / ( ticksPerSecond / oneMillion );
	}
	else
	{
		return fractionalSeconds * ( oneMillion / ticksPerSecond );
	}
}
Пример #7
0
void save(Archive & ar, 
          const posix_time::time_duration& td, 
          unsigned int version)
{
  // serialize a bool so we know how to read this back in later
  bool is_special = td.is_special();
  ar & make_nvp("is_special", is_special);
  if(is_special) {
    std::string s = to_simple_string(td);
    ar & make_nvp("sv_time_duration", s);
  }
  else {
    // Write support for earlier versions allows for upgrade compatibility testing
    // See load comments for version information
    if (version == 0) {
        save_td<int32_t>(ar, td);
    } else {
        save_td<int64_t>(ar, td);
    }
  }
}
Пример #8
0
 /*!
  * Creates a rotation time interval of the specified duration
  *
  * \param interval The interval of the rotation, should be no less than 1 second
  */
 explicit rotation_at_time_interval(posix_time::time_duration const& interval) :
     m_Interval(interval)
 {
     BOOST_ASSERT(!interval.is_special());
     BOOST_ASSERT(interval.total_seconds() > 0);
 }
Пример #9
0
double div(
	const posix_time::time_duration &time1,
	const posix_time::time_duration &time2)
{
	return (double)time1.ticks() / (double)time2.ticks();
}
Пример #10
0
TransformerTF2::TransformerTF2(const posix_time::time_duration& cacheTime) :
		tfBuffer(ros::Duration().fromNSec(cacheTime.total_nanoseconds())) {

	tfBuffer._addTransformsChangedListener(bind(&TransformerTF2::tfChanged, this));
}