@@ -45,12 +45,15 @@ class Sensor{
45
45
public:
46
46
/* *
47
47
* Get shaft angle in the range 0 to 2PI. This value will be as precise as possible with
48
- * the hardware.
48
+ * the hardware. Base implementation uses the values returned by updateSensor() so that
49
+ * the same values are returned until updateSensor() is called again.
49
50
*/
50
51
virtual float getShaftAngle ();
51
52
52
53
/* *
53
- * Get current position (in rad) including full rotations and shaft angle
54
+ * Get current position (in rad) including full rotations and shaft angle.
55
+ * Base implementation uses the values returned by updateSensor() so that the same
56
+ * values are returned until updateSensor() is called again.
54
57
* Note that this value has limited precision as the number of rotations increases,
55
58
* because the limited precision of float can't capture the large angle of the full
56
59
* rotations and the small angle of the shaft angle at the same time.
@@ -60,18 +63,23 @@ class Sensor{
60
63
/* *
61
64
* On architectures supporting it, this will return a double precision position value,
62
65
* which should have improved precision for large position values.
66
+ * Base implementation uses the values returned by updateSensor() so that the same
67
+ * values are returned until updateSensor() is called again.
63
68
*/
64
69
virtual double getPreciseAngle ();
65
70
66
71
/* *
67
72
* Get current angular velocity (rad/s)
68
73
* Can be overridden in subclasses. Base implementation uses the values
69
- * previously returned by getShaftAngle().
74
+ * returned by updateSensor() so that it only makes sense to call this if updateSensor()
75
+ * has been called in the meantime.
70
76
*/
71
77
virtual float getVelocity ();
72
78
73
79
/* *
74
80
* Get the number of full rotations
81
+ * Base implementation uses the values returned by updateSensor() so that the same
82
+ * values are returned until updateSensor() is called again.
75
83
*/
76
84
virtual int32_t getFullRotations ();
77
85
@@ -107,12 +115,12 @@ class Sensor{
107
115
virtual float getSensorAngle ()=0;
108
116
109
117
// velocity calculation variables
110
- float angle_prev=0 ; // result of last call to getAngle , used for full rotations and velocity
118
+ float angle_prev=0 ; // result of last call to getSensorAngle() , used for full rotations and velocity
111
119
long angle_prev_ts=0 ; // timestamp of last call to getAngle, used for velocity
112
120
float vel_angle_prev=0 ; // angle at last call to getVelocity, used for velocity
113
- long vel_angle_prev_ts=0 ; // !< last velocity calculation timestamp
121
+ long vel_angle_prev_ts=0 ; // last velocity calculation timestamp
114
122
int32_t full_rotations=0 ; // full rotation tracking
115
- int32_t vel_full_rotations=0 ;
123
+ int32_t vel_full_rotations=0 ; // previous full rotation value for velocity calculation
116
124
};
117
125
118
126
#endif
0 commit comments