diff options
author | ccolin | 2021-01-04 14:49:26 +0100 |
---|---|---|
committer | ccolin | 2021-01-04 14:49:26 +0100 |
commit | 0c28d9dc80e634ebfbabed5ad446b6a4f82056e3 (patch) | |
tree | 498a6b8ce12305a2d7531396767852a07f564b7d /src/drone_controller.cc | |
parent | 472e291ca823910418919eac101f26e2b3d852a8 (diff) |
add speeding violation reporting
Diffstat (limited to 'src/drone_controller.cc')
-rw-r--r-- | src/drone_controller.cc | 17 |
1 files changed, 17 insertions, 0 deletions
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; |