|
@@ -1,8 +1,10 @@
|
|
#ifndef CAR_CONTROL_H
|
|
#ifndef CAR_CONTROL_H
|
|
#define CAR_CONTROL_H
|
|
#define CAR_CONTROL_H
|
|
|
|
|
|
-#include "include/kx_11_can_frame/chassis_can1_frame.h"
|
|
|
|
-#include "include/kx_11_can_frame/asdm_sim_canfd_frame.h"
|
|
|
|
|
|
+#include "kx_11_can_frame/chassis_can1_frame.h"
|
|
|
|
+#include "kx_11_can_frame/asdm_sim_canfd_frame.h"
|
|
|
|
+#include <thread>
|
|
|
|
+
|
|
|
|
|
|
enum class StsMach
|
|
enum class StsMach
|
|
{
|
|
{
|
|
@@ -36,7 +38,6 @@ public:
|
|
CarControl();
|
|
CarControl();
|
|
~CarControl();
|
|
~CarControl();
|
|
|
|
|
|
- void sm_task_20ms();
|
|
|
|
|
|
|
|
void set_lat_lgt_ctrl_req(bool req);
|
|
void set_lat_lgt_ctrl_req(bool req);
|
|
void set_target_gear(GearPrkgAssistReq tar);
|
|
void set_target_gear(GearPrkgAssistReq tar);
|
|
@@ -44,6 +45,8 @@ public:
|
|
void set_target_pinion_ag_in_deg(float32_t ang_req);
|
|
void set_target_pinion_ag_in_deg(float32_t ang_req);
|
|
void set_target_acc_mps2(float32_t tar_acc);
|
|
void set_target_acc_mps2(float32_t tar_acc);
|
|
void set_turn_light_status(TurnLightIndicReq req);
|
|
void set_turn_light_status(TurnLightIndicReq req);
|
|
|
|
+ void set_ctrl_mode_switch_spd(float32_t spd_kmh);
|
|
|
|
+ void set_debug_log_para(bool enable, uint16_t print_cycle_ms);
|
|
ChassisErrCode get_chassis_err_state();
|
|
ChassisErrCode get_chassis_err_state();
|
|
StsMach get_chassis_statemachine_sts();
|
|
StsMach get_chassis_statemachine_sts();
|
|
float32_t get_current_steer_ang_in_deg();
|
|
float32_t get_current_steer_ang_in_deg();
|
|
@@ -51,6 +54,8 @@ public:
|
|
GearPrkgAssistReq get_setted_tar_gear();
|
|
GearPrkgAssistReq get_setted_tar_gear();
|
|
GearLevelIndicate get_cur_disp_gear();
|
|
GearLevelIndicate get_cur_disp_gear();
|
|
private:
|
|
private:
|
|
|
|
+ void sm_task_20ms();
|
|
|
|
+ void sm_task_thread();
|
|
bool is_chassis_system_failure();
|
|
bool is_chassis_system_failure();
|
|
bool is_hwa_switched();
|
|
bool is_hwa_switched();
|
|
void apa_active_ctrl();
|
|
void apa_active_ctrl();
|
|
@@ -62,35 +67,38 @@ private:
|
|
void apa_startup_action();
|
|
void apa_startup_action();
|
|
void hwa_pre_active();
|
|
void hwa_pre_active();
|
|
private:
|
|
private:
|
|
- ChassisCAN1_Process *chassis_obj_ptr_;
|
|
|
|
- ASDM_Sim_Process *asdm_obj_ptr_;
|
|
|
|
- StsMach sm_ = StsMach::kStandby;
|
|
|
|
- bool is_chassis_handshake_timeout;
|
|
|
|
|
|
+ ChassisCAN1_Process *chassis_obj_ptr_{nullptr};
|
|
|
|
+ ASDM_Sim_Process *asdm_obj_ptr_{nullptr};
|
|
|
|
+ StsMach sm_{StsMach::kStandby};
|
|
|
|
+ std::unique_ptr<std::thread> thread_sm_task_{nullptr};
|
|
|
|
+ bool is_chassis_handshake_timeout{false};
|
|
|
|
|
|
- bool is_lat_lgt_ctrl_requested_;
|
|
|
|
- GearPrkgAssistReq tar_gear_;
|
|
|
|
- float32_t tar_pinion_ang_in_deg_;
|
|
|
|
- float32_t tar_acc_meter_per_second2_;
|
|
|
|
|
|
+ bool is_lat_lgt_ctrl_requested_{false};
|
|
|
|
+ GearPrkgAssistReq tar_gear_{GearPrkgAssistReq::kNoRequest};
|
|
|
|
+ float32_t tar_pinion_ang_in_deg_{0};
|
|
|
|
+ float32_t tar_acc_meter_per_second2_{0};
|
|
|
|
|
|
uint16_t time_startup_ = 0;
|
|
uint16_t time_startup_ = 0;
|
|
uint16_t timeout_apa_startup = 0;
|
|
uint16_t timeout_apa_startup = 0;
|
|
uint16_t timeout_apa_shutdown = 0;
|
|
uint16_t timeout_apa_shutdown = 0;
|
|
uint16_t timeout_hwa_startup = 0;
|
|
uint16_t timeout_hwa_startup = 0;
|
|
uint16_t timeout_hwa_shutdown = 0;
|
|
uint16_t timeout_hwa_shutdown = 0;
|
|
- uint16_t time_handshake_timeout_disappear = 0;
|
|
|
|
const uint16_t kMaxStartupDlyTime = (3000 / 20); // uinit:ms
|
|
const uint16_t kMaxStartupDlyTime = (3000 / 20); // uinit:ms
|
|
const uint16_t kMaxApaStartupTime = (3000 / 20); // uinit:ms
|
|
const uint16_t kMaxApaStartupTime = (3000 / 20); // uinit:ms
|
|
const uint16_t kMaxApaShutdownTime = (10000 / 20); // uinit:ms
|
|
const uint16_t kMaxApaShutdownTime = (10000 / 20); // uinit:ms
|
|
const uint16_t kMaxHwaStartupTime = (5000 / 20); // uinit:ms
|
|
const uint16_t kMaxHwaStartupTime = (5000 / 20); // uinit:ms
|
|
const uint16_t kMaxHwaShutdownTime = (10000 / 20); // uinit:ms
|
|
const uint16_t kMaxHwaShutdownTime = (10000 / 20); // uinit:ms
|
|
- const uint16_t kMaxHandshakeTimeoutDispTime = (4000 / 20); // uinit:ms
|
|
|
|
- const float32_t kSpeedForCtrlModSwitch = CONVERT_KPH_2_MPS(6); // the APA longitude speed uppper limit is 10km/h
|
|
|
|
|
|
+ float32_t kSpeedForCtrlModSwitch = CONVERT_KPH_2_MPS(6); // the APA longitude speed uppper limit is 10km/h
|
|
const float32_t kSteerDiffMax = 90;
|
|
const float32_t kSteerDiffMax = 90;
|
|
const float32_t kSteerDiffMin = -90;
|
|
const float32_t kSteerDiffMin = -90;
|
|
const float32_t kSteerMaxAng = 450;
|
|
const float32_t kSteerMaxAng = 450;
|
|
const float32_t kSteerMinAng = -450;
|
|
const float32_t kSteerMinAng = -450;
|
|
const float32_t kApaShutDownDecel = -1.28; //uinit: m/s^2, apa max deceleration.
|
|
const float32_t kApaShutDownDecel = -1.28; //uinit: m/s^2, apa max deceleration.
|
|
const float32_t kHwaShutDownDecel = -5; //uinit: m/s^2, hwa shutdown deceleration value.
|
|
const float32_t kHwaShutDownDecel = -5; //uinit: m/s^2, hwa shutdown deceleration value.
|
|
|
|
+
|
|
|
|
+ // debug parameter:
|
|
|
|
+ bool debug_enable_{false};
|
|
|
|
+ uint16_t print_period_ms_{20};
|
|
};
|
|
};
|
|
|
|
|
|
#endif
|
|
#endif
|