-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathState_rl.h
71 lines (61 loc) · 2.06 KB
/
State_rl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef STATE_RL_H
#define STATE_RL_H
#include "FSMState.h"
#include "reinforcement/dataTypes.h"
class State_rl : public FSMState
{
private:
// net structure
// torch::Device device = torch::kCPU;
torch::jit::script::Module module;
std::vector<torch::jit::IValue> inputs;
torch::Tensor output;
// Robot State
rlType::Vec3<double> _projGravity;
rlType::Vec3<double> _highCmd;
rlType::Vec12<double> _dofDePos, _dofPos, _targetDofPos, _dofDefaultPos;
rlType::Vec12<double> _dofVel, _targetDofVel;
rlType::Vec12<double> _actions, _preactions, _actionsScaled;
rlType::Vec12<double> pos_err;
rlType::Vec12<double> vel_err;
rlType::VecX<double, 42> _obs; // 观测缓冲
// config
int count;
int frequencyFactor;
const int times = 5; // print times
const double policyQueried = 30; // hz
const double decimation = 6; // 6
const double _GainP = 80.; // 刚度值stiffness,即比例系数P
const double _GainD = 1.; // 阻尼值damping,即微分系数D
const rlType::Vec3<double> _G = {0, 0, -1};
const double actionScale = 0.25;
const double linVelScale = 2.0;
const double angleVelScale = 0.25;
const double dofPosScale = 1.0;
const double dofVelScale = 0.05;
const double clipObs = 100.0;
const double clipActions = 100.0;
const rlType::Vec3<double> torque_limits = {33.5, 33.5, 33.5};
const rlType::Vec2<double> _vxLim = {-1.0, 2.0}, _vyLim = {-0.3, 0.3}, _wyawLim = {-1.57, 1.57};
double _yaw, _dYaw;
rlType::RotMat<double> _B2G_RotMat, _G2B_RotMat; // 互为逆矩阵
rlType::Vec12<double> _torques;
// robot command
rlType::Vec3<double> _vCmdBody;
double _dYawCmd, _dYawCmdPast;
rlType::Vec3<double> _command;
void act();
void step();
void computeTorques();
void limitTorques();
void computeObservations();
virtual void getUserCmd();
public:
State_rl(CtrlComponents *ctrlComp);
~State_rl();
void enter();
void run();
void exit();
virtual FSMStateName checkChange();
};
#endif