-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added comments for IMU function headers #13
base: develop
Are you sure you want to change the base?
Changes from all commits
fe511ab
cf0eb79
feb714d
cb8ae01
cb234b1
7bcafa6
782207a
3d80e8f
e30ce26
e5cf538
28cc8cb
e976cfa
eed78e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,10 @@ int mspeed2, mspeed4 = MOTOR_MIN; // Motors along the y-axis | |
//=> Changing their speeds will affect the roll | ||
|
||
|
||
/* | ||
* Function to initialize the Gyro sample rate. | ||
* Measure and Set the base offset value for the gyro for better calculations in the GetAngleMeasurements function. | ||
*/ | ||
void InitGyro() | ||
{ | ||
// Set the internal sample rate to 1kHz and set the sample | ||
|
@@ -66,10 +70,10 @@ void InitGyro() | |
// Calculate an average offset for the gyro | ||
for (int i = 0; i < OFFSET_AVG_SAMPLES; i++) | ||
{ | ||
gyroOffsetX += gyro.getGyroX(); | ||
gyroOffsetY += gyro.getGyroY(); | ||
gyroOffsetX += gyro.getGyroX(); | ||
gyroOffsetY += gyro.getGyroY(); | ||
} | ||
|
||
// Uses the gyroOffset calculated above while getting the samples to give a more accurate offset value on startup for the gyro | ||
gyroOffsetX /= OFFSET_AVG_SAMPLES; | ||
gyroOffsetY /= OFFSET_AVG_SAMPLES; | ||
|
||
|
@@ -78,6 +82,12 @@ void InitGyro() | |
#endif | ||
} | ||
|
||
|
||
/* | ||
* Initialize the accelerometer and set the sample rate frequency. | ||
* Measure and set the base offset of the accelerometer at startup to give better | ||
* measurements in the GetAnglemeasurements function. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, align the '*' characters please. Capitalize! If you end a sentence, put a '.' character. |
||
void InitAccelerometer() | ||
{ | ||
// Put the ADXL345 into standby mode to configure the device | ||
|
@@ -100,7 +110,7 @@ void InitAccelerometer() | |
acclOffsetY += fg.y; | ||
acclOffsetZ += (fg.z - 1); | ||
} | ||
|
||
// Using the accelOffsets samples above to get the average value to give us a more accurate value startup offset value for the accel. | ||
acclOffsetX /= OFFSET_AVG_SAMPLES; | ||
acclOffsetY /= OFFSET_AVG_SAMPLES; | ||
acclOffsetZ /= OFFSET_AVG_SAMPLES; | ||
|
@@ -110,12 +120,24 @@ void InitAccelerometer() | |
#endif | ||
} | ||
|
||
|
||
/* | ||
* Initializes the Gyro and the accelerometer at startup. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comments above. |
||
void InitIMU(void) | ||
{ | ||
InitGyro(); | ||
InitAccelerometer(); | ||
InitGyro(); // Initialize the gyro | ||
InitAccelerometer(); // Initialize the accelerometer | ||
} | ||
|
||
|
||
/* | ||
* Function using a sample time to calculate the current angle over time. | ||
* The main features of this function are the filter for the accelerometer | ||
* the measurements gathered from the gyro to get the current angle | ||
* and the complimentary filter we used to get our accurate measurement of our | ||
* angle at any given point in time. | ||
*/ | ||
void GetAngleMeasurements() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, see comments above. |
||
{ | ||
if (((tcurr = t.read_ms()) - tprev) >= IMU_SAMPLE_TIME) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please align the '' characters like seen elsewhere. Also, the spaces between the '' characters and the first letter are way to long. Please, only one space.