Download third-party/unitree_rl_lab/deploy/include/FSM/State_RLBase.h from hk239/v2d: direct link, hf CLI and curl.
- Browser
- Download file 1.78 kB
-
https://huggingface.co/datasets/hk239/v2d/resolve/main/third-party/unitree_rl_lab/deploy/include/FSM/State_RLBase.h
- Command line
-
hf download hf://datasets/hk239/v2d/third-party/unitree_rl_lab/deploy/include/FSM/State_RLBase.h
-
curl -L -o State_RLBase.h https://huggingface.co/datasets/hk239/v2d/resolve/main/third-party/unitree_rl_lab/deploy/include/FSM/State_RLBase.h
1.78 kB
| // Copyright (c) 2025, Unitree Robotics Co., Ltd. | |
| // All rights reserved. | |
| class State_RLBase : public FSMState | |
| { | |
| public: | |
| State_RLBase(int state_mode, std::string state_string); | |
| void enter() | |
| { | |
| // set gain | |
| for (int i = 0; i < env->robot->data.joint_stiffness.size(); ++i) | |
| { | |
| lowcmd->msg_.motor_cmd()[i].kp() = env->robot->data.joint_stiffness[i]; | |
| lowcmd->msg_.motor_cmd()[i].kd() = env->robot->data.joint_damping[i]; | |
| lowcmd->msg_.motor_cmd()[i].dq() = 0; | |
| lowcmd->msg_.motor_cmd()[i].tau() = 0; | |
| } | |
| env->robot->update(); | |
| // Start policy thread | |
| policy_thread_running = true; | |
| policy_thread = std::thread([this]{ | |
| using clock = std::chrono::high_resolution_clock; | |
| const std::chrono::duration<double> desiredDuration(env->step_dt); | |
| const auto dt = std::chrono::duration_cast<clock::duration>(desiredDuration); | |
| // Initialize timing | |
| auto sleepTill = clock::now() + dt; | |
| env->reset(); | |
| while (policy_thread_running) | |
| { | |
| env->step(); | |
| // Sleep | |
| std::this_thread::sleep_until(sleepTill); | |
| sleepTill += dt; | |
| } | |
| }); | |
| } | |
| void run(); | |
| void exit() | |
| { | |
| policy_thread_running = false; | |
| if (policy_thread.joinable()) { | |
| policy_thread.join(); | |
| } | |
| } | |
| private: | |
| std::unique_ptr<isaaclab::ManagerBasedRLEnv> env; | |
| std::thread policy_thread; | |
| bool policy_thread_running = false; | |
| }; | |
| REGISTER_FSM(State_RLBase) | |