Skip to content
Snippets Groups Projects
Commit 22eee540 authored by Hoop77's avatar Hoop77 Committed by lenoelda
Browse files

-

parent b2cf94d1
Branches
No related merge requests found
...@@ -60,6 +60,7 @@ int main(int argc, char ** argv) ...@@ -60,6 +60,7 @@ int main(int argc, char ** argv)
std::atomic<bool> monitorSTM{false}; std::atomic<bool> monitorSTM{false};
std::atomic<bool> monitorUSS{false}; std::atomic<bool> monitorUSS{false};
std::atomic<float> speed{0.0f}; std::atomic<float> speed{0.0f};
std::atomic<float> stopDistance{0};
std::mutex outputMutex; std::mutex outputMutex;
UltrasonicSensor sensor{readDevId()}; UltrasonicSensor sensor{readDevId()};
car::StreamMeanFilter streamMeanFilter{5}; car::StreamMeanFilter streamMeanFilter{5};
...@@ -85,7 +86,7 @@ int main(int argc, char ** argv) ...@@ -85,7 +86,7 @@ int main(int argc, char ** argv)
{ {
auto originalDistance = sensor.getDistance(); auto originalDistance = sensor.getDistance();
auto filteredDistance = streamMeanFilter.moveWindow(originalDistance); auto filteredDistance = streamMeanFilter.moveWindow(originalDistance);
if (filteredDistance <= 50) if (filteredDistance <= stopDistance)
conn->setSpeed(BRAKE_SPEED); conn->setSpeed(BRAKE_SPEED);
else else
conn->setSpeed(speed); conn->setSpeed(speed);
...@@ -138,6 +139,7 @@ int main(int argc, char ** argv) ...@@ -138,6 +139,7 @@ int main(int argc, char ** argv)
std::cout << "WARNING: Speed set to 1.0 due to risk of collision!\n"; std::cout << "WARNING: Speed set to 1.0 due to risk of collision!\n";
} }
speed = value; speed = value;
stopDistance = speed.load() * 100 * 15;
std::cout << "Setting speed to: " << value << "\n"; std::cout << "Setting speed to: " << value << "\n";
} }
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment