Apollo 9.0
自动驾驶开放平台
apollo::cyber::PyChannelUtils类 参考

#include <py_cyber.h>

apollo::cyber::PyChannelUtils 的协作图:

静态 Public 成员函数

static std::string get_debugstring_by_msgtype_rawmsgdata (const std::string &msg_type, const std::string &rawmsgdata)
 
static std::string get_msgtype_by_channelname (const std::string &channel_name, uint8_t sleep_s=0)
 
static std::vector< std::string > get_active_channels (uint8_t sleep_s=2)
 
static std::unordered_map< std::string, std::vector< std::string > > get_channels_info (uint8_t sleep_s=2)
 

详细描述

在文件 py_cyber.h 第 338 行定义.

成员函数说明

◆ get_active_channels()

static std::vector< std::string > apollo::cyber::PyChannelUtils::get_active_channels ( uint8_t  sleep_s = 2)
inlinestatic

在文件 py_cyber.h 第 386 行定义.

386 {
387 auto topology = service_discovery::TopologyManager::Instance();
388 sleep(sleep_s);
389 auto channel_manager = topology->channel_manager();
390 std::vector<std::string> channels;
391 channel_manager->GetChannelNames(&channels);
392 return channels;
393 }

◆ get_channels_info()

static std::unordered_map< std::string, std::vector< std::string > > apollo::cyber::PyChannelUtils::get_channels_info ( uint8_t  sleep_s = 2)
inlinestatic

在文件 py_cyber.h 第 396 行定义.

396 {
397 auto topology = service_discovery::TopologyManager::Instance();
398 sleep(sleep_s);
399 std::vector<proto::RoleAttributes> tmpVec;
400 topology->channel_manager()->GetWriters(&tmpVec);
401 std::unordered_map<std::string, std::vector<std::string>> roles_info;
402
403 for (auto& attr : tmpVec) {
404 std::string channel_name = attr.channel_name();
405 std::string msgdata;
406 attr.SerializeToString(&msgdata);
407 roles_info[channel_name].emplace_back(msgdata);
408 }
409
410 tmpVec.clear();
411 topology->channel_manager()->GetReaders(&tmpVec);
412 for (auto& attr : tmpVec) {
413 std::string channel_name = attr.channel_name();
414 std::string msgdata;
415 attr.SerializeToString(&msgdata);
416 roles_info[channel_name].emplace_back(msgdata);
417 }
418 return roles_info;
419 }

◆ get_debugstring_by_msgtype_rawmsgdata()

static std::string apollo::cyber::PyChannelUtils::get_debugstring_by_msgtype_rawmsgdata ( const std::string &  msg_type,
const std::string &  rawmsgdata 
)
inlinestatic

在文件 py_cyber.h 第 343 行定义.

344 {
345 if (msg_type.empty()) {
346 AERROR << "parse rawmessage the msg_type is null";
347 return "";
348 }
349 if (rawmsgdata.empty()) {
350 AERROR << "parse rawmessage the rawmsgdata is null";
351 return "";
352 }
353
354 if (raw_msg_class_ == nullptr) {
355 auto rawFactory = message::ProtobufFactory::Instance();
356 raw_msg_class_ = rawFactory->GenerateMessageByType(msg_type);
357 }
358
359 if (raw_msg_class_ == nullptr) {
360 AERROR << "raw_msg_class_ is null";
361 return "";
362 }
363
364 if (!raw_msg_class_->ParseFromString(rawmsgdata)) {
365 AERROR << "Cannot parse the msg [ " << msg_type << " ]";
366 return "";
367 }
368
369 return raw_msg_class_->DebugString();
370 }
#define AERROR
Definition log.h:44

◆ get_msgtype_by_channelname()

static std::string apollo::cyber::PyChannelUtils::get_msgtype_by_channelname ( const std::string &  channel_name,
uint8_t  sleep_s = 0 
)
inlinestatic

在文件 py_cyber.h 第 372 行定义.

373 {
374 if (channel_name.empty()) {
375 AERROR << "channel_name is null";
376 return "";
377 }
378 auto topology = service_discovery::TopologyManager::Instance();
379 sleep(sleep_s);
380 auto channel_manager = topology->channel_manager();
381 std::string msg_type("");
382 channel_manager->GetMsgType(channel_name, &msg_type);
383 return msg_type;
384 }

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