Files
ASER/App/nav/segment_fsm.h

81 lines
2.5 KiB
C
Raw Normal View History

2026-03-31 23:30:33 +08:00
#ifndef SEGMENT_FSM_H
#define SEGMENT_FSM_H
#include "preproc/corridor_msgs.h"
#include "preproc/corridor_preproc.h"
/**
* @brief
*/
typedef enum {
SEG_STATE_IDLE = 0, // 待命:不输出任何指令
SEG_STATE_CORRIDOR, // 走廊跟踪中:放行控制器输出
SEG_STATE_APPROACH, // 接近端墙:降速保护
SEG_STATE_STOP, // 到端停车:强制零速
SEG_STATE_ESTOP, // 紧急停车:传感器全部失效或异常
} SegFsmState_t;
/**
* @brief
*/
typedef struct {
float d_front_stop; // 前向停车距离阈值 (m),低于此值直接停车
float d_front_approach; // 前向减速预警距离 (m),低于此值开始线性减速
float approach_min_v; // 减速区内最低速度 (m/s),防止爬行太慢永远到不了
float conf_estop_thresh; // 置信度紧急停车阈值,低于此值触发 E-Stop
} SegFsmConfig_t;
/**
* @brief ()
*/
typedef struct {
SegFsmState_t state; // 当前状态
float safe_v; // 经安全仲裁后的最终线速度 (m/s)
float safe_w; // 经安全仲裁后的最终角速度 (rad/s)
} SegFsmOutput_t;
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief
* @param config
*/
void SegFsm_Init(const SegFsmConfig_t *config);
/**
* @brief IDLE CORRIDOR
*/
void SegFsm_Start(void);
/**
* @brief
* @param raw_cmd (v, w)
* @param obs ( d_front valid_mask)
* @param state ( conf )
2026-04-03 08:56:26 +08:00
* @param mode (CORRIDOR/TURN/STRAIGHT/IDLE)
2026-03-31 23:30:33 +08:00
* @param out
*/
void SegFsm_Update(const RawCmd_t *raw_cmd,
const CorridorObs_t *obs,
const CorridorState_t *state,
2026-04-03 08:56:26 +08:00
SafetyMode_t mode,
2026-03-31 23:30:33 +08:00
SegFsmOutput_t *out);
/**
* @brief ()
*/
SegFsmState_t SegFsm_GetState(void);
/**
* @brief ()
*/
const char* SegFsm_GetStateName(SegFsmState_t s);
#ifdef __cplusplus
}
#endif
#endif // SEGMENT_FSM_H