diff --git a/Core/Inc/modelec.h b/Core/Inc/modelec.h index 9097995..df0cade 100644 --- a/Core/Inc/modelec.h +++ b/Core/Inc/modelec.h @@ -63,7 +63,7 @@ public: float preciseAngleFinal = 0.017f; float preciseAngle = 0.39f; - float precisePosFinal = 0.0005f; + float precisePosFinal = 0.001f; float precisePos2 = 0.02f; float precisePos = 0.1f; diff --git a/Core/Inc/point.h b/Core/Inc/point.h index 54ed4b4..298fa88 100644 --- a/Core/Inc/point.h +++ b/Core/Inc/point.h @@ -25,8 +25,9 @@ public: float y; float theta; bool active; + bool isAtPosition; - Point(uint8_t id = 0, StatePoint state = StatePoint::INTERMEDIAIRE, float x = 0.0, float y = 0.0, float theta = 0.0, bool active = false); + Point(uint8_t id = 0, StatePoint state = StatePoint::INTERMEDIAIRE, float x = 0.0, float y = 0.0, float theta = 0.0, bool active = false, bool isAtPosition = false); }; #endif /* INC_POINT_H_ */ diff --git a/Core/Src/modelec.cpp b/Core/Src/modelec.cpp index a39a9e3..ca7ce50 100644 --- a/Core/Src/modelec.cpp +++ b/Core/Src/modelec.cpp @@ -141,8 +141,10 @@ void DiffBot::update(float dt_actual) bool isAtPoint = (dist < (targets[index].state == FINAL ? precisePosFinal : precisePos)); - if (isAtPoint) { + if (isAtPoint || targets[index].isAtPosition) { if (targets[index].state == FINAL) { + targets[index].isAtPosition = true; + float finalAngleErr = normalizeAngle(targets[index].theta - pos.theta); if (std::fabs(finalAngleErr) <= preciseAngleFinal) { diff --git a/Core/Src/point.cpp b/Core/Src/point.cpp index 0018307..3119c39 100644 --- a/Core/Src/point.cpp +++ b/Core/Src/point.cpp @@ -2,5 +2,5 @@ #include "point.h" -Point::Point(uint8_t id, StatePoint state, float x, float y, float theta, bool active) : id(id), state(state), x(x), y(y), theta(theta), active(active) { +Point::Point(uint8_t id, StatePoint state, float x, float y, float theta, bool active, bool isAtPosition) : id(id), state(state), x(x), y(y), theta(theta), active(active), isAtPosition(isAtPosition) { }