Apollo 10.0
自动驾驶开放平台
apollo::cyber::ApolloRosMessageConverter< InputTypes< std::shared_ptr< InType0 >, std::shared_ptr< InType1 >, std::shared_ptr< InType2 > >, OutputTypes< std::shared_ptr< OutType0 >, std::shared_ptr< OutType1 >, std::shared_ptr< OutType2 > > > 模板类 参考abstract

#include <convert_apollo_triple.h>

类 apollo::cyber::ApolloRosMessageConverter< InputTypes< std::shared_ptr< InType0 >, std::shared_ptr< InType1 >, std::shared_ptr< InType2 > >, OutputTypes< std::shared_ptr< OutType0 >, std::shared_ptr< OutType1 >, std::shared_ptr< OutType2 > > > 继承关系图:
apollo::cyber::ApolloRosMessageConverter< InputTypes< std::shared_ptr< InType0 >, std::shared_ptr< InType1 >, std::shared_ptr< InType2 > >, OutputTypes< std::shared_ptr< OutType0 >, std::shared_ptr< OutType1 >, std::shared_ptr< OutType2 > > > 的协作图:

Public 成员函数

 ApolloRosMessageConverter ()
 
 ~ApolloRosMessageConverter () override
 
bool Init () override
 
- Public 成员函数 继承自 apollo::cyber::MessageConverter
 MessageConverter ()
 
virtual ~MessageConverter ()
 
bool IsInit () const
 

Protected 成员函数

virtual bool ConvertMsg (InputTypes< std::shared_ptr< InType0 >, std::shared_ptr< InType1 >, std::shared_ptr< InType2 > > &input, OutputTypes< std::shared_ptr< OutType0 >, std::shared_ptr< OutType1 >, std::shared_ptr< OutType2 > > &output)=0
 
- Protected 成员函数 继承自 apollo::cyber::MessageConverter
bool LoadConfig (ConverterConf *config)
 

额外继承的成员函数

- Protected 属性 继承自 apollo::cyber::MessageConverter
std::atomic< bool > init_
 
std::unique_ptr< apollo::cyber::Nodecyber_node_
 
std::vector< std::shared_ptr< apollo::cyber::proto::RoleAttributes > > apollo_attrs_
 
std::vector< std::shared_ptr< apollo::cyber::ReaderBase > > apollo_readers_
 
std::vector< std::shared_ptr< apollo::cyber::WriterBase > > apollo_writers_
 
const std::string node_name_ = "converter_base"
 
ConverterConf converter_conf_
 

详细描述

template<typename InType0, typename InType1, typename InType2, typename OutType0, typename OutType1, typename OutType2>
class apollo::cyber::ApolloRosMessageConverter< InputTypes< std::shared_ptr< InType0 >, std::shared_ptr< InType1 >, std::shared_ptr< InType2 > >, OutputTypes< std::shared_ptr< OutType0 >, std::shared_ptr< OutType1 >, std::shared_ptr< OutType2 > > >

在文件 convert_apollo_triple.h223 行定义.

构造及析构函数说明

◆ ApolloRosMessageConverter()

template<typename InType0 , typename InType1 , typename InType2 , typename OutType0 , typename OutType1 , typename OutType2 >
apollo::cyber::ApolloRosMessageConverter< InputTypes< std::shared_ptr< InType0 >, std::shared_ptr< InType1 >, std::shared_ptr< InType2 > >, OutputTypes< std::shared_ptr< OutType0 >, std::shared_ptr< OutType1 >, std::shared_ptr< OutType2 > > >::ApolloRosMessageConverter ( )
inline

在文件 convert_apollo_triple.h229 行定义.

229{}

◆ ~ApolloRosMessageConverter()

template<typename InType0 , typename InType1 , typename InType2 , typename OutType0 , typename OutType1 , typename OutType2 >
apollo::cyber::ApolloRosMessageConverter< InputTypes< std::shared_ptr< InType0 >, std::shared_ptr< InType1 >, std::shared_ptr< InType2 > >, OutputTypes< std::shared_ptr< OutType0 >, std::shared_ptr< OutType1 >, std::shared_ptr< OutType2 > > >::~ApolloRosMessageConverter ( )
inlineoverride

在文件 convert_apollo_triple.h230 行定义.

230{}

成员函数说明

◆ ConvertMsg()

template<typename InType0 , typename InType1 , typename InType2 , typename OutType0 , typename OutType1 , typename OutType2 >
virtual bool apollo::cyber::ApolloRosMessageConverter< InputTypes< std::shared_ptr< InType0 >, std::shared_ptr< InType1 >, std::shared_ptr< InType2 > >, OutputTypes< std::shared_ptr< OutType0 >, std::shared_ptr< OutType1 >, std::shared_ptr< OutType2 > > >::ConvertMsg ( InputTypes< std::shared_ptr< InType0 >, std::shared_ptr< InType1 >, std::shared_ptr< InType2 > > &  input,
OutputTypes< std::shared_ptr< OutType0 >, std::shared_ptr< OutType1 >, std::shared_ptr< OutType2 > > &  output 
)
protectedpure virtual

◆ Init()

template<typename InType0 , typename InType1 , typename InType2 , typename OutType0 , typename OutType1 , typename OutType2 >
bool apollo::cyber::ApolloRosMessageConverter< InputTypes< std::shared_ptr< InType0 >, std::shared_ptr< InType1 >, std::shared_ptr< InType2 > >, OutputTypes< std::shared_ptr< OutType0 >, std::shared_ptr< OutType1 >, std::shared_ptr< OutType2 > > >::Init ( )
overridevirtual

重载 apollo::cyber::MessageConverter .

在文件 convert_apollo_triple.h248 行定义.

248 {
250 if (!init_.load()) {
251 return false;
252 }
254 return false;
255 }
256
257 apollo::cyber::ReaderConfig reader_cfg_0;
259
260 apollo::cyber::ReaderConfig reader_cfg_1;
262 auto apollo_reader_1 =
263 cyber_node_->template CreateReader<InType1>(reader_cfg_1);
264
265 apollo::cyber::ReaderConfig reader_cfg_2;
267 auto apollo_reader_2 =
268 cyber_node_->template CreateReader<InType2>(reader_cfg_2);
269
270 auto apollo_blocker_1 =
271 blocker::BlockerManager::Instance()->GetBlocker<InType1>(
272 reader_cfg_1.channel_name);
273 auto apollo_blocker_2 =
274 blocker::BlockerManager::Instance()->GetBlocker<InType2>(
275 reader_cfg_2.channel_name);
276
277 std::string ros_topic_name_0 = converter_conf_.ros_topic_name_0();
278 std::string ros_topic_name_1 = converter_conf_.ros_topic_name_1();
279 std::string ros_topic_name_2 = converter_conf_.ros_topic_name_2();
280
281#ifdef RCLCPP__RCLCPP_HPP_
282 auto ros_publisher_0 =
283 ros_node_->create_publisher<OutType0>(ros_topic_name_0, 10);
284 auto ros_publisher_1 =
285 ros_node_->create_publisher<OutType1>(ros_topic_name_1, 10);
286 auto ros_publisher_2 =
287 ros_node_->create_publisher<OutType2>(ros_topic_name_2, 10);
288 ros_publishers_.push_back(std::move(ros_publisher_0));
289 ros_publishers_.push_back(std::move(ros_publisher_1));
290 ros_publishers_.push_back(std::move(ros_publisher_2));
291 auto func = [this, apollo_blocker_1, apollo_blocker_2, ros_publisher_0,
292 ros_publisher_1,
293 ros_publisher_2](const std::shared_ptr<InType0> in) {
294#else
295 auto func = [this, apollo_blocker_1,
296 apollo_blocker_2](const std::shared_ptr<InType0> in) {
297#endif
298 if (!apollo_blocker_1->IsPublishedEmpty() &&
299 !apollo_blocker_1->IsPublishedEmpty()) {
300 auto msg1 = apollo_blocker_1->GetLatestPublishedPtr();
301 auto msg2 = apollo_blocker_2->GetLatestPublishedPtr();
302 auto out_0 = std::make_shared<OutType0>();
303 auto out_1 = std::make_shared<OutType1>();
304 auto out_2 = std::make_shared<OutType2>();
305 auto in_container =
306 InputTypes<std::shared_ptr<InType0>, std::shared_ptr<InType1>,
307 std::shared_ptr<InType2>>{std::make_tuple(in, msg1, msg2)};
308 auto out_container =
309 OutputTypes<std::shared_ptr<OutType0>, std::shared_ptr<OutType1>,
310 std::shared_ptr<OutType2>>{
311 std::make_tuple(out_0, out_1, out_2)};
312 this->ConvertMsg(in_container, out_container);
313#ifdef RCLCPP__RCLCPP_HPP_
314 ros_publisher_0->publish(*out_0);
315 ros_publisher_1->publish(*out_1);
316 ros_publisher_2->publish(*out_2);
317#endif
318 }
319 };
320 auto apollo_reader_0 =
321 cyber_node_->template CreateReader<InType0>(reader_cfg_0, func);
322 apollo_readers_.push_back(std::move(apollo_reader_0));
323 apollo_readers_.push_back(std::move(apollo_reader_1));
324 apollo_readers_.push_back(std::move(apollo_reader_2));
325
326 return true;
327}
virtual bool ConvertMsg(InputTypes< std::shared_ptr< InType0 >, std::shared_ptr< InType1 >, std::shared_ptr< InType2 > > &input, OutputTypes< std::shared_ptr< OutType0 >, std::shared_ptr< OutType1 >, std::shared_ptr< OutType2 > > &output)=0
std::unique_ptr< apollo::cyber::Node > cyber_node_
std::vector< std::shared_ptr< apollo::cyber::ReaderBase > > apollo_readers_
bool LoadConfig(ConverterConf *config)
static const std::shared_ptr< BlockerManager > & Instance()

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