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

#include <convert_apollo_double.h>

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

在文件 convert_apollo_double.h282 行定义.

构造及析构函数说明

◆ ApolloRosMessageConverter()

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

在文件 convert_apollo_double.h288 行定义.

288{}

◆ ~ApolloRosMessageConverter()

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

在文件 convert_apollo_double.h289 行定义.

289{}

成员函数说明

◆ ConvertMsg()

template<typename InType0 , typename InType1 , typename OutType0 , typename OutType1 , typename OutType2 , typename OutType3 >
virtual bool apollo::cyber::ApolloRosMessageConverter< InputTypes< std::shared_ptr< InType0 >, std::shared_ptr< InType1 > >, 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 > > &  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 OutType0 , typename OutType1 , typename OutType2 , typename OutType3 >
bool apollo::cyber::ApolloRosMessageConverter< InputTypes< std::shared_ptr< InType0 >, std::shared_ptr< InType1 > >, OutputTypes< std::shared_ptr< OutType0 >, std::shared_ptr< OutType1 >, std::shared_ptr< OutType2 >, std::shared_ptr< OutType3 > > >::Init ( )
overridevirtual

重载 apollo::cyber::MessageConverter .

在文件 convert_apollo_double.h306 行定义.

306 {
308 if (!init_.load()) {
309 return false;
310 }
312 return false;
313 }
314
315 apollo::cyber::ReaderConfig reader_cfg_0;
317
318 apollo::cyber::ReaderConfig reader_cfg_1;
320 auto apollo_reader_1 =
321 cyber_node_->template CreateReader<InType1>(reader_cfg_1);
322
323 auto apollo_blocker_1 =
324 blocker::BlockerManager::Instance()->GetBlocker<InType1>(
325 reader_cfg_1.channel_name);
326
327 std::string ros_topic_name_0 = converter_conf_.ros_topic_name_0();
328 std::string ros_topic_name_1 = converter_conf_.ros_topic_name_1();
329 std::string ros_topic_name_2 = converter_conf_.ros_topic_name_2();
330 std::string ros_topic_name_3 = converter_conf_.ros_topic_name_3();
331
332#ifdef RCLCPP__RCLCPP_HPP_
333 auto ros_publisher_0 =
334 ros_node_->create_publisher<OutType0>(ros_topic_name_0, 10);
335 auto ros_publisher_1 =
336 ros_node_->create_publisher<OutType1>(ros_topic_name_1, 10);
337 auto ros_publisher_2 =
338 ros_node_->create_publisher<OutType2>(ros_topic_name_2, 10);
339 auto ros_publisher_3 =
340 ros_node_->create_publisher<OutType2>(ros_topic_name_3, 10);
341 ros_publishers_.push_back(std::move(ros_publisher_0));
342 ros_publishers_.push_back(std::move(ros_publisher_1));
343 ros_publishers_.push_back(std::move(ros_publisher_2));
344 ros_publishers_.push_back(std::move(ros_publisher_3));
345 auto func = [this, apollo_blocker_1, ros_publisher_0, ros_publisher_1,
346 ros_publisher_2,
347 ros_publisher_3](const std::shared_ptr<InType0> in) {
348#else
349 auto func = [this, apollo_blocker_1](const std::shared_ptr<InType0> in) {
350#endif
351 if (!apollo_blocker_1->IsPublishedEmpty()) {
352 auto msg1 = apollo_blocker_1->GetLatestPublishedPtr();
353 auto out_0 = std::make_shared<OutType0>();
354 auto out_1 = std::make_shared<OutType1>();
355 auto out_2 = std::make_shared<OutType2>();
356 auto out_3 = std::make_shared<OutType3>();
357 auto in_container =
358 InputTypes<std::shared_ptr<InType0>, std::shared_ptr<InType1>>{
359 std::make_tuple(in, msg1)};
360 auto out_container =
361 OutputTypes<std::shared_ptr<OutType0>, std::shared_ptr<OutType1>,
362 std::shared_ptr<OutType2>, std::shared_ptr<OutType3>>{
363 std::make_tuple(out_0, out_1, out_2, out_3)};
364 this->ConvertMsg(in_container, out_container);
365#ifdef RCLCPP__RCLCPP_HPP_
366 ros_publisher_0->publish(*out_0);
367 ros_publisher_1->publish(*out_1);
368 ros_publisher_2->publish(*out_2);
369 ros_publisher_3->publish(*out_2);
370#endif
371 }
372 };
373 auto apollo_reader_0 =
374 cyber_node_->template CreateReader<InType0>(reader_cfg_0, func);
375 apollo_readers_.push_back(std::move(apollo_reader_0));
376 apollo_readers_.push_back(std::move(apollo_reader_1));
377
378 return true;
379}
virtual bool ConvertMsg(InputTypes< std::shared_ptr< InType0 >, std::shared_ptr< InType1 > > &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()

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