At the FIRST Championships in April I checkout the Orbit Odyssey exhibit and I was given a gift of a miniXRP body. I bought a DIY kit with the new control board and built the miniXRP.
Everything worked great. EXCEPT the library functions which are relying on the IMU. Such as “turn”. The “turn” code uses yaw. But the miniXRP bot has the control board mounted vertically rather than horizontally. You can see the pictures of what it looks like at the miniXRP link above.
Going through the API, there is a “calibrate” method which I had hoped would allow me to change the orientation of the IMU. But regardless of what value I provide for the vertical_axis, the roll value is what changes when I rotate the bot.
This is what the API doc says about calibrating the IMU.
calibrate(calibration_time: float = 1, vertical_axis: int = 2)
Collect readings for [calibration_time] seconds and calibrate the IMU based on those readings.
Do not move the robot during this time Assumes the board to be parallel to the ground.
Please use the vertical_axis parameter if that is not correct
Parameters:
calibration_time (float) – The time in seconds to collect readings for
vertical_axis (int) – The axis that is vertical. 0 for X, 1 for Y, 2 for Z
Here’s the code I’m using for testing.
I’ve changed the vertical_axis parameter in the calibrate call but it didn’t change the results.
from XRPLib.defaults import *
import time
# Wait for user to press button
print("Press user button to start")
board.wait_for_button()
#calibration_time (float) – The time in seconds to collect readings for
#vertical_axis (int) – The axis that is vertical. 0 for X, 1 for Y, 2 for Z
imu.reset()
print("Calibrating IMU...")
imu.calibrate(1,0)
while not board.is_button_pressed():
y = imu.get_yaw()
p = imu.get_pitch()
r = imu.get_roll()
print(f"Yaw: {y:.1f} ")
print(f"Pitch: {p:.1f} ")
print(f"Roll: {r:.1f} ")
time.sleep(0.1)
# Wait until button is released
while board.is_button_pressed():
time.sleep(0.1)
So…is there any way to explain to the IMU that it is not mounted horizontally?