From 0c28d9dc80e634ebfbabed5ad446b6a4f82056e3 Mon Sep 17 00:00:00 2001 From: ccolin Date: Mon, 4 Jan 2021 14:49:26 +0100 Subject: add speeding violation reporting --- src/drone_controller.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/drone_controller.cc') diff --git a/src/drone_controller.cc b/src/drone_controller.cc index cede63d..58f0359 100644 --- a/src/drone_controller.cc +++ b/src/drone_controller.cc @@ -261,6 +261,23 @@ void DroneController::computeCollisions(double sphere_radius) { } +void DroneController::computeSpeedingViolations(double speed) { + speed_violations.clear(); + for (int i = 0; i < duration; i++) { + for (Drone &d : drones) { + d.setTo(i); + if (d.getSpeed() > speed) { + speed_violations[i].append(d.getId()); + emit speedViolation(d.getId(), d.getSpeed(), i); + } + } + } + for (Drone &d : drones) { + d.setTo(frame); + } +} + + void DroneController::displaySpheres(double sphere_radius) { draw_spheres = true; this->sphere_radius = sphere_radius; -- cgit v1.2.3-70-g09d2