Comments (9)
I saw this in readme:
calibrate function in the lib
-- not as lib will grow too large.
I think it's over worry, right now GY521.cpp only 484 line of code.
Ask user to manually copy & paste the data numbers into application code is worse.
from gy521.
I think it's over worry, right now GY521.cpp only 484 line of code.
It is not about source code, it is about runtime code for different boards including boards with less memory.
If time permits I will check how much the footprint increases.
Ask user to manually copy & paste the data numbers into application code is worse.
Your proposal is valid if
- the application has enough time to calibrate at start-up.
- the system is in a stable state so it can be calibrated.
- it is less work for the user.
- probably more
However not all applications might have time to calibrate at every startup, as they need to be operational right away. Imagine a drone that gets a watchdog reset and it is falling from the sky, it is not stable so calibrating during restart is not possible. You will be happy it restarts with hard coded calibration data.
That said I will not close the issue right now,
- investigate the increase in footprint and time it might take.
- investigate how to overrule auto calibration at startup and fall back to hard coded numbers.
(not all boards have EEPROM)
from gy521.
Basically you have two concerns:
- increased memory footprint (which I think is small)
- when to call
calibrate()
If memory footprint is not a concern, at least provide such function, so the user can call in his/her application instead of manually copy & paste the data numbers into source code.
E.g. suppose it's a commercial product sold to thousands of customers, the end user should just press some button on the device if calibrate()
is needed (they have no access to the source code of the product).
from gy521.
As said above I keep the issue open and will investigate when time permits.
At this moment your other issue of the drifting PITCH has to be understood first (higher prio imho)
from gy521.
Ah, I just realized C/C++ has macro: so define a macro INCLUDE_CALIBRATE_IN_BUILD.
Then the users can define it in the Makefile, so even the memory footprint is not a concern. If the memory is really tight, those users can simply set INCLUDE_CALIBRATE_IN_BUILD=0 for his / her own device build.
from gy521.
Did a first test to check the footprint with one of the examples + UNO (as I have no sensor I cannot test duration)
hardcode errors: 10324 bytes + 747 RAM
calibrate(100): 11124 bytes + 747 RAM
Increase of 800 bytes footprint.
Duration not measured..
Adding duration math takes ~70 bytes on an UNO (estimate).
void GY521::calibrate(uint16_t times)
{
// set errors to zero
axe = aye = aze = 0;
gxe = gye = gze = 0;
// set measurements to zero
_ax = _ay = _az = 0;
_gx = _gy = _gz = 0;
for (uint16_t i = 0; i < times; i++)
{
read();
_ax -= getAccelX();
_ay -= getAccelY();
_az -= getAccelZ();
_gx -= getGyroX();
_gy -= getGyroY();
_gz -= getGyroZ();
}
// adjust calibration errors so table should get all zero's.
float factor = 1.0 / times;
axe += _ax * factor;
aye += _ay * factor;
aze += _az * factor;
gxe += _gx * factor;
gye += _gy * factor;
gze += _gz * factor;
}
from gy521.
smaller version
void GY521::calibrate(uint16_t times)
{
// set errors to zero
axe = aye = aze = 0;
gxe = gye = gze = 0;
for (uint16_t i = 0; i < times; i++)
{
read();
axe -= getAccelX();
aye -= getAccelY();
aze -= getAccelZ();
gxe -= getGyroX();
gye -= getGyroY();
gze -= getGyroZ();
}
// adjust calibration errors so table should get all zero's.
float factor = 1.0 / times;
axe *= factor;
aye *= factor;
aze *= factor;
gxe *= factor;
gye *= factor;
gze *= factor;
}
10956 - 10324 = 632 bytes more.
PS,
while posting this I realize throttling must be disabled and set to previous state to get non-cached reads.
So it needs 3 additional lines to handle that (12 bytes)
to be continued
from gy521.
Note:
think calibrate() must be called after setAccelSensitivity(as); and setGyroSensitivity(gs);
from gy521.
Going to merge the develop branch / PR - #49
This will include the calibrate() function as above and some more.
It does not include new Pitch Roll Yaw code
from gy521.
Related Issues (20)
- Examples use GetAngle instead of GetAccel HOT 2
- Enabling the interruptions HOT 6
- Calibration never zeros out HOT 7
- Add multiWire support
- improve performance + precision
- improve precision HOT 1
- swire support HOT 27
- Invalid data without Reset while initializing the begin HOT 9
- version number incorrect in .h and .cpp (minor)
- getting position from distance = acceleration * time HOT 7
- Raw data HOT 1
- getYaw, getPitch and getRoll go past 360 degrees HOT 19
- small bugfix in readCalibration HOT 3
- How can I get data from 2 sensors? HOT 4
- Shifted pitch and yaw measurement HOT 19
- why when I run the GY521_pitch_roll_yaw example code, all the numbers slowly increase 0 -> 359 -> 0? HOT 22
- use float variables in example GY521_test_1.ino HOT 1
- Feature request: API for low-pass filter HOT 4
- add getAddress() function
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gy521.