-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimpedance_control.h
79 lines (65 loc) · 2.04 KB
/
impedance_control.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
72
73
74
75
76
77
78
79
//インピーダンス制御用
//@todo:インピーダンス型の実装
//未チェック
#ifndef ___KAL_IMPEDANCE_CONTROL
#define ___KAL_IMPEDANCE_CONTROL
#include "config.h"
#include "utilize.h"
#ifdef EIGEN_KAL
#include "eigen3.3.7/Eigen/Core"
#endif
//#define IMPEDANCE_FORM
#define ADMITANCE_FORM
namespace kal{
template<class T,class Tmat>
class impedance_control{
public:
RobotData<T> zero;//基準位置
//desired imoedance
Tmat Md;//N/m/s^2=kg
Tmat Cd;//N/m/s
Tmat Kd;//N/m
//admitance control
RobotData<T> ref;
RobotData<T> ref_b1;
RobotData<T> ref_b2;
T fext;
T fext_b1;
T fext_b2;
impedance_control();
impedance_control(Tmat Md,Tmat Cd,Tmat Kd);
void set_impedance(Tmat Md,Tmat Cd,Tmat Kd);
void impedance_out(RobotData<T> state,T fref,T& f); //運動入力力出力
void admitance_out(T fext,T fref,RobotData<T>& ref);//力入力運動出力
};
template<class T,class Tmat>
impedance_control<T,Tmat>::impedance_control(){
}
template<class T,class Tmat>
impedance_control<T,Tmat>::impedance_control(Tmat Md,Tmat Cd,Tmat Kd){
this->Md = Md;
this->Cd = Cd;
this->Kd = Kd;
}
template<class T,class Tmat>
void impedance_control<T,Tmat>::set_impedance(Tmat Md,Tmat Cd,Tmat Kd){
this->Md = Md;
this->Cd = Cd;
this->Kd = Kd;
}
template<class T,class Tmat>
void impedance_control<T,Tmat>::impedance_out(RobotData<T> state,T fref,T& f){
f = Md * state.d2x + Cd * state.dx + Kd * state.x;//@todo:動力学補償入れる
}
template<class T,class Tmat>
void impedance_control<T,Tmat>::admitance_out(T fext,T fref,RobotData<T>& ref){//速度出力/があるからスカラーでしか計算できない
this->fext = fext;
this->ref.dx = 1.0/(4*Md+2*Ts*Cd+Kd*Ts*Ts)*(2*Ts*(fext-this->fext_b2)-(2*Kd*Ts*Ts-8*Md)*this->ref_b1.dx-(4*Md-2*Ts*Cd+Kd*Ts*Ts)*this->ref_b2.dx);
this->fext_b2 = this->fext_b1;
this->fext_b1 = fext;
this->ref_b2 = this->ref_b1;
this->ref_b1 = this->ref;
ref.dx = this->ref.dx*1000.0;//mm/sに直す
}
}
#endif