24#include "modules/common_msgs/control_msgs/control_cmd.pb.h"
40 chassis_msg.ParseFromString(msg.
content);
41 const float speed = chassis_msg.
speed_mps();
47 EnqueueMessage(speed);
50 AINFO <<
"hard break trigger is pulled: " << msg.
time <<
" - "
57bool HardBrakeTrigger::IsNoisy(
const float speed)
const {
58 const float pre_speed_mps =
59 (current_speed_queue_.empty() ? 0.0f : current_speed_queue_.back());
60 return fabs(pre_speed_mps - speed) > noisy_diff_;
63bool HardBrakeTrigger::IsHardBrake()
const {
64 if (current_speed_queue_.size() < queue_size_ ||
65 history_speed_queue_.size() < queue_size_) {
69 (history_total_ - current_total_) /
static_cast<float>(queue_size_);
70 return delta > max_delta_;
73void HardBrakeTrigger::EnqueueMessage(
const float speed) {
74 current_speed_queue_.emplace_back(speed);
75 current_total_ += speed;
76 if (current_speed_queue_.size() > queue_size_) {
77 const float current_front = current_speed_queue_.front();
78 current_speed_queue_.pop_front();
79 current_total_ -= current_front;
81 history_speed_queue_.emplace_back(current_front);
82 history_total_ += current_front;
83 if (history_speed_queue_.size() > queue_size_) {
84 history_total_ -= history_speed_queue_.front();
85 history_speed_queue_.pop_front();
void Pull(const cyber::record::RecordMessage &msg) override
std::unique_ptr< Trigger > trigger_obj_
void TriggerIt(const uint64_t msg_time) const
std::string trigger_name_
Basic data struct of record message.
std::string content
The content of the message.
uint64_t time
The time (nanosecond) of the message.
std::string channel_name
The channel name of the message.