diff --git a/lib/HALInterfaces/IIMU.h b/lib/HALInterfaces/IIMU.h index f8e1014a..7d696317 100644 --- a/lib/HALInterfaces/IIMU.h +++ b/lib/HALInterfaces/IIMU.h @@ -25,7 +25,7 @@ DESCRIPTION *******************************************************************************/ /** - * @brief Abstract IMU interface + * @brief Abstract IMU interface, depicts Zumo32U4IMU library * @author Juliane Kerpe * * @addtogroup HALInterfaces @@ -52,16 +52,6 @@ * Types and Classes *****************************************************************************/ - -/** - * Own enum is necessary since it is only defined in the Zumo32U4-Library and will therefor only be found on HALTarget and not HALSim. - */ -enum class Zumo32U4IMUTypeRU : uint8_t { - Unknown, - LSM303D_L3GD20H, - LSM6DS33_LIS3MDL -}; - /** The abstract IMU interface. */ class IIMU { @@ -79,13 +69,6 @@ class IIMU * @return True if the sensor type was detected succesfully; false otherwise. */ virtual bool init() = 0; - - /** - * Returns the type of the inertial sensors on the Zumo 32U4. - * - * @return The sensor type as a member of the Zumo32U4IMUType enum. If the type is not known (e.g. if init() has not been called yet), this will be Zumo32U4IMUType::Unknown. - */ - virtual Zumo32U4IMUTypeRU getType() = 0; /** * Enables all of the inertial sensors with a default configuration. @@ -96,15 +79,6 @@ class IIMU * Configures the sensors with settings optimized for turn sensing. */ virtual void configureForTurnSensing() = 0; - - /** - * Writes an 8-bit sensor register. - * - * @param[in] addr Device address. - * @param[in] reg Register address. - * @param[in] value 8-bit register value to be written. - */ - virtual void writeReg(uint8_t addr, uint8_t reg, uint8_t value) = 0; /** * Takes a reading from the accelerometer and makes the measurements available in a. diff --git a/lib/HALSim/IMU.cpp b/lib/HALSim/IMU.cpp index 24174fe4..6a5a199b 100644 --- a/lib/HALSim/IMU.cpp +++ b/lib/HALSim/IMU.cpp @@ -65,11 +65,6 @@ bool IMU::init() return true; } -Zumo32U4IMUTypeRU IMU::getType() -{ - return m_sensorType; -} - void IMU::readAcc() { const double * accelerationValues = m_accelerometer->getValues(); diff --git a/lib/HALSim/IMU.h b/lib/HALSim/IMU.h index 82634efa..60830d42 100644 --- a/lib/HALSim/IMU.h +++ b/lib/HALSim/IMU.h @@ -58,12 +58,6 @@ * Types and Classes *****************************************************************************/ -enum class Zumo32U4IMUType : uint8_t { - Unknown, - LSM303D_L3GD20H, - LSM6DS33_LIS3MDL -}; - /** The IMU adapter. */ class IMU : public IIMU { @@ -81,8 +75,7 @@ class IMU : public IIMU m_simTime(simTime), m_accelerometer(accelerometer), m_gyro(gyro), - m_magnetometer(compass), - m_sensorType(Zumo32U4IMUTypeRU::LSM303D_L3GD20H) + m_magnetometer(compass) { } @@ -99,13 +92,6 @@ class IMU : public IIMU * @return True if the sensor type was detected succesfully; false otherwise. */ bool init(); - - /** - * Returns the type of the inertial sensors on the Zumo 32U4. - * - * @return The sensor type as a member of the Zumo32U4IMUType enum. If the type is not known (e.g. if init() has not been called yet), this will be Zumo32U4IMUType::Unknown. - */ - Zumo32U4IMUTypeRU getType(); /** * Enables all of the inertial sensors with a default configuration. @@ -116,15 +102,6 @@ class IMU : public IIMU * Configures the sensors with settings optimized for turn sensing. */ void configureForTurnSensing() {} - - /** - * Writes an 8-bit sensor register. - * - * @param[in] addr Device address. - * @param[in] reg Register address. - * @param[in] value 8-bit register value to be written. - */ - void writeReg(uint8_t addr, uint8_t reg, uint8_t value) {}; /** * Takes a reading from the accelerometer and makes the measurements available in a. @@ -199,7 +176,6 @@ class IMU : public IIMU webots::Accelerometer* m_accelerometer; /**< The accelerometer of Webots. */ webots::Gyro* m_gyro; /**< The gyro of Webots. */ webots::Compass* m_magnetometer; /**< The magnetometer of Webots. */ - Zumo32U4IMUTypeRU m_sensorType; /**< The type of the IMU. */ }; /****************************************************************************** diff --git a/lib/HALTarget/Board.cpp b/lib/HALTarget/Board.cpp index 6fbd9c26..0aee127c 100644 --- a/lib/HALTarget/Board.cpp +++ b/lib/HALTarget/Board.cpp @@ -77,22 +77,7 @@ void Board::init() m_motors.init(); m_imu.init(); m_imu.enableDefault(); - m_imu.configureForTurnSensing(); - - switch(m_imu.getType()) - { - case Zumo32U4IMUTypeRU::LSM303D_L3GD20H: - // 0x00 means +/- 245 dps according to L3GD20H data sheet - m_imu.writeReg(L3GD20H_ADDR, L3GD20H_REG_CTRL4, 0x00); - break; - case Zumo32U4IMUTypeRU::LSM6DS33_LIS3MDL: - // 0x00 means +/- 245 dps according to LSM6DS33 data sheet - m_imu.writeReg(LSM6DS33_ADDR, LSM6DS33_REG_CTRL2_G, 00); - break; - default: - ; - } - + m_imu.configureForTurnSensing(); m_imu.calibrate(); } diff --git a/lib/HALTarget/IMU.cpp b/lib/HALTarget/IMU.cpp index 9356f8b8..28e539af 100644 --- a/lib/HALTarget/IMU.cpp +++ b/lib/HALTarget/IMU.cpp @@ -63,15 +63,23 @@ bool IMU::init() if (isInitSuccessful) { m_imu.enableDefault(); } + + switch(m_imu.getType()) + { + case Zumo32U4IMUType::LSM303D_L3GD20H: + // 0x00 means +/- 245 dps according to L3GD20H data sheet + m_imu.writeReg(L3GD20H_ADDR, L3GD20H_REG_CTRL4, 0x00); + break; + case Zumo32U4IMUType::LSM6DS33_LIS3MDL: + // 0x00 means +/- 245 dps according to LSM6DS33 data sheet + m_imu.writeReg(LSM6DS33_ADDR, LSM6DS33_REG_CTRL2_G, 00); + break; + default: + ; + } return isInitSuccessful; } -Zumo32U4IMUTypeRU IMU::getType() -{ - /* Return the Sensor Type mapped to the own enum class defined in IIMU. */ - return static_cast(m_imu.getType()); -} - void IMU::enableDefault() { m_imu.enableDefault(); @@ -82,11 +90,6 @@ void IMU::configureForTurnSensing() m_imu.configureForTurnSensing(); } -void IMU::writeReg(uint8_t addr, uint8_t reg, uint8_t value) -{ - m_imu.writeReg(addr, reg, value); -} - void IMU::readAcc() { while(!m_imu.accDataReady()){} diff --git a/lib/HALTarget/IMU.h b/lib/HALTarget/IMU.h index e1234234..de1b483f 100644 --- a/lib/HALTarget/IMU.h +++ b/lib/HALTarget/IMU.h @@ -90,13 +90,6 @@ class IMU : public IIMU * @return True if the sensor type was detected succesfully; false otherwise. */ bool init(); - - /** - * Returns the type of the inertial sensors on the Zumo 32U4. - * - * @return The sensor type as a member of the Zumo32U4IMUType enum. If the type is not known (e.g. if init() has not been called yet), this will be Zumo32U4IMUType::Unknown. - */ - Zumo32U4IMUTypeRU getType(); /** * Enables all of the inertial sensors with a default configuration. @@ -107,15 +100,6 @@ class IMU : public IIMU * Configures the sensors with settings optimized for turn sensing. */ void configureForTurnSensing(); - - /** - * Writes an 8-bit sensor register. - * - * @param[in] addr Device address. - * @param[in] reg Register address. - * @param[in] value 8-bit register value to be written. - */ - void writeReg(uint8_t addr, uint8_t reg, uint8_t value); /** * Takes a reading from the accelerometer and makes the measurements available in a. diff --git a/lib/HALTest/IMU.h b/lib/HALTest/IMU.h index 44786509..63d00e74 100644 --- a/lib/HALTest/IMU.h +++ b/lib/HALTest/IMU.h @@ -62,13 +62,6 @@ class IMU : public IIMU * @return True if the sensor type was detected succesfully; false otherwise. */ bool init(){return true;} - - /** - * Returns the type of the inertial sensors on the Zumo 32U4. - * - * @return The sensor type as a member of the Zumo32U4IMUType enum. If the type is not known (e.g. if init() has not been called yet), this will be Zumo32U4IMUType::Unknown. - */ - Zumo32U4IMUTypeRU getType() {return Zumo32U4IMUTypeRU::LSM303D_L3GD20H;} /** * Enables all of the inertial sensors with a default configuration. @@ -79,15 +72,6 @@ class IMU : public IIMU * Configures the sensors with settings optimized for turn sensing. */ void configureForTurnSensing() {} - - /** - * Writes an 8-bit sensor register. - * - * @param[in] addr Device address. - * @param[in] reg Register address. - * @param[in] value 8-bit register value to be written. - */ - void writeReg(uint8_t addr, uint8_t reg, uint8_t value){} /** * Takes a reading from the accelerometer and makes the measurements available in a.