Example of gathering IMU data from SeekurSample program that demonstrates how to get IMU data from an IMU on a Seekur-class robot (from SeekurOS). Only some Seekurs have IMUs.
[Some Pioneers also have gyros that are integrated into the robot and normally automatically correct data or which can optionally return the data seperately (using different packets and different ARIA interface in ArAnalogGyro).]
The data comes back in a custom packet with ID 0x9A. It's requested with client command 26.
Press escape to exit the program.
#include "Aria.h"
#include <time.h>
if (packet->
getID() != 0x9a) {
return false;
}
ArLog::log(
ArLog::Normal,
"got IMUpac, %dms since readings took place, %d readings per axis", timeSince, numPerAxis);
int i;
int range;
double x = 0.0;
double y = 0.0;
double z = 0.0;
double multiplier = 0.0;
double offset = 0.0;
for (i=1; i <= numPerAxis; i++) {
x = 0.0;
y = 0.0;
z = 0.0;
if (range == 3) {
multiplier = 0.07326;
offset = 0.0;
}
else if (range == 2) {
multiplier = 0.03663;
offset = 0.0;
}
else if (range == 1) {
multiplier = 0.01832;
offset = 0.0;
}
if (numGyroAxes >= 1) {
}
if (numGyroAxes >= 2) {
}
if (numGyroAxes >= 3) {
}
i, numPerAxis, x, y, z);
}
for (i=1; i <= numPerAxis; i++) {
x = 0.0;
y = 0.0;
z = 0.0;
multiplier = 0.002522 * 9806.65;
offset = 0.0;
if (numAccelAxes >= 1) {
}
if (numAccelAxes >= 2) {
}
if (numAccelAxes >= 3) {
}
i, numPerAxis, x, y, z);
}
int numTemperatureAxes = packet->
bufToByte();
for (i=1; i <= numPerAxis; i++) {
x = 0.0;
y = 0.0;
z = 0.0;
multiplier = 0.1453;
offset = 25.0;
if (numTemperatureAxes >= 1) {
}
if (numTemperatureAxes >= 2) {
}
if (numTemperatureAxes >= 3) {
}
i, numPerAxis, x, y, z);
}
return true;
}
int main(int argc, char **argv) {
}
}
exit(0);
}