Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/BlueAndi/RadonUlzer into Se…
Browse files Browse the repository at this point in the history
…nsorFusion/base
  • Loading branch information
jkerpe committed Dec 4, 2023
2 parents 83c581e + 7fec382 commit f76b2e1
Show file tree
Hide file tree
Showing 26 changed files with 129 additions and 113 deletions.
23 changes: 7 additions & 16 deletions lib/APPConvoyLeader/DrivingState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DESCRIPTION
*******************************************************************************/
/**
* @brief Calibration state
* @brief Driving state
* @author Andreas Merkle <[email protected]>
*/

Expand Down Expand Up @@ -77,8 +77,6 @@ void DrivingState::entry()
m_trackStatus = TRACK_STATUS_ON_TRACK; /* Assume that the robot is placed on track. */
m_posMovAvg.clear();

diffDrive.enable();

/* Configure PID controller with selected parameter set. */
m_topSpeed = parSet.topSpeed;
m_pidCtrl.clear();
Expand Down Expand Up @@ -140,16 +138,17 @@ void DrivingState::process(StateMachine& sm)

void DrivingState::exit()
{
DifferentialDrive& diffDrive = DifferentialDrive::getInstance();

diffDrive.disable();
m_observationTimer.stop();
Board::getInstance().getYellowLed().enable(false);
}

/* PROTECTED METHODES *****************************************************************************/
/******************************************************************************
* Protected Methods
*****************************************************************************/

/* PRIVATE METHODES *******************************************************************************/
/******************************************************************************
* Private Methods
*****************************************************************************/

void DrivingState::processOnTrack(int16_t position, const uint16_t* lineSensorValues)
{
Expand Down Expand Up @@ -363,14 +362,6 @@ void DrivingState::adaptDriving(int16_t position)
diffDrive.setLinearSpeed(leftSpeed, rightSpeed);
}

/******************************************************************************
* Protected Methods
*****************************************************************************/

/******************************************************************************
* Private Methods
*****************************************************************************/

/******************************************************************************
* External Functions
*****************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion lib/APPConvoyLeader/ErrorState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DESCRIPTION
*******************************************************************************/
/**
* @brief Calibration state
* @brief Error state
* @author Andreas Merkle <[email protected]>
*/

Expand Down
4 changes: 0 additions & 4 deletions lib/APPConvoyLeader/LineSensorsCalibrationState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ void LineSensorsCalibrationState::entry()
/* Prepare calibration drive. */
m_calibrationSpeed = diffDrive.getMaxMotorSpeed() / 3;
m_orientation = odometry.getOrientation();
diffDrive.enable();

/* Wait some time, before starting the calibration drive. */
m_phase = PHASE_1_WAIT;
Expand Down Expand Up @@ -134,9 +133,6 @@ void LineSensorsCalibrationState::process(StateMachine& sm)

void LineSensorsCalibrationState::exit()
{
DifferentialDrive& diffDrive = DifferentialDrive::getInstance();

diffDrive.disable();
m_timer.stop();
}

Expand Down
3 changes: 3 additions & 0 deletions lib/APPConvoyLeader/MotorSpeedCalibrationState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ void MotorSpeedCalibrationState::finishCalibration(StateMachine& sm)
*/
diffDrive.setMaxMotorSpeed(maxSpeed);

/* Differential drive can now be used. */
diffDrive.enable();

if (0 == maxSpeed)
{
ErrorState::getInstance().setErrorMsg("MS=0");
Expand Down
2 changes: 1 addition & 1 deletion lib/APPConvoyLeader/ReadyState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DESCRIPTION
*******************************************************************************/
/**
* @brief Calibration state
* @brief Ready state
* @author Andreas Merkle <[email protected]>
*/

Expand Down
23 changes: 7 additions & 16 deletions lib/APPLineFollower/DrivingState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DESCRIPTION
*******************************************************************************/
/**
* @brief Calibration state
* @brief Driving state
* @author Andreas Merkle <[email protected]>
*/

Expand Down Expand Up @@ -76,8 +76,6 @@ void DrivingState::entry()
m_lineStatus = LINE_STATUS_FIND_START_LINE;
m_trackStatus = TRACK_STATUS_ON_TRACK; /* Assume that the robot is placed on track. */

diffDrive.enable();

/* Configure PID controller with selected parameter set. */
m_topSpeed = parSet.topSpeed;
m_pidCtrl.clear();
Expand Down Expand Up @@ -137,16 +135,17 @@ void DrivingState::process(StateMachine& sm)

void DrivingState::exit()
{
DifferentialDrive& diffDrive = DifferentialDrive::getInstance();

diffDrive.disable();
m_observationTimer.stop();
Board::getInstance().getYellowLed().enable(false);
}

/* PROTECTED METHODES *****************************************************************************/
/******************************************************************************
* Protected Methods
*****************************************************************************/

/* PRIVATE METHODES *******************************************************************************/
/******************************************************************************
* Private Methods
*****************************************************************************/

void DrivingState::processOnTrack(int16_t position, const uint16_t* lineSensorValues)
{
Expand Down Expand Up @@ -361,14 +360,6 @@ void DrivingState::adaptDriving(int16_t position)
diffDrive.setLinearSpeed(leftSpeed, rightSpeed);
}

/******************************************************************************
* Protected Methods
*****************************************************************************/

/******************************************************************************
* Private Methods
*****************************************************************************/

/******************************************************************************
* External Functions
*****************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion lib/APPLineFollower/ErrorState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DESCRIPTION
*******************************************************************************/
/**
* @brief Calibration state
* @brief Error state
* @author Andreas Merkle <[email protected]>
*/

Expand Down
4 changes: 0 additions & 4 deletions lib/APPLineFollower/LineSensorsCalibrationState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ void LineSensorsCalibrationState::entry()
/* Prepare calibration drive. */
m_calibrationSpeed = diffDrive.getMaxMotorSpeed() / 3;
m_orientation = odometry.getOrientation();
diffDrive.enable();

/* Wait some time, before starting the calibration drive. */
m_phase = PHASE_1_WAIT;
Expand Down Expand Up @@ -134,9 +133,6 @@ void LineSensorsCalibrationState::process(StateMachine& sm)

void LineSensorsCalibrationState::exit()
{
DifferentialDrive& diffDrive = DifferentialDrive::getInstance();

diffDrive.disable();
m_timer.stop();
}

Expand Down
3 changes: 3 additions & 0 deletions lib/APPLineFollower/MotorSpeedCalibrationState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ void MotorSpeedCalibrationState::finishCalibration(StateMachine& sm)
*/
diffDrive.setMaxMotorSpeed(maxSpeed);

/* Differential drive can now be used. */
diffDrive.enable();

if (0 == maxSpeed)
{
ErrorState::getInstance().setErrorMsg("MS=0");
Expand Down
2 changes: 1 addition & 1 deletion lib/APPLineFollower/ReadyState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DESCRIPTION
*******************************************************************************/
/**
* @brief Calibration state
* @brief Ready state
* @author Andreas Merkle <[email protected]>
*/

Expand Down
2 changes: 1 addition & 1 deletion lib/APPLineFollower/ReleaseTrackState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DESCRIPTION
*******************************************************************************/
/**
* @brief Calibration state
* @brief Release track state
* @author Andreas Merkle <[email protected]>
*/

Expand Down
2 changes: 1 addition & 1 deletion lib/APPRemoteControl/ErrorState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DESCRIPTION
*******************************************************************************/
/**
* @brief Calibration state
* @brief Error state
* @author Andreas Merkle <[email protected]>
*/

Expand Down
4 changes: 0 additions & 4 deletions lib/APPRemoteControl/LineSensorsCalibrationState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ void LineSensorsCalibrationState::entry()
/* Prepare calibration drive. */
m_calibrationSpeed = diffDrive.getMaxMotorSpeed() / 3;
m_orientation = odometry.getOrientation();
diffDrive.enable();

/* Wait some time, before starting the calibration drive. */
m_phase = PHASE_1_WAIT;
Expand Down Expand Up @@ -134,9 +133,6 @@ void LineSensorsCalibrationState::process(StateMachine& sm)

void LineSensorsCalibrationState::exit()
{
DifferentialDrive& diffDrive = DifferentialDrive::getInstance();

diffDrive.disable();
m_timer.stop();
}

Expand Down
3 changes: 3 additions & 0 deletions lib/APPRemoteControl/MotorSpeedCalibrationState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ void MotorSpeedCalibrationState::finishCalibration(StateMachine& sm)
*/
diffDrive.setMaxMotorSpeed(maxSpeed);

/* Differential drive can now be used. */
diffDrive.enable();

if (0 == maxSpeed)
{
ErrorState::getInstance().setErrorMsg("MS=0");
Expand Down
2 changes: 0 additions & 2 deletions lib/APPSensorFusion/DrivingState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ void DrivingState::entry()
m_lineStatus = LINE_STATUS_FIND_START_LINE;
m_trackStatus = TRACK_STATUS_ON_TRACK; /* Assume that the robot is placed on track. */

diffDrive.enable();

/* Configure PID controller with selected parameter set. */
m_topSpeed = parSet.topSpeed;
m_pidCtrl.clear();
Expand Down
2 changes: 1 addition & 1 deletion lib/APPSensorFusion/ErrorState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DESCRIPTION
*******************************************************************************/
/**
* @brief Calibration state
* @brief Error state
* @author Andreas Merkle <[email protected]>
*/

Expand Down
4 changes: 0 additions & 4 deletions lib/APPSensorFusion/LineSensorsCalibrationState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ void LineSensorsCalibrationState::entry()
/* Prepare calibration drive. */
m_calibrationSpeed = diffDrive.getMaxMotorSpeed() / 3;
m_orientation = odometry.getOrientation();
diffDrive.enable();

/* Wait some time, before starting the calibration drive. */
m_phase = PHASE_1_WAIT;
Expand Down Expand Up @@ -128,9 +127,6 @@ void LineSensorsCalibrationState::process(StateMachine& sm)

void LineSensorsCalibrationState::exit()
{
DifferentialDrive& diffDrive = DifferentialDrive::getInstance();

diffDrive.disable();
m_timer.stop();
}

Expand Down
3 changes: 3 additions & 0 deletions lib/APPSensorFusion/MotorSpeedCalibrationState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ void MotorSpeedCalibrationState::finishCalibration(StateMachine& sm)
*/
diffDrive.setMaxMotorSpeed(maxSpeed);

/* Differential drive can now be used. */
diffDrive.enable();

if (0 == maxSpeed)
{
ErrorState::getInstance().setErrorMsg("MS=0");
Expand Down
2 changes: 1 addition & 1 deletion lib/APPSensorFusion/ReadyState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DESCRIPTION
*******************************************************************************/
/**
* @brief Calibration state
* @brief Ready state
* @author Andreas Merkle <[email protected]>
*/

Expand Down
2 changes: 1 addition & 1 deletion lib/APPSensorFusion/ReleaseTrackState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DESCRIPTION
*******************************************************************************/
/**
* @brief Calibration state
* @brief Release track state
* @author Andreas Merkle <[email protected]>
*/

Expand Down
4 changes: 2 additions & 2 deletions lib/HALSim/ButtonB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@

bool ButtonB::isPressed()
{
return m_keyboard.buttonAPressed();
return m_keyboard.buttonBPressed();
}

void ButtonB::waitForRelease()
{
m_keyboard.waitForReleaseA();
m_keyboard.waitForReleaseB();
}

/******************************************************************************
Expand Down
4 changes: 2 additions & 2 deletions lib/HALSim/ButtonC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@

bool ButtonC::isPressed()
{
return m_keyboard.buttonAPressed();
return m_keyboard.buttonCPressed();
}

void ButtonC::waitForRelease()
{
m_keyboard.waitForReleaseA();
m_keyboard.waitForReleaseC();
}

/******************************************************************************
Expand Down
Loading

0 comments on commit f76b2e1

Please sign in to comment.