Skip to content

CurieIMU Doesn't Provide API For Sync To Gyroscope Rate #150

Closed
@PaulStoffregen

Description

@PaulStoffregen

CurieIMU allows the gyroscope measurement rate to be controlled with these functions:

https://www.arduino.cc/en/Reference/CurieIMUsetGyroRate
https://www.arduino.cc/en/Reference/CurieIMUgetGyroRate

However, there does not appear to be any API for an Arduino sketch to actually read the data at the proper rate. Functions like readGyro() return the stored data from hardware registers. If called rapidly, readGyro() will return the same data many times.

Normally Arduino libraries provide an available() function, to indicate whether (or how much) new data is available, which hasn't already been read.

Acquiring gyroscope data at the correct rate is particularly important. Gyroscopes measure angular velocity. Converting this to angular position with a Kalman or other filter algorithm involves integrating the angular velocity with respect to time.

If an Arduino sketch re-reads the same data, because it can't reliably know when the sensor has produced a new measurement, and it passes that data to a Kalman or similar integrating filter, the short-term rotational motion will be overestimated. The result is sketches using CurieIMU must resort to very poor design practice. For example, the Orientation Visualizer uses this kludge factor:

int factor = 800; // variable by which to divide gyroscope values, used to control sensitivity
// note that an increased baud rate requires an increase in value of factor

Obviously this is terrible design. The computed angular position depends heavily on the Curie's CPU speed, by how quickly it can run the loop() function. If you run the visualizer and vigorously shake the Arduino 101 board for several seconds and then let it rest, you'll see the visualizer almost always stops in a very wrong orientation, and then very slowly corrects itself over about a minute as the filter uses the accelerometer data to gradually correct for the massive errors caused by incorrect rate & improperly scaled gyroscope data.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions