Apollo 11.0
自动驾驶开放平台
apollo::external_command::ChassisCommandProcessor类 参考

#include <chassis_command_processor.h>

类 apollo::external_command::ChassisCommandProcessor 继承关系图:
apollo::external_command::ChassisCommandProcessor 的协作图:

Public 成员函数

bool Init (const std::shared_ptr< cyber::Node > &node) override
 
bool GetCommandStatus (int64_t command_id, CommandStatus *status) const override
 Get the command status.
 
- Public 成员函数 继承自 apollo::external_command::CommandProcessorBase
 CommandProcessorBase ()
 
virtual ~CommandProcessorBase ()=default
 

额外继承的成员函数

- Protected 成员函数 继承自 apollo::external_command::CommandProcessorBase
const CommandProcessorConfig & GetProcessorConfig () const
 
const std::shared_ptr< cyber::Node > & Node () const
 

详细描述

在文件 chassis_command_processor.h 第 40 行定义.

成员函数说明

◆ GetCommandStatus()

bool apollo::external_command::ChassisCommandProcessor::GetCommandStatus ( int64_t  command_id,
CommandStatus *  status 
) const
overridevirtual

Get the command status.

参数
command_idId of the command.
statusOutput command status.

实现了 apollo::external_command::CommandProcessorBase.

在文件 chassis_command_processor.cc 第 54 行定义.

54 {
55 CHECK_NOTNULL(status);
56 if (command_id != last_received_command_.command_id()) {
57 return false;
58 }
59 status->set_command_id(command_id);
60 auto* latest_chassis_status = message_reader_->GetMessage<apollo::canbus::Chassis>(chassis_status_name_);
61 if (nullptr == latest_chassis_status) {
63 status->set_message("Cannot get chassis status!");
64 return true;
65 }
66 // Process basic vehicle signals.
67 if (last_received_command_.has_basic_signal()) {
68 const auto& basic_signal = last_received_command_.basic_signal();
69 // Check turn signal.
70 if (basic_signal.has_turn_signal()) {
71 if (!latest_chassis_status->has_signal() || !latest_chassis_status->signal().has_turn_signal()
72 || latest_chassis_status->signal().turn_signal() != basic_signal.turn_signal()) {
74 return true;
75 }
76 }
77 // Check high beam.
78 if (basic_signal.has_high_beam()) {
79 if (!latest_chassis_status->has_signal() || !latest_chassis_status->signal().has_high_beam()
80 || latest_chassis_status->signal().high_beam() != basic_signal.high_beam()) {
82 return true;
83 }
84 }
85 // Check low beam.
86 if (basic_signal.has_low_beam()) {
87 if (!latest_chassis_status->has_signal() || !latest_chassis_status->signal().has_low_beam()
88 || latest_chassis_status->signal().low_beam() != basic_signal.low_beam()) {
90 return true;
91 }
92 }
93 // Check horn.
94 if (basic_signal.has_horn()) {
95 if (!latest_chassis_status->has_signal() || !latest_chassis_status->signal().has_horn()
96 || latest_chassis_status->signal().horn() != basic_signal.horn()) {
98 return true;
99 }
100 }
101 // Check emergency light.
102 if (basic_signal.has_emergency_light()) {
103 if (!latest_chassis_status->has_signal() || !latest_chassis_status->signal().has_emergency_light()
104 || latest_chassis_status->signal().emergency_light() != basic_signal.emergency_light()) {
106 return true;
107 }
108 }
109 }
111 return true;
112}
const T * GetMessage(const std::string &channel_name) const
Get the message with the channel name.
optional apollo::common::VehicleSignal basic_signal

◆ Init()

bool apollo::external_command::ChassisCommandProcessor::Init ( const std::shared_ptr< cyber::Node > &  node)
overridevirtual

重载 apollo::external_command::CommandProcessorBase .

在文件 chassis_command_processor.cc 第 31 行定义.

31 {
32 // hook: Apollo License Verification: v_apollo_park
33 if (!CommandProcessorBase::Init(node)) {
34 return false;
35 }
36 last_received_command_.set_command_id(-1);
37 message_reader_ = MessageReader::Instance();
38 const auto& config = GetProcessorConfig();
39 command_service_ = node->CreateService<ChassisCommand, CommandStatus>(
40 config.input_command_name(),
41 [this](const std::shared_ptr<ChassisCommand>& command, std::shared_ptr<CommandStatus>& status) {
42 this->OnCommand(command, status);
43 });
44 // Create writer for output command.
45 CHECK(config.output_command_name().size() > 0 && config.input_command_status_name().size() > 0);
46 auto message_writer = MessageWriter::Instance();
47 chassis_command_writer_ = message_writer->RegisterMessage<ChassisCommand>(config.output_command_name().Get(0));
48 chassis_status_name_ = config.input_command_status_name().Get(0);
49 message_reader_->RegisterMessage<apollo::canbus::Chassis>(chassis_status_name_);
50 return true;
51}
virtual bool Init(const std::shared_ptr< cyber::Node > &node)
const CommandProcessorConfig & GetProcessorConfig() const
void RegisterMessage(const std::string &channel_name)
Register the message reader with the given channel name.

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