0
我使用SFINEA訂閱到ROS通用主題,偵聽每一個主題,並使用SFINEA如果存在返回header.stamp
時間。這反序列化的速度更快。唯一的問題是我有一個問題讓我的訂戶設置。我不斷收到以下編譯錯誤:SFINAE模板錯誤
CMakeFiles/performance_tracker.dir/src/performance_tracker.cpp.o:
In function PerformanceTracker::topicCallback(boost::shared_ptr<topic_tools::ShapeShifter>)
ros/src/performance_tracker/src/performance_tracker.cpp:32:
undefined reference to boost::disable_if<timewarp::has_header<boost::shared_ptr<topic_tools::ShapeShifter> >, ros::Time>::type
timewarp::extractTime<boost::shared_ptr<topic_tools::ShapeShifter> >(boost::shared_ptr<topic_tools::ShapeShifter>)
主要
// Subscribe To Generic Message
_sub = _nh.subscribe(_topicName, 1, &PerformanceTracker::topicCallback, this);
void PerformanceTracker::topicCallback(const boost::shared_ptr<topic_tools::ShapeShifter> data){
//Current Time
ros::Time begin = ros::Time::now();
ros::Time timePublished = timewarp::extractTime<boost::shared_ptr<topic_tools::ShapeShifter>>(data);
}
Namespace類
namespace timewarp
{
template <typename T>
struct has_header {
typedef char yes[1];
typedef char no[2];
template <typename C>
static yes& test(typename C::_header_type*);
template <typename>
static no& test(...);
// If the "sizeof" the result of calling test<T>(0) would be equal to the sizeof(yes),
static const bool value = sizeof(test<T>(0)) == sizeof(yes);
};
template<class MsgType>
typename boost::enable_if<has_header<MsgType>, ros::Time>::type extractTime(const boost::shared_ptr<topic_tools::ShapeShifter> data)
{
boost::shared_ptr<MsgType> ptr = data->instantiate<MsgType>();
assert(ptr);
return ptr->header.stamp;
}
template<class MsgType>
typename boost::disable_if<has_header<MsgType>, ros::Time>::type extractTime(const boost::shared_ptr<topic_tools::ShapeShifter>);
}
這是有道理的,但我把'提高:: shared_ptr的< topic_tools :: ShapeShifter>'作爲我的SFINAE方法中的數據類型,那麼爲什麼傳遞通用'topic_tools :: ShapeShifter'工作? – DaynaJuliana
另外第二個'返回錯誤:const的ROS之前預期基本表達式::時間timePublished =時間扭曲:: extractTime(常量升壓:: shared_ptr的&數據);' –
DaynaJuliana
,第一個返回相同的錯誤。這是一個鏈接問題? – DaynaJuliana