Skip to content

Commit

Permalink
Revert "Added LineFollowerSimple to the CI workflows."
Browse files Browse the repository at this point in the history
This reverts commit 48e1139.
  • Loading branch information
gabryelreyes committed Jul 2, 2024
1 parent 8bce223 commit 727e68b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
needs: intro
strategy:
matrix:
environment: ["CalibTarget", "ConvoyFollowerTarget", "ConvoyLeaderTarget", "LineFollowerTarget", "LineFollowerSimpleTarget", "RemoteControlTarget", "SensorFusionTarget"]
environment: ["CalibTarget", "ConvoyFollowerTarget", "ConvoyLeaderTarget", "LineFollowerTarget", "RemoteControlTarget", "SensorFusionTarget"]

# Steps represent a sequence of tasks that will be executed as part of the job.
steps:
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
needs: intro
strategy:
matrix:
environment: ["CalibTarget", "ConvoyFollowerTarget", "ConvoyLeaderTarget", "LineFollowerTarget", "LineFollowerSimpleTarget", "RemoteControlTarget", "SensorFusionTarget", "TestSim"]
environment: ["CalibTarget", "ConvoyFollowerTarget", "ConvoyLeaderTarget", "LineFollowerTarget", "RemoteControlTarget", "SensorFusionTarget", "TestSim"]

steps:
- name: Checkout repository
Expand Down
33 changes: 31 additions & 2 deletions lib/APPLineFollowerSimple/src/DrivingState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ void DrivingState::process(StateMachine& sm)
const uint16_t* lineSensorValues = lineSensors.getSensorValues();
uint8_t numLineSensors = lineSensors.getNumLineSensors();
int16_t position3 = 0;
bool isPosition3Valid = calcPosition3(position3, lineSensorValues, numLineSensors);
bool isTrackLost = isNoLineDetected(lineSensorValues, numLineSensors);

/* ========================================================================
Expand Down Expand Up @@ -281,6 +282,35 @@ DrivingState::DrivingState() :
{
}

bool DrivingState::calcPosition3(int16_t& position, const uint16_t* lineSensorValues, uint8_t length) const
{
const int32_t WEIGHT = SENSOR_VALUE_MAX;
bool isValid = true;
int32_t numerator = 0U;
int32_t denominator = 0U;
int32_t idxBegin = 1;
int32_t idxEnd = length - 1;

for (int32_t idx = idxBegin; idx < idxEnd; ++idx)
{
int32_t sensorValue = static_cast<int32_t>(lineSensorValues[idx]);

numerator += idx * WEIGHT * sensorValue;
denominator += sensorValue;
}

if (0 == denominator)
{
isValid = false;
}
else
{
position = numerator / denominator;
}

return isValid;
}

DrivingState::TrackStatus DrivingState::evaluateSituation(const uint16_t* lineSensorValues, uint8_t length,
int16_t position, bool isTrackLost) const
{
Expand Down Expand Up @@ -381,8 +411,7 @@ bool DrivingState::isNoLineDetected(const uint16_t* lineSensorValues, uint8_t le
return isDetected;
}

void DrivingState::processSituation(int16_t& position, bool& allowNegativeMotorSpeed, TrackStatus trackStatus,
int16_t position3)
void DrivingState::processSituation(int16_t& position, bool& allowNegativeMotorSpeed, TrackStatus trackStatus, int16_t position3)
{
switch (trackStatus)
{
Expand Down
13 changes: 13 additions & 0 deletions lib/APPLineFollowerSimple/src/DrivingState.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,18 @@ class DrivingState : public IState
*/
DrivingState& operator=(const DrivingState& state);

/**
* Calculate the position with the inner 3 line sensors.
*
* @param[out] position The position result.
* @param[in] lineSensorValues Array of line sensor values.
* @param[in] length Array length.
*
* @return If successful, it will return true otherwise false.
*/
bool calcPosition3(int16_t& position, const uint16_t* lineSensorValues, uint8_t length) const;


/**
* Evaluate the situation by line sensor values and position and determine
* the track status. The result influences the measures to keep track on
Expand Down Expand Up @@ -253,6 +265,7 @@ class DrivingState : public IState
*/
void processSituation(int16_t& position, bool& allowNegativeMotorSpeed, TrackStatus trackStatus, int16_t position3);


/**
* Adapt driving by using a PID algorithm, depended on the position
* input.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ void LineSensorsCalibrationState::exit()
bool LineSensorsCalibrationState::turnAndCalibrate(int32_t calibAlpha, bool isGreaterEqual)
{
IBoard& board = Board::getInstance();
IMotors& motors = board.getMotors();
ILineSensors& lineSensors = board.getLineSensors();
bool isSuccesful = false;

Expand Down

0 comments on commit 727e68b

Please sign in to comment.