T_SpeedShape.h
1.7 KB
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
#ifndef __T_SPEEDSHAPE_H_
#define __T_SPEEDSHAPE_H_
typedef enum
{
TRAP_CURVE_STA_1_T,
TRAP_CURVE_STA_2_TRIANGLE,
TRAP_CURVE_STA_3_BACK,
TRAP_CURVE_STA_4_STOP,
} TRAP_CURVE_STA;
typedef enum
{
TRAP_CURVE_CYCMODE_OFF = 0,
TRAP_CURVE_CYCMODE_M1,
} TRAP_CURVE_CYCMODE;
typedef enum
{
TRAP_CURVE_CYCSIGN_NONE = 0,
TRAP_CURVE_CYCSIGN_NEED_CYC,
} TRAP_CURVE_CYCSIGN;
typedef struct
{
/* Globe Setting Group */
float vel_Max_Limit;
float acc_global;
/* Target Group */
float target_Position;
/* Running Status*/
TRAP_CURVE_STA status;
float vel_Max; // the MAX Velocity calculated by target ; The Maximum is vel_Max_Limit
float vel_Cur; // the Current velocity ; transitions for state transitions
float vel_Orig; // the originate velocity ;
float pos_Start; // the position where start to move ; Will be flashed when state transitions
float pos_Cur; // the current position ;
float time_Start; // the start time;
float time_Now; // the current time;
float acc_live;
// /* Vaule PreCalculation */
// float vel_Orig_2; //vel_Orig ^ 2
/* Inter calculate Value */
float t1; // Tf = t1 + t2 + t3
float t2;
float t3;
float S1_Int;
float S2_Int;
float S3_Int;
float S_Min;
float Vm; // the Maximum achievable velocity
int cycMode;
float cycRange;
float cycRange_2;
float target_Position_CYC;
int cycSign;
} TRAP_CURVE_s;
void trap_Curve_Init(TRAP_CURVE_s *s, float vel_Max_Limit, float acc_global, float time_Now,int cycMode,float cycRange);
void trap_Curve_SetTarget(TRAP_CURVE_s *s, float target_Position);
float trap_Curve_Update(TRAP_CURVE_s *s, float time_Now);
#endif