可调用对象:function和bind用法
用法链接
std::function<void(px4_msgs::VehicleGpsPosition const* const)> gps_cb =
std::bind(&VinsOfflineSim::callbackGps, &agent, std::placeholders::_1);
bag_player.registerCallback(ktopic_opt_img, img_cb);
template <typename MsgType>
void registerCallback(std::string const &topic,
std::function<void(std::shared_ptr<MsgType>)> callback) {
std::shared_ptr<CallBackBaseRef<decltype(callback), std::shared_ptr<MsgType>>> cb(
new CallBackBaseRef<decltype(callback), std::shared_ptr<MsgType>>());
cb->f = callback;
mp_topic_2_callback_[topic] = cb;
subscribed_topics_.insert(topic);
}
|