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

#include <convert_apollo_quadruple.h>

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

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 >, std::shared_ptr< InType3 > > &input, OutputTypes< std::shared_ptr< OutType0 >, std::shared_ptr< OutType1 >, std::shared_ptr< OutType2 >, std::shared_ptr< OutType3 > > &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 InType3, typename OutType0, typename OutType1, typename OutType2, typename OutType3>
class apollo::cyber::ApolloRosMessageConverter< InputTypes< std::shared_ptr< InType0 >, std::shared_ptr< InType1 >, std::shared_ptr< InType2 >, std::shared_ptr< InType3 > >, OutputTypes< std::shared_ptr< OutType0 >, std::shared_ptr< OutType1 >, std::shared_ptr< OutType2 >, std::shared_ptr< OutType3 > > >

在文件 convert_apollo_quadruple.h373 行定义.

构造及析构函数说明

◆ ApolloRosMessageConverter()

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

在文件 convert_apollo_quadruple.h380 行定义.

380{}

◆ ~ApolloRosMessageConverter()

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

在文件 convert_apollo_quadruple.h381 行定义.

381{}

成员函数说明

◆ ConvertMsg()

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

◆ Init()

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

重载 apollo::cyber::MessageConverter .

在文件 convert_apollo_quadruple.h401 行定义.

401 {
403 if (!init_.load()) {
404 return false;
405 }
407 return false;
408 }
409
410 apollo::cyber::ReaderConfig reader_cfg_0;
412
413 apollo::cyber::ReaderConfig reader_cfg_1;
415 auto apollo_reader_1 =
416 cyber_node_->template CreateReader<InType1>(reader_cfg_1);
417
418 apollo::cyber::ReaderConfig reader_cfg_2;
420 auto apollo_reader_2 =
421 cyber_node_->template CreateReader<InType2>(reader_cfg_2);
422
423 apollo::cyber::ReaderConfig reader_cfg_3;
425 auto apollo_reader_3 =
426 cyber_node_->template CreateReader<InType3>(reader_cfg_3);
427
428 auto apollo_blocker_1 =
429 blocker::BlockerManager::Instance()->GetBlocker<InType1>(
430 reader_cfg_1.channel_name);
431 auto apollo_blocker_2 =
432 blocker::BlockerManager::Instance()->GetBlocker<InType2>(
433 reader_cfg_2.channel_name);
434 auto apollo_blocker_3 =
435 blocker::BlockerManager::Instance()->GetBlocker<InType3>(
436 reader_cfg_3.channel_name);
437
438 std::string ros_topic_name_0 = converter_conf_.ros_topic_name_0();
439 std::string ros_topic_name_1 = converter_conf_.ros_topic_name_1();
440 std::string ros_topic_name_2 = converter_conf_.ros_topic_name_2();
441 std::string ros_topic_name_3 = converter_conf_.ros_topic_name_3();
442
443#ifdef RCLCPP__RCLCPP_HPP_
444 auto ros_publisher_0 =
445 ros_node_->create_publisher<OutType0>(ros_topic_name_0, 10);
446 auto ros_publisher_1 =
447 ros_node_->create_publisher<OutType1>(ros_topic_name_1, 10);
448 auto ros_publisher_2 =
449 ros_node_->create_publisher<OutType2>(ros_topic_name_2, 10);
450 auto ros_publisher_3 =
451 ros_node_->create_publisher<OutType2>(ros_topic_name_3, 10);
452 ros_publishers_.push_back(std::move(ros_publisher_0));
453 ros_publishers_.push_back(std::move(ros_publisher_1));
454 ros_publishers_.push_back(std::move(ros_publisher_2));
455 ros_publishers_.push_back(std::move(ros_publisher_3));
456 auto func = [this, apollo_blocker_1, apollo_blocker_2, apollo_blocker_3,
457 ros_publisher_0, ros_publisher_1, ros_publisher_2,
458 ros_publisher_3](const std::shared_ptr<InType0> in) {
459#else
460 auto func = [this, apollo_blocker_1, apollo_blocker_2,
461 apollo_blocker_3](const std::shared_ptr<InType0> in) {
462#endif
463 if (!apollo_blocker_1->IsPublishedEmpty() &&
464 !apollo_blocker_2->IsPublishedEmpty() &&
465 !apollo_blocker_3->IsPublishedEmpty()) {
466 auto msg1 = apollo_blocker_1->GetLatestPublishedPtr();
467 auto msg2 = apollo_blocker_2->GetLatestPublishedPtr();
468 auto msg3 = apollo_blocker_3->GetLatestPublishedPtr();
469 auto out_0 = std::make_shared<OutType0>();
470 auto out_1 = std::make_shared<OutType1>();
471 auto out_2 = std::make_shared<OutType2>();
472 auto out_3 = std::make_shared<OutType3>();
473 auto in_container =
474 InputTypes<std::shared_ptr<InType0>, std::shared_ptr<InType1>,
475 std::shared_ptr<InType2>, std::shared_ptr<InType3>>{
476 std::make_tuple(in, msg1, msg2, msg3)};
477 auto out_container =
478 OutputTypes<std::shared_ptr<OutType0>, std::shared_ptr<OutType1>,
479 std::shared_ptr<OutType2>, std::shared_ptr<OutType3>>{
480 std::make_tuple(out_0, out_1, out_2, out_3)};
481 this->ConvertMsg(in_container, out_container);
482#ifdef RCLCPP__RCLCPP_HPP_
483 ros_publisher_0->publish(*out_0);
484 ros_publisher_1->publish(*out_1);
485 ros_publisher_2->publish(*out_2);
486 ros_publisher_3->publish(*out_2);
487#endif
488 }
489 };
490 auto apollo_reader_0 =
491 cyber_node_->template CreateReader<InType0>(reader_cfg_0, func);
492 apollo_readers_.push_back(std::move(apollo_reader_0));
493 apollo_readers_.push_back(std::move(apollo_reader_1));
494 apollo_readers_.push_back(std::move(apollo_reader_2));
495 apollo_readers_.push_back(std::move(apollo_reader_3));
496
497 return true;
498}
virtual bool ConvertMsg(InputTypes< std::shared_ptr< InType0 >, std::shared_ptr< InType1 >, std::shared_ptr< InType2 >, std::shared_ptr< InType3 > > &input, OutputTypes< std::shared_ptr< OutType0 >, std::shared_ptr< OutType1 >, std::shared_ptr< OutType2 >, std::shared_ptr< OutType3 > > &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()

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