Apollo 11.0
自动驾驶开放平台
apollo::cyber 命名空间参考

命名空间

namespace  base
 
namespace  benchmark
 
namespace  binary
 
namespace  blocker
 
namespace  class_loader
 
namespace  common
 
namespace  context
 
namespace  croutine
 
namespace  data
 
namespace  event
 
namespace  examples
 
namespace  io
 
namespace  logger
 
namespace  mainboard
 
namespace  message
 
namespace  plugin_manager
 
namespace  profiler
 
namespace  proto
 
namespace  record
 
namespace  scheduler
 
namespace  service_discovery
 
namespace  statistics
 
namespace  transport
 

class  Client
 Client get Response from a responding Service by sending a Request 更多...
 
class  ClientBase
 Base class of Client 更多...
 
class  Clock
 a singleton clock that can be used to get the current timestamp. 更多...
 
class  Component
 
class  Component< M0, M1, M2, NullType >
 
class  Component< M0, M1, NullType, NullType >
 
class  Component< M0, NullType, NullType, NullType >
 
class  Component< NullType, NullType, NullType, NullType >
 
class  ComponentBase
 
class  Duration
 
class  Node
 Node is the fundamental building block of Cyber RT. 更多...
 
class  NodeChannelImpl
 The implementation for Node to create Objects connected by Channels. 更多...
 
class  NodeServiceImpl
 The implementation for Node to create Objects connected by Param. 更多...
 
class  NullType
 
class  Parameter
 A Parameter holds an apollo::cyber::proto::Param, It's more human-readable, you can use basic-value type and Protobuf values to construct a paramter. 更多...
 
class  ParameterClient
 Parameter Client is used to set/get/list parameter(s) by sending a request to ParameterServer 更多...
 
class  ParameterServer
 Parameter Service is a very important function of auto-driving. 更多...
 
class  PyChannelUtils
 
class  PyClient
 
class  PyDuration
 
class  PyNode
 
class  PyNodeUtils
 
class  PyParameter
 
class  PyParameterClient
 
class  PyParameterServer
 
class  PyRate
 
class  PyReader
 
class  PyService
 
class  PyServiceUtils
 
class  PyTime
 
class  PyTimer
 
class  PyWriter
 
class  Rate
 
class  Reader
 Reader subscribes a channel, it has two main functions: 更多...
 
class  ReaderBase
 Base Class for Reader Reader is identified by one apollo::cyber::proto::RoleAttribute, it contains the channel_name, channel_id that we subscribe, and host_name, process_id and node that we are located, and qos that describes our transportation quality. 更多...
 
struct  ReaderConfig
 
class  ReceiverManager
 One Channel is related to one Receiver. 更多...
 
class  Service
 Service handles Request from the Client, and send a Response to it. 更多...
 
class  ServiceBase
 Base class for Service 更多...
 
class  SysMo
 
class  TaskManager
 
class  Time
 Cyber has builtin time type Time. 更多...
 
class  Timer
 Used to perform oneshot or periodic timing tasks 更多...
 
class  TimerBucket
 
class  TimerComponent
 
struct  TimerOption
 The options of timer 更多...
 
struct  TimerTask
 
class  TimingWheel
 
class  Writer
 
class  WriterBase
 Base class for a Writer. 更多...
 

类型定义

template<typename M0 >
using CallbackFunc = std::function< void(const std::shared_ptr< M0 > &)>
 
using PyMsgWrapPtr = std::shared_ptr< message::PyMessageWrap >
 
using GlobalData = ::apollo::cyber::common::GlobalData
 
using AtomicRWLock = ::apollo::cyber::base::AtomicRWLock
 
using AtomicWriteLockGuard = ::apollo::cyber::base::WriteLockGuard< AtomicRWLock >
 
using AtomicReadLockGuard = ::apollo::cyber::base::ReadLockGuard< AtomicRWLock >
 

枚举

enum  ReturnCode { SUCC = 0 , FAIL = 1 }
 
enum  Relation : std::uint8_t { NO_RELATION = 0 , DIFF_HOST , DIFF_PROC , SAME_PROC }
 Describe relation between nodes, writers/readers... 更多...
 
enum  State : std::uint8_t { STATE_UNINITIALIZED = 0 , STATE_INITIALIZED , STATE_SHUTTING_DOWN , STATE_SHUTDOWN }
 

函数

std::unique_ptr< NodeCreateNode (const std::string &node_name, const std::string &name_space)
 
void OnShutdown (int sig)
 
void ExitHandle ()
 
bool Init (const char *binary_name, const std::string &dag_info)
 
void Clear ()
 
bool py_init (const std::string &module_name)
 
bool py_ok ()
 
void py_shutdown ()
 
bool py_is_shutdown ()
 
void py_waitforshutdown ()
 
State GetState ()
 
void SetState (const State &state)
 
bool OK ()
 
bool IsShutdown ()
 
void WaitForShutdown ()
 
void AsyncShutdown ()
 
std::ostream & operator<< (std::ostream &os, const Duration &rhs)
 
std::ostream & operator<< (std::ostream &os, const Time &rhs)
 

变量

const uint32_t DEFAULT_PENDING_QUEUE_SIZE = 1
 
constexpr auto SERVICE_NAME_DELIMITER = "/"
 
constexpr auto GET_PARAMETER_SERVICE_NAME = "get_parameter"
 
constexpr auto SET_PARAMETER_SERVICE_NAME = "set_parameter"
 
constexpr auto LIST_PARAMETERS_SERVICE_NAME = "list_parameters"
 
const char RAWDATATYPE [] = "RawData"
 

类型定义说明

◆ AtomicReadLockGuard

◆ AtomicRWLock

◆ AtomicWriteLockGuard

◆ CallbackFunc

template<typename M0 >
using apollo::cyber::CallbackFunc = typedef std::function<void(const std::shared_ptr<M0>&)>

在文件 reader.h46 行定义.

◆ GlobalData

◆ PyMsgWrapPtr

using apollo::cyber::PyMsgWrapPtr = typedef std::shared_ptr<message::PyMessageWrap>

在文件 py_cyber.h186 行定义.

枚举类型说明

◆ Relation

enum apollo::cyber::Relation : std::uint8_t

Describe relation between nodes, writers/readers...

枚举值
NO_RELATION 
DIFF_HOST 
DIFF_PROC 
SAME_PROC 

在文件 types.h36 行定义.

36 : std::uint8_t {
37 NO_RELATION = 0,
38 DIFF_HOST, // different host
39 DIFF_PROC, // same host, but different process
40 SAME_PROC, // same process
41};
@ NO_RELATION
Definition types.h:37

◆ ReturnCode

枚举值
SUCC 
FAIL 

在文件 types.h28 行定义.

28 {
29 SUCC = 0,
30 FAIL = 1,
31};

◆ State

enum apollo::cyber::State : std::uint8_t
枚举值
STATE_UNINITIALIZED 
STATE_INITIALIZED 
STATE_SHUTTING_DOWN 
STATE_SHUTDOWN 

在文件 state.h34 行定义.

34 : std::uint8_t {
39};
@ STATE_INITIALIZED
Definition state.h:36
@ STATE_SHUTDOWN
Definition state.h:38
@ STATE_SHUTTING_DOWN
Definition state.h:37
@ STATE_UNINITIALIZED
Definition state.h:35

函数说明

◆ AsyncShutdown()

void apollo::cyber::AsyncShutdown ( )
inline

在文件 state.h56 行定义.

56 {
57 pid_t pid = getpid();
58 if (kill(pid, SIGINT) != 0) {
59 AERROR << strerror(errno);
60 }
61}
#define AERROR
Definition log.h:44

◆ Clear()

void apollo::cyber::Clear ( )

在文件 init.cc154 行定义.

154 {
155 std::lock_guard<std::mutex> lg(g_mutex);
156 if (GetState() == STATE_SHUTDOWN || GetState() == STATE_UNINITIALIZED) {
157 return;
158 }
159 SysMo::CleanUp();
160 TaskManager::CleanUp();
161 TimingWheel::CleanUp();
162 scheduler::CleanUp();
163 service_discovery::TopologyManager::CleanUp();
164 transport::Transport::CleanUp();
165 StopLogger();
166 SetState(STATE_SHUTDOWN);
167}
State GetState()
Definition state.cc:28

◆ CreateNode()

std::unique_ptr< Node > apollo::cyber::CreateNode ( const std::string &  node_name,
const std::string &  name_space 
)

在文件 cyber.cc33 行定义.

34 {
35 bool is_reality_mode = GlobalData::Instance()->IsRealityMode();
36 if (is_reality_mode && !OK()) {
37 // add some hint log
38 AERROR << "please initialize cyber firstly.";
39 return nullptr;
40 }
41 return std::unique_ptr<Node>(new Node(node_name, name_space));
42}
Definition node.h:31

◆ ExitHandle()

void apollo::cyber::ExitHandle ( )

在文件 init.cc97 行定义.

97{ Clear(); }
void Clear()
Definition init.cc:154

◆ GetState()

State apollo::cyber::GetState ( )

在文件 state.cc28 行定义.

28{ return g_cyber_state.load(); }

◆ Init()

bool apollo::cyber::Init ( const char *  binary_name,
const std::string &  dag_info 
)

在文件 init.cc99 行定义.

99 {
100 std::lock_guard<std::mutex> lg(g_mutex);
101 if (GetState() != STATE_UNINITIALIZED) {
102 return false;
103 }
104
105 InitLogger(binary_name);
106 auto thread = const_cast<std::thread*>(async_logger->LogThread());
107 scheduler::Instance()->SetInnerThreadAttr("async_log", thread);
108 SysMo::Instance();
109 std::signal(SIGINT, OnShutdown);
110 // Register exit handlers
111 if (!g_atexit_registered) {
112 if (std::atexit(ExitHandle) != 0) {
113 AERROR << "Register exit handle failed";
114 return false;
115 }
116 AINFO << "Register exit handle succ.";
117 g_atexit_registered = true;
118 }
119 SetState(STATE_INITIALIZED);
120
121 auto global_data = GlobalData::Instance();
122 if (global_data->IsMockTimeMode()) {
123 auto node_name = kClockNode + std::to_string(getpid());
124 clock_node = std::unique_ptr<Node>(new Node(node_name));
125 auto cb =
126 [](const std::shared_ptr<const apollo::cyber::proto::Clock>& msg) {
127 if (msg->has_clock()) {
128 Clock::Instance()->SetNow(Time(msg->clock()));
129 }
130 };
131 clock_node->CreateReader<apollo::cyber::proto::Clock>(kClockChannel, cb);
132 }
133
134 if (dag_info != "") {
135 std::string dump_path;
136 if (dag_info.length() > 200) {
137 std::string truncated = dag_info.substr(0, 200);
138 dump_path = common::GetEnv(
139 "APOLLO_ENV_WORKROOT", "/apollo") + "/dumps/" + truncated;
140 } else {
141 dump_path = \
142 common::GetEnv("APOLLO_ENV_WORKROOT", "/apollo") + "/dumps/" + dag_info;
143 }
144 google::SetCommandLineOption("bvar_dump_file", dump_path.c_str());
145 } else {
146 statistics::Statistics::Instance()->DisableChanVar();
147 }
148 google::SetCommandLineOption("bvar_dump_exclude", "*qps");
149 google::SetCommandLineOption("bvar_dump", "true");
150
151 return true;
152}
#define AINFO
Definition log.h:42
void SetState(const State &state)
Definition state.cc:30
::apollo::cyber::Time Time

◆ IsShutdown()

bool apollo::cyber::IsShutdown ( )
inline

在文件 state.h46 行定义.

46 {
48}

◆ OK()

bool apollo::cyber::OK ( )
inline

在文件 state.h44 行定义.

44{ return GetState() == STATE_INITIALIZED; }

◆ OnShutdown()

void apollo::cyber::OnShutdown ( int  sig)

在文件 init.cc90 行定义.

90 {
91 (void)sig;
92 if (GetState() != STATE_SHUTDOWN) {
93 SetState(STATE_SHUTTING_DOWN);
94 }
95}

◆ operator<<() [1/2]

std::ostream & apollo::cyber::operator<< ( std::ostream &  os,
const Duration rhs 
)

在文件 duration.cc114 行定义.

114 {
115 std::ios::fmtflags before(os.flags());
116 os << std::fixed << std::setprecision(9) << rhs.ToSecond() << "s";
117 os.flags(before);
118 return os;
119}
double ToSecond() const
Definition duration.cc:48

◆ operator<<() [2/2]

std::ostream & apollo::cyber::operator<< ( std::ostream &  os,
const Time rhs 
)

在文件 time.cc164 行定义.

164 {
165 os << rhs.ToString();
166 return os;
167}
std::string ToString() const
convert time to a string.
Definition time.cc:89

◆ py_init()

bool apollo::cyber::py_init ( const std::string &  module_name)
inline

在文件 py_cyber.h46 行定义.

46 {
47 static bool inited = false;
48 if (inited) {
49 AINFO << "cyber already inited.";
50 return true;
51 }
52
53 if (!Init(module_name.c_str())) {
54 AERROR << "cyber::Init failed:" << module_name;
55 return false;
56 }
57 inited = true;
58 AINFO << "cyber init succ.";
59 return true;
60}

◆ py_is_shutdown()

bool apollo::cyber::py_is_shutdown ( )
inline

在文件 py_cyber.h66 行定义.

66{ return IsShutdown(); }
bool IsShutdown()
Definition state.h:46

◆ py_ok()

bool apollo::cyber::py_ok ( )
inline

在文件 py_cyber.h62 行定义.

62{ return OK(); }

◆ py_shutdown()

void apollo::cyber::py_shutdown ( )
inline

在文件 py_cyber.h64 行定义.

64{ return Clear(); }

◆ py_waitforshutdown()

void apollo::cyber::py_waitforshutdown ( )
inline

在文件 py_cyber.h68 行定义.

68{ return WaitForShutdown(); }
void WaitForShutdown()
Definition state.h:50

◆ SetState()

void apollo::cyber::SetState ( const State state)

在文件 state.cc30 行定义.

30{ g_cyber_state.store(state); }

◆ WaitForShutdown()

void apollo::cyber::WaitForShutdown ( )
inline

在文件 state.h50 行定义.

50 {
51 while (!IsShutdown()) {
52 std::this_thread::sleep_for(std::chrono::milliseconds(200));
53 }
54}

变量说明

◆ DEFAULT_PENDING_QUEUE_SIZE

const uint32_t apollo::cyber::DEFAULT_PENDING_QUEUE_SIZE = 1

在文件 reader.h50 行定义.

◆ GET_PARAMETER_SERVICE_NAME

constexpr auto apollo::cyber::GET_PARAMETER_SERVICE_NAME = "get_parameter"
constexpr

在文件 parameter_service_names.h26 行定义.

◆ LIST_PARAMETERS_SERVICE_NAME

constexpr auto apollo::cyber::LIST_PARAMETERS_SERVICE_NAME = "list_parameters"
constexpr

在文件 parameter_service_names.h28 行定义.

◆ RAWDATATYPE

const char apollo::cyber::RAWDATATYPE[] = "RawData"

在文件 py_cyber.h108 行定义.

◆ SERVICE_NAME_DELIMITER

constexpr auto apollo::cyber::SERVICE_NAME_DELIMITER = "/"
constexpr

在文件 parameter_service_names.h25 行定义.

◆ SET_PARAMETER_SERVICE_NAME

constexpr auto apollo::cyber::SET_PARAMETER_SERVICE_NAME = "set_parameter"
constexpr

在文件 parameter_service_names.h27 行定义.