/* * fsm.c * * Created on: 2025年7月14日 * Author: akeguo */ #include "fsm_state.h" #include "stdint.h" void fsm_state_run(transition_t* p_this) { // turnstile_pass(&turnstile) if (p_this->p_state->robotRun!= NULL) { p_this->p_state->robotRun(p_this); } } //修改状态机状态,若状态机修改后,则查看是否有enter 和 exit命令进行运动 void fsm_state_set(transition_t* p_this, transition_state_t* p_new_state) { if(p_this==NULL){return;} // turnstile_pass(&turnstile) if (p_this->p_state!= p_new_state) /* 状态不等 */ { if (p_this->p_state->robotExit!=NULL) { p_this->p_state->robotExit(p_this); } p_this->p_state = p_new_state; if (p_this->p_state->robotEnter != NULL) { p_this->p_state->robotEnter(p_this); } //exit } } //状态机初始化设定 void fsm_state_init(transition_t* p_this,transition_state_t* inti_state) { p_this->p_state =inti_state; }