我正在使用SFINEA订阅ROS中的通用主题,它会侦听每个主题,并使用SFINEA返回header.stamp
时间(如果存在)。这反复进行反序列化。唯一的问题是我在设置用户时遇到问题。我不断收到以下编译错误:
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 CLASS
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>);
}
答案 0 :(得分:1)
您将Runnable
类型称为MsgType传递给boost::shared_ptr<topic_tools::ShapeShifter>
而不是has_header<T>
。
我相信你想这样做:
topic_tools::ShapeShifter
使用const refs参数时,你可以使用它:)
ros::Time timePublished = timewarp::extractTime<topic_tools::ShapeShifter>(data);