Download third-party/unitree_rl_lab/deploy/include/FSM/FSMState.h from hk239/v2d: direct link, hf CLI and curl.
- Browser
- Download file 2.04 kB
-
https://huggingface.co/datasets/hk239/v2d/resolve/main/third-party/unitree_rl_lab/deploy/include/FSM/FSMState.h
- Command line
-
hf download hf://datasets/hk239/v2d/third-party/unitree_rl_lab/deploy/include/FSM/FSMState.h
-
curl -L -o FSMState.h https://huggingface.co/datasets/hk239/v2d/resolve/main/third-party/unitree_rl_lab/deploy/include/FSM/FSMState.h
2.04 kB
| class FSMState : public BaseState | |
| { | |
| public: | |
| FSMState(int state, std::string state_string) | |
| : BaseState(state, state_string) | |
| { | |
| spdlog::info("Initializing State_{} ...", state_string); | |
| auto transitions = param::config["FSM"][state_string]["transitions"]; | |
| if(transitions) | |
| { | |
| auto transition_map = transitions.as<std::map<std::string, std::string>>(); | |
| for(auto it = transition_map.begin(); it != transition_map.end(); ++it) | |
| { | |
| std::string target_fsm = it->first; | |
| if(!FSMStringMap.right.count(target_fsm)) | |
| { | |
| spdlog::warn("FSM State_'{}' not found in FSMStringMap!", target_fsm); | |
| continue; | |
| } | |
| int fsm_id = FSMStringMap.right.at(target_fsm); | |
| std::string condition = it->second; | |
| unitree::common::dsl::Parser p(condition); | |
| auto ast = p.Parse(); | |
| auto func = unitree::common::dsl::Compile(*ast); | |
| registered_checks.emplace_back( | |
| std::make_pair( | |
| [func]()->bool{ return func(FSMState::lowstate->joystick); }, | |
| fsm_id | |
| ) | |
| ); | |
| } | |
| } | |
| // register for all states | |
| registered_checks.emplace_back( | |
| std::make_pair( | |
| []()->bool{ return lowstate->isTimeout(); }, | |
| FSMStringMap.right.at("Passive") | |
| ) | |
| ); | |
| } | |
| void pre_run() | |
| { | |
| lowstate->update(); | |
| if(keyboard) keyboard->update(); | |
| } | |
| void post_run() | |
| { | |
| lowcmd->unlockAndPublish(); | |
| } | |
| static std::unique_ptr<LowCmd_t> lowcmd; | |
| static std::shared_ptr<LowState_t> lowstate; | |
| static std::shared_ptr<Keyboard> keyboard; | |
| }; |