-
Notifications
You must be signed in to change notification settings - Fork 2
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
WIP: Gyro calibration #11
base: main
Are you sure you want to change the base?
Conversation
(not tested yet)
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.
Great feature! Linked to #5
src/imu/adis16448.cpp
Outdated
auto ygyro_off = readReg(0x1C); | ||
auto zgyro_off = readReg(0x1E); | ||
|
||
std::cout << "Gyro offers after reset:\n" << xgyro_off[0] << " , " << xgyro_off[1] << " , " << ygyro_off[1] << " , " << zgyro_off[1] << std::endl; |
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.
Use lpp
std::cout << "Gyro offers after reset:\n" << xgyro_off[0] << " , " << xgyro_off[1] << " , " << ygyro_off[1] << " , " << zgyro_off[1] << std::endl; | |
LOG(I, std::hex << "Gyro offset after reset: " << ": 0x" << +xgyro_off[0] << ", 0x" << +xgyro_off[1] << ", 0x" << +xgyro_off[2]); |
src/imu/adis16448.cpp
Outdated
@@ -226,6 +226,47 @@ int Adis16448::signedWordToInt(const std::vector<byte> &word) { | |||
return (((int) *(signed char *) (word.data())) * 1 << CHAR_BIT) | word[1]; | |||
} | |||
|
|||
bool Adis16448::calibrateGyro(){ | |||
// set offsets to zero | |||
writeReg(0x1A, {0x00, 0x00}, "XGYRO_OFF"); |
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.
Use the command definitions, e.g.,
writeReg(0x1A, {0x00, 0x00}, "XGYRO_OFF"); | |
writeReg(XGYRO_OFF, {0x00, 0x00}, "XGYRO_OFF"); |
src/imu/adis16448.cpp
Outdated
std::cout << "Starting Gyro Calibration. Keep IMU steady and wait for 40s.." << std::endl; | ||
writeReg(SENS_AVG, calib_sens_avg, "CALIB_SENS_AVG"); | ||
writeReg(SMPL_PRD, calib_smpl_prd, "CALIB_SMPL_PRD"); | ||
usleep(40*1e6); // wait for next measurement |
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.
I think instead of a fixed sleeping time, you can also poll the IMU and see if the value changes... But not sure how robust this is. Or calculate the sampling time from the register value to make it adaptable.
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.
good idea!
src/imu/adis16448.cpp
Outdated
writeReg(SENS_AVG, sens_avg, "SENS_AVG"); | ||
writeReg(SMPL_PRD, smpl_prd, "SMPL_PRD"); | ||
|
||
return true; |
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.
It would be nice to configure the alarm on the IMU in case the platform is moved during calibration progress and then return false.
Ah, nice! Thanks for the feedback! I will change the stuff and still need to test it as well. I also want to look at how/if the gyro_off values reset when the imu is power cycled. If they get reset we could call the calibration method once at the first start (when all gyro_off values are zero) and then leave them until the imu is turned off again. |
Also publishes latched topic with the set offset values.
per default calibration is turned off
Adds gyro calibration which can be started through a ROS service call