Skip to content

Commit c642756

Browse files
committed
comments
1 parent a5df234 commit c642756

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/common/base_classes/Sensor.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ class Sensor{
4545
public:
4646
/**
4747
* 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.
4950
*/
5051
virtual float getShaftAngle();
5152

5253
/**
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.
5457
* Note that this value has limited precision as the number of rotations increases,
5558
* because the limited precision of float can't capture the large angle of the full
5659
* rotations and the small angle of the shaft angle at the same time.
@@ -60,18 +63,23 @@ class Sensor{
6063
/**
6164
* On architectures supporting it, this will return a double precision position value,
6265
* 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.
6368
*/
6469
virtual double getPreciseAngle();
6570

6671
/**
6772
* Get current angular velocity (rad/s)
6873
* 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.
7076
*/
7177
virtual float getVelocity();
7278

7379
/**
7480
* 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.
7583
*/
7684
virtual int32_t getFullRotations();
7785

@@ -107,12 +115,12 @@ class Sensor{
107115
virtual float getSensorAngle()=0;
108116

109117
// 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
111119
long angle_prev_ts=0; // timestamp of last call to getAngle, used for velocity
112120
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
114122
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
116124
};
117125

118126
#endif

0 commit comments

Comments
 (0)