File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ float MagneticSensorAnalog::getVelocity(){
72
72
float MagneticSensorAnalog::initRelativeZero (){
73
73
74
74
float angle_offset = -getAngle ();
75
- zero_offset = getRawCount ();
75
+ zero_offset = natural_direction * getRawCount ();
76
76
77
77
// angle tracking variables
78
78
full_rotation_offset = 0 ;
@@ -81,14 +81,14 @@ float MagneticSensorAnalog::initRelativeZero(){
81
81
// set absolute zero angle as zero angle
82
82
// return the angle [rad] difference
83
83
float MagneticSensorAnalog::initAbsoluteZero (){
84
-
85
- // don't reset zero offset, making adjustments in sensor
86
- // zero_offset = 0;
84
+ float rotation = -( int )zero_offset;
85
+ // init absolute zero
86
+ zero_offset = 0 ;
87
87
88
88
// angle tracking variables
89
89
full_rotation_offset = 0 ;
90
-
91
- return 0 ;
90
+ // return offset in radians
91
+ return rotation / ( float )cpr * _2PI ;
92
92
}
93
93
// returns 0 if it has no absolute 0 measurement
94
94
// 0 - incremental encoder without index
You can’t perform that action at this time.
0 commit comments