-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
147 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.. _extras: | ||
|
||
Extra Modules | ||
============= | ||
|
||
Simple AHRS | ||
""""""""""" | ||
|
||
Simple attitude and heading reference system module can return pitch and roll angles using acceleration value. Include ``mpu925x_simple_ahrs.h`` in desired source file and compile ``mpu925x_simple_ahrs.c`` source file with target program. | ||
|
||
.. code-block:: c | ||
:caption: Example Code | ||
#include "mpu925x.h" | ||
#include "mpu925x_simple_ahrs.h" | ||
// Create struct instances. | ||
mpu925x_t mpu925x; | ||
mpu925x_simple_ahrs ahrs; | ||
// Initialize driver. | ||
mpu925x_init(&mpu925x, 0); | ||
// Get values. | ||
mpu925x_get_acceleration(&mpu925x); | ||
mpu925x_get_simple_ahrs(&mpu925x, &ahrs); | ||
printf("Pitch: %f, Roll: %f\n", ahrs.pitch, ahrs.roll); | ||
API Reference | ||
^^^^^^^^^^^^^ | ||
|
||
.. doxygenfile:: mpu925x_simple_ahrs.h | ||
:project: mpu925x-driver |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ Advanced Usage | |
accelerometer | ||
gyroscope | ||
magnetometer | ||
fifo | ||
extras |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* @file | ||
* @author Ceyhun Şen | ||
* @brief Simple AHRS source file for MPU-925X driver. | ||
* */ | ||
|
||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2022 Ceyhun Şen | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* */ | ||
|
||
#include "mpu925x_simple_ahrs.h" | ||
#include <math.h> | ||
|
||
/** | ||
* @brief Get pitch and roll angles. | ||
* @param mpu925x MPU-925X struct pointer. | ||
* @param ahrs Simple AHRS struct pointer. | ||
* */ | ||
void mpu925x_get_simple_ahrs(mpu925x_t *mpu925x, mpu925x_simple_ahrs *ahrs) | ||
{ | ||
ahrs->pitch = asin(mpu925x->sensor_data.acceleration[0] / sqrt(mpu925x->sensor_data.acceleration[0] * mpu925x->sensor_data.acceleration[0] + mpu925x->sensor_data.acceleration[1] * mpu925x->sensor_data.acceleration[1] + mpu925x->sensor_data.acceleration[2] * mpu925x->sensor_data.acceleration[2])) * 120; | ||
|
||
ahrs->roll = atan(mpu925x->sensor_data.acceleration[1] / mpu925x->sensor_data.acceleration[2]) * 120; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* @file | ||
* @author Ceyhun Şen | ||
* @brief Simple AHRS header file for MPU-925X driver. | ||
* */ | ||
|
||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2022 Ceyhun Şen | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* */ | ||
|
||
#ifndef __MPU925X_SIMPLE_AHRS_H | ||
#define __MPU925X_SIMPLE_AHRS_H | ||
|
||
#include "mpu925x.h" | ||
|
||
/** | ||
* @brief Pitch and roll angles for simple AHRS. | ||
* */ | ||
typedef struct mpu925x_simple_ahrs { | ||
float pitch; | ||
float roll; | ||
} mpu925x_simple_ahrs; | ||
|
||
void mpu925x_get_simple_ahrs(mpu925x_t *mpu925x, mpu925x_simple_ahrs *ahrs); | ||
|
||
#endif // __MPU925X_SIMPLE_AHRS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters