This repository has been archived by the owner on Jan 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interpolation.h
99 lines (80 loc) · 1.99 KB
/
interpolation.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//
// Created by troy on 12/12/16.
//
#pragma once
#ifndef SIMPLE_MOTION_INTERPOLATION_H
#define SIMPLE_MOTION_INTERPOLATION_H
#include <string>
typedef double TimeInS;
/**
* Interpolation state
*/
enum InterpolationState {
kIntNotYetConfigured,
kIntIdle,
kIntRunning,
kIntDone,
kIntError,
};
class Interpolation {
private:
InterpolationState status;
std::string type;
protected:
double p;
double v;
double a;
double j;
/**
* @brief Not allow create instance directly
*/
Interpolation();
public:
virtual ~Interpolation();
/**
* @brief initialize the interpolation alogrithm (pure virtual function)
* @param start_position start position
* @param start_velocity start velocity
* @return current interpolating status, only kError/kRunning
*/
virtual InterpolationState start(const TimeInS now,
const double start_position,
const double start_velocity) = 0;
/**
* @brief interpolate once (pure virtual function)
* @param TimeInS current time stamp
* @return current interpolating status
*/
virtual InterpolationState move(const TimeInS now) = 0;
/**
* @brief return current interpolating status
* @return interpolating status
*/
virtual InterpolationState get_status(void);
/**
* @brief return the type of this interpolation
* @return the type of this interpolation
*/
std::string get_type(void);
/**
* @brief return the position
* @return the position
*/
double get_position(void);
/**
* @brief return the velocity
* @return the velocity
*/
double get_velocity(void);
/**
* @brief return the acceleration
* @return the acceleration
*/
double get_acceleration(void);
/**
* @brief return the jerk
* @return the jerk
*/
double get_jerk(void);
};
#endif //SIMPLE_MOTION_INTERPOLATION_H