Several other libraries, such as EZ-Template and JAR-Template, provide the option to scale the IMU reading to adjust for slight inaccuracies in the sensor. I was trying to find this option in LemLib, but I couldn’t see it in the API.
Is IMU scaling available in LemLib? If not, are there plans to implement it?
1 Like
Not where you can just put a parameter in, but somewhere in the discord there is a post detailing how you can modify the IMU class/header to scale it.
Apparently you got to do something like this:
class CustomIMU : public pros::IMU {
public:
CustomIMU(int port, double scalar)
: pros::IMU(port),
m_port(port),
m_scalar(scalar) {}
virtual double get_rotation() const {
return pros::c::imu_get_rotation(m_port) * m_scalar;
}
private:
const int m_port;
const double m_scalar;
};
// create custom IMU with a scalar of 1.1
CustomIMU my_imu(14, 1.1);
lemlib::OdomSensors sensors(nullptr, nullptr, nullptr, nullptr, &my_imu);```
2 Likes