forked from Archive/PX4-Autopilot
fix timesync for timestamp sample (including SFINAE detection)
This commit is contained in:
parent
ecf2cd3afb
commit
e4f235001b
|
@ -109,8 +109,11 @@ void RtpsTopics::publish(uint8_t topic_ID, char data_buffer[], size_t len)
|
|||
@[ end if]@
|
||||
// apply timestamp offset
|
||||
uint64_t timestamp = getMsgTimestamp(&st);
|
||||
uint64_t timestamp_sample = getMsgTimestampSample(&st);
|
||||
_timesync->subtractOffset(timestamp);
|
||||
setMsgTimestamp(&st, timestamp);
|
||||
_timesync->subtractOffset(timestamp_sample);
|
||||
setMsgTimestampSample(&st, timestamp_sample);
|
||||
_@(topic)_pub.publish(&st);
|
||||
@[ if topic == 'Timesync' or topic == 'timesync']@
|
||||
}
|
||||
|
|
|
@ -120,10 +120,13 @@ private:
|
|||
// SFINAE
|
||||
template<typename T> struct hasTimestampSample{
|
||||
private:
|
||||
static void detect(...);
|
||||
template<typename U> static decltype(std::declval<U>().timestamp_sample()) detect(const U&);
|
||||
template<typename U,
|
||||
typename = decltype(std::declval<U>().timestamp_sample(int64_t()))>
|
||||
static std::true_type detect(int);
|
||||
template<typename U>
|
||||
static std::false_type detect(...);
|
||||
public:
|
||||
static constexpr bool value = std::is_same<uint64_t, decltype(detect(std::declval<T>()))>::value;
|
||||
static constexpr bool value = decltype(detect<T>(0))::value;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
|
Loading…
Reference in New Issue