Skip to content

Commit

Permalink
Made fixes to pass code analysis tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jkerpe committed Oct 18, 2023
1 parent bb61648 commit f92f632
Show file tree
Hide file tree
Showing 18 changed files with 142 additions and 324 deletions.
16 changes: 0 additions & 16 deletions lib/HALInterfaces/IBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@
*****************************************************************************/
#include <stdint.h>
#include <IButton.h>
#include <IBuzzer.h>
#include <IDisplay.h>
#include <IEncoders.h>
#include <ILineSensors.h>
#include <IMotors.h>
#include <ILed.h>
#include <IProximitySensors.h>
#include <IIMU.h>

/******************************************************************************
Expand Down Expand Up @@ -102,13 +100,6 @@ class IBoard
*/
virtual IButton& getButtonC() = 0;

/**
* Get buzzer driver.
*
* @return Buzzer driver.
*/
virtual IBuzzer& getBuzzer() = 0;

/**
* Get LCD driver.
*
Expand Down Expand Up @@ -158,13 +149,6 @@ class IBoard
*/
virtual ILed& getGreenLed() = 0;

/**
* Get proximity sensors driver.
*
* @return Proximity sensors driver
*/
virtual IProximitySensors& getProximitySensors() = 0;

/**
* Get IMU driver.
*
Expand Down
8 changes: 0 additions & 8 deletions lib/HALInterfaces/IIMU.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,6 @@ class IIMU
*/
virtual const double getMagnetometerValue() = 0;

/**
* Get number of axis used.
*
* @return number of axis which are evaluated
*/
virtual const uint8_t getNumberOfAccelerometerAxis() = 0;


/**
* Checks whether the calibration was successful or not.
*
Expand Down
7 changes: 0 additions & 7 deletions lib/HALSim/Board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,6 @@ const char* Board::LED_YELLOW_NAME = "led_yellow";
/* Name of the green LED in the robot simulation. */
const char* Board::LED_GREEN_NAME = "led_green";

/* Name of the front left proximity sensor in the robot simulation. */
const char* Board::PROXIMITY_SENSOR_FRONT_LEFT_NAME = "proxim_sensor_fl";

/* Name of the front right proximity sensor in the robot simulation. */
const char* Board::PROXIMITY_SENSOR_FRONT_RIGHT_NAME = "proxim_sensor_fr";

/* Name of the accelerometer in the robot simulation. */
const char* Board::ACCELEROMETER_NAME = "accelerometer";

Expand All @@ -143,7 +137,6 @@ void Board::init()
m_keyboard.init();
m_lineSensors.init();
m_motors.init();
m_proximitySensors.initFrontSensor();
m_imu.init();
}

Expand Down
37 changes: 0 additions & 37 deletions lib/HALSim/Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,13 @@
#include <ButtonA.h>
#include <ButtonB.h>
#include <ButtonC.h>
#include <Buzzer.h>
#include <Display.h>
#include <Encoders.h>
#include <LineSensors.h>
#include <Motors.h>
#include <LedRed.h>
#include <LedYellow.h>
#include <LedGreen.h>
#include <ProximitySensors.h>
#include <IMU.h>

#include <math.h>
Expand Down Expand Up @@ -124,16 +122,6 @@ class Board : public IBoard
return m_buttonC;
}

/**
* Get buzzer driver.
*
* @return Buzzer driver.
*/
IBuzzer& getBuzzer() final
{
return m_buzzer;
}

/**
* Get LCD driver.
*
Expand Down Expand Up @@ -204,16 +192,6 @@ class Board : public IBoard
return m_ledGreen;
}

/**
* Get proximity sensors driver.
*
* @return Proximity sensors driver
*/
IProximitySensors& getProximitySensors() final
{
return m_proximitySensors;
}

/**
* Get Accelerometer.
*
Expand Down Expand Up @@ -283,12 +261,6 @@ class Board : public IBoard
/** Name of the green LED in the robot simulation. */
static const char* LED_GREEN_NAME;

/** Name of the front proximity sensor in the robot simulation. */
static const char* PROXIMITY_SENSOR_FRONT_LEFT_NAME;

/** Name of the front right proximity sensor in the robot simulation. */
static const char* PROXIMITY_SENSOR_FRONT_RIGHT_NAME;

/** Name of the accelerometer in the robot simulation. */
static const char* ACCELEROMETER_NAME;

Expand Down Expand Up @@ -316,9 +288,6 @@ class Board : public IBoard
/** Button C driver */
ButtonC m_buttonC;

/** Buzzer driver */
Buzzer m_buzzer;

/** Display driver */
Display m_display;

Expand All @@ -339,9 +308,6 @@ class Board : public IBoard

/** Red LED driver */
LedGreen m_ledGreen;

/** Proximity sensors */
ProximitySensors m_proximitySensors;

/** Accelerometer */
IMU m_imu;
Expand All @@ -357,7 +323,6 @@ class Board : public IBoard
m_buttonA(m_keyboard),
m_buttonB(m_keyboard),
m_buttonC(m_keyboard),
m_buzzer(m_robot.getSpeaker(SPEAKER_NAME)),
m_display(m_robot.getDisplay(DISPLAY_NAME)),
m_encoders(m_simTime, m_robot.getPositionSensor(POS_SENSOR_LEFT_NAME),
m_robot.getPositionSensor(POS_SENSOR_RIGHT_NAME)),
Expand All @@ -370,8 +335,6 @@ class Board : public IBoard
m_ledRed(m_robot.getLED(LED_RED_NAME)),
m_ledYellow(m_robot.getLED(LED_YELLOW_NAME)),
m_ledGreen(m_robot.getLED(LED_GREEN_NAME)),
m_proximitySensors(m_simTime, m_robot.getDistanceSensor(PROXIMITY_SENSOR_FRONT_LEFT_NAME),
m_robot.getDistanceSensor(PROXIMITY_SENSOR_FRONT_RIGHT_NAME)),
m_imu(m_simTime, m_robot.getAccelerometer(ACCELEROMETER_NAME), m_robot.getGyro(GYRO_NAME), m_robot.getCompass(MAGNETOMETER_NAME))
{
}
Expand Down
15 changes: 1 addition & 14 deletions lib/HALSim/IMU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*****************************************************************************/
#include "IMU.h"
#include <iostream>
#include <cmath> // to do: entfernen
#include <cmath>
# define M_PI 3.14159265358979323846
/******************************************************************************
* Compiler Switches
Expand Down Expand Up @@ -114,16 +114,10 @@ const double IMU::getMagnetometerValue()
if (magnetometerValues != nullptr) {
double angleInRadians = atan2(magnetometerValues[INDEX_OF_Y_AXIS], magnetometerValues[INDEX_OF_X_AXIS]);
m_gyroValue = angleInRadians;
std::cout << "IMU.cpp: Magnetometer = " << m_gyroValue<< std::endl;
}
return m_gyroValue;
}

const uint8_t IMU::getNumberOfAccelerometerAxis()
{
return NUMBER_OF_AXIS;
}

bool IMU::isCalibrationSuccessful()
{
// to do: implement
Expand All @@ -146,10 +140,3 @@ bool IMU::isCalibrationSuccessful()
/******************************************************************************
* Local Functions
*****************************************************************************/
void transformFromUToX(double* result, const double* vectorP, const double* vectorX, const double& angle) {
double cosAngle = cos(angle);
double sinAngle = sin(angle);

result[0] = cosAngle * vectorP[0] - sinAngle * vectorP[1] + vectorX[0];
result[1] = sinAngle * vectorP[0] + cosAngle * vectorP[1] + vectorX[1];
}
39 changes: 17 additions & 22 deletions lib/HALSim/IMU.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ class IMU : public IIMU
m_accelerometer(accelerometer),
m_gyro(gyro),
m_magnetometer(compass),

m_calibErrorInfo(CALIB_ERROR_NOT_CALIBRATED),
m_accelerationValues(),
m_gyroValue(),
m_magnetometerValue(),
m_sensorCalibSuccessful(false),
m_sensorCalibStarted(false),
m_samplingPeriod(10) // to do: woher kommt wert?
Expand Down Expand Up @@ -117,15 +120,7 @@ class IMU : public IIMU
*/
//
const double getMagnetometerValue() final;


/**
* Get number of axis used.
*
* @return number of axis which are evaluated
*/
const uint8_t getNumberOfAccelerometerAxis() final;


/**
* Checks whether the calibration was successful or not.
*
Expand Down Expand Up @@ -157,17 +152,17 @@ class IMU : public IIMU
static const uint8_t INDEX_OF_Z_AXIS = 2;


const SimTime& m_simTime; /**< Simulation time */
webots::Accelerometer* m_accelerometer; /**< The accelerometer */
webots::Gyro* m_gyro; /**< The gyro */
webots::Compass* m_magnetometer; /**< The magnetometer */
uint8_t m_calibErrorInfo; /**< Indicates which sensor failed the calibration, if the calibration failed. */
bool m_sensorCalibSuccessful; /**< Indicates weather the calibration was successfull or not. */
bool m_sensorCalibStarted; /**< Indicates weather the calibration has started or not. */
double m_accelerationValues[NUMBER_OF_AXIS]; /**< The last value of each sensor */
double m_gyroValue;
double m_magnetometerValue;
int m_samplingPeriod;
const SimTime& m_simTime; /**< Simulation time */
webots::Accelerometer* m_accelerometer; /**< The accelerometer */
webots::Gyro* m_gyro; /**< The gyro */
webots::Compass* m_magnetometer; /**< The magnetometer */
uint8_t m_calibErrorInfo; /**< Indicates which sensor failed the calibration, if the calibration failed. */
bool m_sensorCalibSuccessful; /**< Indicates weather the calibration was successfull or not. */
bool m_sensorCalibStarted; /**< Indicates weather the calibration has started or not. */
double m_accelerationValues[NUMBER_OF_AXIS]; /**< The last values of the acceleration sensor */
double m_gyroValue; /**< The last value of the gyroscope around the z-axis*/
double m_magnetometerValue; /**< The last value of the magnetometer */
int m_samplingPeriod; /**< The sampling Period of the IMU Sensors*/

/* Default constructor not allowed. */
IMU();
Expand All @@ -177,5 +172,5 @@ class IMU : public IIMU
* Functions
*****************************************************************************/

#endif /* LINESENSORS_H */
#endif /* IMU_H */
/** @} */
1 change: 0 additions & 1 deletion lib/HALTarget/Board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ void Board::init()
m_encoders.init();
m_lineSensors.init();
m_motors.init();
m_proximitySensors.initFrontSensor();
}

/******************************************************************************
Expand Down
30 changes: 0 additions & 30 deletions lib/HALTarget/Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,13 @@
#include <ButtonA.h>
#include <ButtonB.h>
#include <ButtonC.h>
#include <Buzzer.h>
#include <Display.h>
#include <Encoders.h>
#include <LineSensors.h>
#include <Motors.h>
#include <LedRed.h>
#include <LedYellow.h>
#include <LedGreen.h>
#include <ProximitySensors.h>
#include <IMU.h>

/******************************************************************************
Expand Down Expand Up @@ -120,16 +118,6 @@ class Board : public IBoard
return m_buttonC;
}

/**
* Get buzzer driver.
*
* @return Buzzer driver.
*/
IBuzzer& getBuzzer() final
{
return m_buzzer;
}

/**
* Get LCD driver.
*
Expand Down Expand Up @@ -200,16 +188,6 @@ class Board : public IBoard
return m_ledGreen;
}

/**
* Get proximity sensors driver.
*
* @return Proximity sensors driver
*/
IProximitySensors& getProximitySensors() final
{
return m_proximitySensors;
}

/**
* Get IMU driver.
*
Expand All @@ -233,9 +211,6 @@ class Board : public IBoard
/** Button C driver */
ButtonC m_buttonC;

/** Buzzer driver */
Buzzer m_buzzer;

/** Display driver */
Display m_display;

Expand All @@ -257,9 +232,6 @@ class Board : public IBoard
/** Red LED driver */
LedGreen m_ledGreen;

/** Proximity sensors */
ProximitySensors m_proximitySensors;

/** IMU */
IMU m_imu;

Expand All @@ -271,15 +243,13 @@ class Board : public IBoard
m_buttonA(),
m_buttonB(),
m_buttonC(),
m_buzzer(),
m_display(),
m_encoders(),
m_lineSensors(),
m_motors(),
m_ledRed(),
m_ledYellow(),
m_ledGreen(),
m_proximitySensors(),
m_imu()
{
}
Expand Down
Loading

0 comments on commit f92f632

Please sign in to comment.