| 38 | return true; |
| 39 | } |
| 40 | bool EvalDec::Step(eval::EvalStep &helper) { |
| 41 | // grading msg |
| 42 | sim_msg::Grading &grading = helper.GetGradingMsg(); |
| 43 | grading.mutable_event_detector()->set_deceleration_above_thresh( |
| 44 | sim_msg::Grading_EventDetector_EventState_EventNotDetected); |
| 45 | |
| 46 | // check whether the module is valid and whether the indicator is enabled |
| 47 | if (IsModuleValid() && m_KpiEnabled) { |
| 48 | // get the ego pointer and check whether the pointer is null |
| 49 | auto ego_front = _actor_mgr->GetEgoFrontActorPtr(); |
| 50 | if (ego_front == nullptr) { |
| 51 | VLOG_1 << "ego actor missing.\n"; |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | _ax = ego_front->GetAcc().GetX(); |
| 56 | double speed = ego_front->GetSpeed().GetNormal(); |
| 57 | if (speed < threshold_speed_lower) { |
| 58 | real_dec_thresh = -threshold_dec_below_lower; |
| 59 | } else if (speed < m_defaultThreshDouble) { |
| 60 | real_dec_thresh = -threshold_dec_low2up; |
| 61 | } else { |
| 62 | real_dec_thresh = -threshold_dec_above_upper; |
| 63 | } |
| 64 | if (_detector.Detect(_ax, real_dec_thresh)) { |
| 65 | grading.mutable_event_detector()->set_deceleration_above_thresh( |
| 66 | sim_msg::Grading_EventDetector_EventState_EventDetected); |
| 67 | } |
| 68 | |
| 69 | // add data to xy-pot |
| 70 | if (isReportEnabled()) { |
| 71 | s_dec_plot.mutable_x_axis()->add_axis_data(helper.GetSimTime()); |
| 72 | s_dec_plot.mutable_y_axis()->at(0).add_axis_data(_ax); |
| 73 | s_dec_plot.mutable_y_axis()->at(0).mutable_threshold_lower()->add_value(real_dec_thresh); |
| 74 | } |
| 75 | } else { |
| 76 | VLOG_1 << _kpi_name << " not enabled.\n"; |
| 77 | return false; |
| 78 | } |
| 79 | return true; |
| 80 | } |
| 81 | bool EvalDec::Stop(eval::EvalStop &helper) { |
| 82 | // add report |
| 83 | if (isReportEnabled()) { |
nothing calls this directly
no test coverage detected