From 04d36a3357651bf600377f218c0d0d36f400d043 Mon Sep 17 00:00:00 2001 From: Aaryan Sharma Date: Thu, 12 Feb 2026 01:37:37 +0000 Subject: [PATCH 1/2] take pics if in search zone --- include/ticks/fly_waypoints.hpp | 1 + protos | 2 +- src/ticks/fly_waypoints.cpp | 36 +++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/include/ticks/fly_waypoints.hpp b/include/ticks/fly_waypoints.hpp index 7bf76fb9..a352cc7b 100644 --- a/include/ticks/fly_waypoints.hpp +++ b/include/ticks/fly_waypoints.hpp @@ -24,6 +24,7 @@ class FlyWaypointsTick : public Tick { private: Tick* next_tick; + std::chrono::milliseconds last_photo_time; }; #endif // INCLUDE_TICKS_FLY_WAYPOINTS_HPP_ diff --git a/protos b/protos index af05980b..0789219c 160000 --- a/protos +++ b/protos @@ -1 +1 @@ -Subproject commit af05980bdd6ba49ad87abb9c662dd8fbea95d733 +Subproject commit 0789219cac47a9396b045d24f7152eabdd741dff diff --git a/src/ticks/fly_waypoints.cpp b/src/ticks/fly_waypoints.cpp index dc06a3bd..434e099d 100644 --- a/src/ticks/fly_waypoints.cpp +++ b/src/ticks/fly_waypoints.cpp @@ -5,12 +5,16 @@ #include "ticks/ids.hpp" #include "ticks/mav_upload.hpp" #include "utilities/constants.hpp" +#include "utilities/common.hpp" +#include "pathing/environment.hpp" FlyWaypointsTick::FlyWaypointsTick(std::shared_ptr state, Tick* next_tick) :Tick(state, TickID::FlyWaypoints), next_tick(next_tick) {} void FlyWaypointsTick::init() { state->getMav()->startMission(); + //state->getCamera()->startStreaming(); + this->last_photo_time = getUnixTime_ms(); } std::chrono::milliseconds FlyWaypointsTick::getWait() const { @@ -18,6 +22,38 @@ std::chrono::milliseconds FlyWaypointsTick::getWait() const { } Tick* FlyWaypointsTick::tick() { + auto [lat_deg, lng_deg] = state->getMav()->latlng_deg(); + double altitude_agl_m = state->getMav()->altitude_agl_m(); + GPSCoord current_pos = makeGPSCoord(lat_deg, lng_deg, altitude_agl_m); + // Get the CartesianConverter (which is already initialized from mission boundaries) + auto converter = state->getCartesianConverter(); + if (converter) { + // Convert GPS to local XYZ coords + XYZCoord current_xyz = converter->toXYZ(current_pos); + // Get the airdrop boundary polygon + Polygon airdrop_boundary = state->mission_params.getAirdropBoundary(); + // Check if we're inside the airdrop zone + bool in_zone = Environment::isPointInPolygon(airdrop_boundary, current_xyz); + + if (in_zone) { + for (int i = 0; i < this->state->config.pathing.coverage.hover.pictures_per_stop; i++) { + auto photo = this->state->getCamera()->takePicture(std::chrono::milliseconds(100), this->state->getMav()); + if (state->config.camera.save_images_to_file) { + photo->saveToFile(state->config.camera.save_dir); + } + + if (photo.has_value()) { + // Update the last photo time + this->last_photo_time = getUnixTime_ms(); + // Run the pipeline on the photo + this->state->getCV()->runPipeline(photo.value()); + } + } + } else { + // Stop camera/CV operations + } + } + // TODO: Eventually implement dynamic avoidance so we dont crash brrr bool isMissionFinished = state->getMav()->isMissionFinished(); From b156feb49d1cb6f5e3eb7be0438ca75ee864e18c Mon Sep 17 00:00:00 2001 From: Aaryan Sharma Date: Thu, 12 Feb 2026 02:06:26 +0000 Subject: [PATCH 2/2] fixed intervals --- src/ticks/fly_waypoints.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ticks/fly_waypoints.cpp b/src/ticks/fly_waypoints.cpp index 434e099d..dc66b1a2 100644 --- a/src/ticks/fly_waypoints.cpp +++ b/src/ticks/fly_waypoints.cpp @@ -8,12 +8,14 @@ #include "utilities/common.hpp" #include "pathing/environment.hpp" +using namespace std::chrono_literals; // NOLINT + FlyWaypointsTick::FlyWaypointsTick(std::shared_ptr state, Tick* next_tick) :Tick(state, TickID::FlyWaypoints), next_tick(next_tick) {} void FlyWaypointsTick::init() { state->getMav()->startMission(); - //state->getCamera()->startStreaming(); + state->getCamera()->startStreaming(); this->last_photo_time = getUnixTime_ms(); } @@ -34,10 +36,11 @@ Tick* FlyWaypointsTick::tick() { Polygon airdrop_boundary = state->mission_params.getAirdropBoundary(); // Check if we're inside the airdrop zone bool in_zone = Environment::isPointInPolygon(airdrop_boundary, current_xyz); - + if (in_zone) { - for (int i = 0; i < this->state->config.pathing.coverage.hover.pictures_per_stop; i++) { - auto photo = this->state->getCamera()->takePicture(std::chrono::milliseconds(100), this->state->getMav()); + auto now = getUnixTime_ms(); + if ((now - this->last_photo_time) >= 300ms) { + auto photo = this->state->getCamera()->takePicture(100ms, this->state->getMav()); if (state->config.camera.save_images_to_file) { photo->saveToFile(state->config.camera.save_dir); }