Download third-party/unitree_rl_lab/deploy/include/FSM/State_FixStand.h from hk239/v2d: direct link, hf CLI and curl.
- Browser
- Download file 1.66 kB
-
https://huggingface.co/datasets/hk239/v2d/resolve/main/third-party/unitree_rl_lab/deploy/include/FSM/State_FixStand.h
- Command line
-
hf download hf://datasets/hk239/v2d/third-party/unitree_rl_lab/deploy/include/FSM/State_FixStand.h
-
curl -L -o State_FixStand.h https://huggingface.co/datasets/hk239/v2d/resolve/main/third-party/unitree_rl_lab/deploy/include/FSM/State_FixStand.h
1.66 kB
| // Copyright (c) 2025, Unitree Robotics Co., Ltd. | |
| // All rights reserved. | |
| class State_FixStand : public FSMState | |
| { | |
| public: | |
| State_FixStand(int state, std::string state_string = "FixStand") | |
| : FSMState(state, state_string) | |
| { | |
| ts_ = param::config["FSM"]["FixStand"]["ts"].as<std::vector<float>>(); | |
| qs_ = param::config["FSM"]["FixStand"]["qs"].as<std::vector<std::vector<float>>>(); | |
| assert(ts_.size() == qs_.size()); | |
| } | |
| void enter() | |
| { | |
| // set gain | |
| static auto kp = param::config["FSM"]["FixStand"]["kp"].as<std::vector<float>>(); | |
| static auto kd = param::config["FSM"]["FixStand"]["kd"].as<std::vector<float>>(); | |
| for(int i(0); i < kp.size(); ++i) | |
| { | |
| auto & motor = lowcmd->msg_.motor_cmd()[i]; | |
| motor.kp() = kp[i]; | |
| motor.kd() = kd[i]; | |
| motor.dq() = motor.tau() = 0; | |
| } | |
| // set initial position | |
| std::vector<float> q0; | |
| for(int i(0); i < kp.size(); ++i) { | |
| q0.push_back(lowcmd->msg_.motor_cmd()[i].q()); | |
| } | |
| qs_[0] = q0; | |
| t0_ = (double)unitree::common::GetCurrentTimeMillisecond() * 1e-3; | |
| } | |
| void run() | |
| { | |
| float t = (double)unitree::common::GetCurrentTimeMillisecond() * 1e-3 - t0_; | |
| auto q = linear_interpolate(t, ts_, qs_); | |
| for(int i(0); i < q.size(); ++i) { | |
| lowcmd->msg_.motor_cmd()[i].q() = q[i]; | |
| } | |
| } | |
| private: | |
| double t0_; | |
| std::vector<float> ts_; | |
| std::vector<std::vector<float>> qs_; | |
| }; | |
| REGISTER_FSM(State_FixStand) |