Policy Deployment
Policy Runner Base Class
Section titled “Policy Runner Base Class”The policy runner base class PolicyRunnerBase defines input observation, output action, and inference lifecycle.
Interface Example
Section titled “Interface Example”virtual RobotAction getRobotAction(const RobotBasicState&, const UserCommand&) = 0;virtual void OnEnter(const RobotBasicState&) = 0;virtual void SetDecimation(int d);ONNX Policy Implementation
Section titled “ONNX Policy Implementation”Lite3PolicyRunner is the ONNX policy implementation for Lite3.
Model Loading Example
Section titled “Model Loading Example”session_ = Ort::Session(env_, policy_path_.c_str(), session_options_);Observation and Action Dimensions
Section titled “Observation and Action Dimensions”const int motor_num = 12;const int observation_dim = 45;const int action_dim = 12;Observation vector composition:
current_observation_ << base_omega, // 3D (angular velocity * 0.25) projected_gravity, // 3D (gravity projection) command, // 3D (velocity command) joint_pos_rl, // 12D (joint position - default position) joint_vel_rl, // 12D (joint velocity * 0.05) last_action_eigen; // 12D (previous action)Inference Example
Section titled “Inference Example”VecXf current_action_eigen = Onnx_infer(current_observation_);Robot Action Output
Section titled “Robot Action Output”for (int i = 0; i < 4; ++i){ robot_action.goal_joint_pos.segment(i*3, 3) = tmp_action_eigen.segment(i*3, 3);}robot_action.kp = kp_; // Vec3f(30, 30, 30).replicate(4, 1)robot_action.kd = kd_; // Vec3f(1, 1, 1).replicate(4, 1)Joint Ordering Mapping
Section titled “Joint Ordering Mapping”The policy and robot may have different joint orderings. Permutation indices are automatically computed via name mapping:
std::vector<std::string> robot_order = { "FL_HipX_joint", "FL_HipY_joint", "FL_Knee_joint", "FR_HipX_joint", "FR_HipY_joint", "FR_Knee_joint", "HL_HipX_joint", "HL_HipY_joint", "HL_Knee_joint", "HR_HipX_joint", "HR_HipY_joint", "HR_Knee_joint"};robot2policy_idx = generate_permutation(robot_order, policy_order);policy2robot_idx = generate_permutation(policy_order, robot_order);Policy Deployment Notes
Section titled “Policy Deployment Notes”Model File Location
Section titled “Model File Location”The model file is located at:
src/Lite3_sdk_deploy/policy/policy.onnxDefault Posture
Section titled “Default Posture”dof_default_eigen_policy << 0.0000, -0.8000, 1.6000, 0.0000, -0.8000, 1.6000, 0.0000, -0.8000, 1.6000, 0.0000, -0.8000, 1.6000;Action Scaling
Section titled “Action Scaling”std::vector<float> action_scale_robot = {0.125, 0.25, 0.25, 0.125, 0.25, 0.25, 0.125, 0.25, 0.25, 0.125, 0.25, 0.25};