Apollo 10.0
自动驾驶开放平台
apollo::perception::MsgConverter类 参考

#include <msg_converter.h>

apollo::perception::MsgConverter 的协作图:

Public 类型

template<class U , class V >
using Callback = bool(*)(const std::shared_ptr< U > &, V *)
 

Public 成员函数

 MsgConverter ()=default
 
 MsgConverter (const std::shared_ptr< cyber::Node > &node)
 
virtual ~MsgConverter ()=default
 
template<class From , class To >
bool Add (const std::string &from_topic, const std::string &to_topic, Callback< From, To > convert)
 

详细描述

在文件 msg_converter.h29 行定义.

成员类型定义说明

◆ Callback

template<class U , class V >
using apollo::perception::MsgConverter::Callback = bool(*)(const std::shared_ptr<U> &, V *)

在文件 msg_converter.h32 行定义.

构造及析构函数说明

◆ MsgConverter() [1/2]

apollo::perception::MsgConverter::MsgConverter ( )
default

◆ MsgConverter() [2/2]

apollo::perception::MsgConverter::MsgConverter ( const std::shared_ptr< cyber::Node > &  node)
inlineexplicit

在文件 msg_converter.h36 行定义.

37 : node_(node) {}

◆ ~MsgConverter()

virtual apollo::perception::MsgConverter::~MsgConverter ( )
virtualdefault

成员函数说明

◆ Add()

template<class From , class To >
bool apollo::perception::MsgConverter::Add ( const std::string &  from_topic,
const std::string &  to_topic,
Callback< From, To >  convert 
)

在文件 msg_converter.h53 行定义.

55 {
56 AINFO << "Convert: " << from_topic << " to " << to_topic;
57 auto writer = node_->CreateWriter<To>(to_topic);
58 auto reader = node_->CreateReader<From>(
59 from_topic, [=](const std::shared_ptr<From> &from) {
60 std::shared_ptr<To> to(new To());
61 bool res = convert(from, to.get());
62 if (res) {
63 writer->Write(to);
64 }
65 });
66
67 writers_.push_back(writer);
68 readers_.push_back(reader);
69 return true;
70}
#define AINFO
Definition log.h:42

该类的文档由以下文件生成: