Apollo 10.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.h339 行定义.

成员函数说明

◆ get_active_channels()

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

在文件 py_cyber.h387 行定义.

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

◆ 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.h397 行定义.

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

◆ 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.h344 行定义.

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

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

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