Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
041bc23
Kinda working yolo
kimichenn Feb 4, 2025
6e48d00
Working Yolo
kimichenn Feb 5, 2025
8424716
Revert devcontainer.json
kimichenn Feb 5, 2025
8558739
Compartementalize YOLO
kimichenn Feb 8, 2025
bef5480
Change onnxruntime cmake such that we can actually build other targets
kimichenn Feb 15, 2025
14d00f4
Working Pipeline
kimichenn Feb 16, 2025
4e57d84
Lint yolo
kimichenn Feb 18, 2025
c421147
Remove extraneous folder
kimichenn Feb 22, 2025
99316f1
Merge remote-tracking branch 'origin/main' into feat/yolo-integration
kimichenn Feb 22, 2025
5582895
Merge branch 'main' into feat/yolo
AskewParity Feb 23, 2025
69645df
Merge branch 'main' into feat/yolo
AskewParity Feb 23, 2025
cd452be
Merge branch 'feat/yolo' into feat/yolo-integration
kimichenn Feb 23, 2025
dfb027b
Lint pipeline
kimichenn Feb 23, 2025
0247688
Model path and image path as argv
kimichenn Feb 25, 2025
78dd71e
It works but I wouldn't merge it in the slightest bit
kimichenn Feb 26, 2025
912eafd
debug mapping
kimichenn Mar 4, 2025
01d93ad
Preprocess
kimichenn Mar 7, 2025
44c2c9a
QOL to yolo and pipeline. Implement preprocessing
kimichenn Mar 7, 2025
bb3e29d
Better output handling
kimichenn Mar 8, 2025
d81e820
Mapping implement preprocess, better folder management
kimichenn Mar 8, 2025
09e8299
Auto comment onnxruntime src, lint
kimichenn Mar 12, 2025
ba818c2
Download different onnx depending on platform
kimichenn Mar 12, 2025
b8c3616
Change protos branch, update pipeline and aggregator
kimichenn Mar 20, 2025
2d0c2d8
Update route for getting images
kimichenn Mar 20, 2025
9eb965a
Update aggregator output
kimichenn Mar 21, 2025
1a7ef7f
Update route for new proto
kimichenn Apr 4, 2025
9fa3000
Compile obcpp
kimichenn Apr 11, 2025
740254c
Update routes fix test
kimichenn Apr 13, 2025
26b1f38
Added matched routes
kimichenn May 4, 2025
b9ddaaf
Update matched
kimichenn May 6, 2025
9b5be70
Update aggregator to use maps for results, fix post matched route
tuas-travis-ci May 11, 2025
e146521
Working airdrop prep
tuas-travis-ci May 11, 2025
978cfdb
Fixed (I hope) everything
tuas-travis-ci May 16, 2025
6733f23
Fix localization. Though airdrop approach is non-deterministic
tuas-travis-ci May 16, 2025
cc33811
Mappingbound edits
miyatakazuya May 16, 2025
9455e6c
lint
kimichenn May 18, 2025
0755a7a
Add dev_protos
kimichenn May 18, 2025
c19b08c
Maybe compiling unit tests??
kimichenn May 18, 2025
09cbb88
Working refueling tick prototype; WTD flywaypoint diversion
miyatakazuya May 18, 2025
d05fe52
Jank but working mission flow
miyatakazuya May 19, 2025
41dee1a
Work for Christopher LEE
miyatakazuya May 20, 2025
727c4b1
New airdrop dropping method
kimichenn May 20, 2025
ed69aa3
add forward pathing
AskewParity May 20, 2025
a66bf5f
Lint
kimichenn May 21, 2025
f0bd8e3
Undo useless unit test changes
kimichenn May 21, 2025
a9e21f5
Add docs for MAV_CMD_DO_SET_RELAY command
kimichenn May 21, 2025
3e4f4ed
Added note abt ordering + update protos
miyatakazuya May 22, 2025
ab728f2
lint
kimichenn May 18, 2025
0065157
Add dev_protos
kimichenn May 18, 2025
5e0fc18
Add payload size to config and use it in airdrop approach, and active…
Fox-King777 May 23, 2025
57dbe03
work for christopher LEE
kimichenn May 25, 2025
ab4565f
Chris did a dumb dumb
Fox-King777 May 23, 2025
cd86240
chore: update mavlink constructor in integration test + loosen reqs f…
AskewParity May 26, 2025
702f044
fix: update messages and usage for mavlink_client intergration test
tuas-travis-ci May 26, 2025
c77ddc9
fix: drop_it_like_its_hot update mavlink constructor
tuas-travis-ci May 27, 2025
d1317e0
Add mapping fake tick
kimichenn May 27, 2025
5592e4f
Modified dodropnow handler
miyatakazuya May 27, 2025
22401a0
Comment testing logic and uncomment main logic and change the locatio…
Fox-King777 May 28, 2025
8c94956
Comment testing logic and uncomment main logic and change the locatio…
Fox-King777 May 28, 2025
072a7db
Fixed manual landing; reset refueling tick wait time
miyatakazuya May 28, 2025
0858217
Merge branch 'feat/cv-everything' into feat/cv-everything-mappingbound
miyatakazuya May 28, 2025
bd3037a
Add mapping state handlers
tuas-travis-ci May 28, 2025
4d354de
lint
kimichenn May 28, 2025
9a6a366
Fixed lint
miyatakazuya May 28, 2025
c229ba4
Merge pull request #250 from tritonuas/feat/cv-everything-mappingbound
miyatakazuya May 29, 2025
2f72e90
remove comments
kimichenn May 30, 2025
7a13097
Merge branch 'feat/cv-everything' into feat/cv-everything-mappingtick
miyatakazuya May 30, 2025
94928d2
Fixed manual landing logic
miyatakazuya May 30, 2025
225cebd
Added error handling for triggerAirdrop
miyatakazuya May 30, 2025
016ad65
Added new route structure
miyatakazuya May 30, 2025
7da85c9
Fixed interval typing
miyatakazuya May 30, 2025
b467834
Remove redudant NUMAIRDROPS constant and comment out unused ALL_AIRDR…
tuas-travis-ci May 30, 2025
dc7d8d4
lint
kimichenn May 30, 2025
08d2889
Lint
kimichenn May 30, 2025
bc19f33
Flip on and off for relay
kimichenn May 31, 2025
5760bf1
Merge pull request #255 from tritonuas/feat/cv-everything-stream-camera
kimichenn May 31, 2025
f6b759b
lint
kimichenn May 31, 2025
c31d4d6
Update tests/integration/drop_it_like_its_hot.cpp
miyatakazuya Jun 1, 2025
75e37be
Fixed HTTP code return
atar13 Jun 1, 2025
67354ab
Merge branch 'feat/cv-everything-airdrop' of github.com:tritonuas/obc…
atar13 Jun 1, 2025
2e7c1c9
Merge pull request #251 from tritonuas/feat/cv-everything-airdrop
miyatakazuya Jun 1, 2025
e611ccc
Remove duplicate markAirdropAsDropped
tuas-travis-ci Jun 1, 2025
0941295
Add get tick state GCS route
Fox-King777 Jun 3, 2025
b305c4d
Change response style
tuas-travis-ci Jun 3, 2025
5de40d1
Update dockerfile to install opencv and changed : to ;
tuas-travis-ci Jun 5, 2025
77304c3
Update comments, use loguru
kimichenn Jun 7, 2025
a904322
Merge pull request #253 from tritonuas/feat/cv-everything-mappingtick
tuas-travis-ci Jun 7, 2025
08a7da2
Initiate isMappingDone to false
tuas-travis-ci Jun 7, 2025
b1e49c8
Merge pull request #256 from tritonuas/feat/cv-everything-tickstate
miyatakazuya Jun 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ models/*

images/*
!images/.gitkeep
!images/mapping/

images/mapping/*
!images/mapping/.gitkeep

tests/integration/images/*
!tests/integration/images/.gitkeep
Expand All @@ -38,9 +42,18 @@ tests/integration/mapping/batch2/*
tests/integration/mapping/images/*
!tests/integration/mapping/images/.gitkeep

tests/integration/mapping/direct_test_images/*
!tests/integration/mapping/direct_test_images/.gitkeep

tests/integration/mapping/output/*
!tests/integration/mapping/output/.gitkeep

tests/integration/mapping/direct_output/*
!tests/integration/mapping/direct_output/.gitkeep

tests/integration/aggregator/*
!tests/integration/aggregator/.gitkeep

.vscode/*
!.vscode/c_cpp_properties.json

Expand Down
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ set(LOGURU_WITH_STREAMS TRUE)
set(FETCHCONTENT_QUIET FALSE)
set(DEPS_DIRECTORY ${PROJECT_SOURCE_DIR}/deps)

include(${DEPS_DIRECTORY}/onnxruntime/onnxruntime.cmake)
include(${DEPS_DIRECTORY}/torch/torch.cmake)
include(${DEPS_DIRECTORY}/torchvision/torchvision.cmake)
include(${DEPS_DIRECTORY}/json/json.cmake)
Expand Down Expand Up @@ -193,3 +194,16 @@ else()
message(FATAL_ERROR "cpplint executable not found. Check the README for steps to install it on your system")
endif()
# =============================

add_custom_target(dev_protos
COMMAND cd ${CMAKE_BINARY_DIR} &&
cmake .. &&
cd ${CMAKE_SOURCE_DIR}/include/udp_squared &&
git checkout feat/udp_update &&
cd ${CMAKE_SOURCE_DIR}/protos &&
git checkout feat/protoupdate &&
cd ${CMAKE_BINARY_DIR} &&
protoc -I=../protos --cpp_out=./gen_protos/protos ../protos/obc.proto &&
ninja obcpp
USES_TERMINAL
)
12 changes: 6 additions & 6 deletions configs/dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
}
},
"takeoff": {
"altitude_m": 30.0
"altitude_m": 30.0,
"payload_size": 2
},
"pathing": {
"dubins": {
Expand All @@ -25,11 +26,12 @@
"rewire_radius": 256.0,
"optimize": true,
"point_fetch_method": "nearest",
"allowed_to_skip_waypoints": false
"allowed_to_skip_waypoints": false,
"generate_deviations": false
},
"coverage": {
"altitude_m": 30.0,
"camera_vision_m": 5.0,
"camera_vision_m": 20.0,
"method": "hover",
"hover": {
"pictures_per_stop": 1,
Expand All @@ -50,9 +52,7 @@
}
},
"cv": {
"matching_model_dir": "/workspaces/obcpp/models/target_siamese_1.pt",
"segmentation_model_dir": "/workspaces/obcpp/models/fcn-model_20-epochs_06-01-2023T21-16-02.pth",
"saliency_model_dir": "/workspaces/obcpp/models/torchscript_19.pth",
"yolo_model_dir": "/workspaces/obcpp/models/yolo11x.onnx",
"not_stolen_addr": "localhost",
"not_stolen_port": 5069
},
Expand Down
4 changes: 1 addition & 3 deletions configs/jetson.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@
}
},
"cv": {
"matching_model_dir": "/obcpp/models/target_siamese_1.pt",
"segmentation_model_dir": "/obcpp/models/fcn-model_20-epochs_06-01-2023T21-16-02.pth",
"saliency_model_dir": "/obcpp/models/torchscript_19.pth",
"yolo_model_dir": "/obcpp/models/yolo11x.onnx",
"not_stolen_addr": "localhost",
"not_stolen_port": 5069
},
Expand Down
40 changes: 40 additions & 0 deletions deps/onnxruntime/onnxruntime.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function(target_add_onnxruntime target_name)
include(FetchContent)

# Detect architecture.
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(ONNX_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.20.1/onnxruntime-linux-x64-1.20.1.tgz")
set(ONNX_HASH SHA256=67db4dc1561f1e3fd42e619575c82c601ef89849afc7ea85a003abbac1a1a105)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(ONNX_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.20.1/onnxruntime-linux-aarch64-1.20.1.tgz")
set(ONNX_HASH SHA256=ae4fedbdc8c18d688c01306b4b50c63de3445cdf2dbd720e01a2fa3810b8106a)
else()
message(FATAL_ERROR "Unknown architecture: ${CMAKE_SYSTEM_PROCESSOR}")
endif()

FetchContent_Declare(
onnxruntime
URL ${ONNX_URL}
URL_HASH ${ONNX_HASH}
DOWNLOAD_EXTRACT_TIMESTAMP FALSE
)
FetchContent_MakeAvailable(onnxruntime)

# Apply patches
if(EXISTS "${onnxruntime_SOURCE_DIR}/include/onnxruntime_cxx_api.h")
execute_process(
COMMAND sed -i "210s|^|//|" "${onnxruntime_SOURCE_DIR}/include/onnxruntime_cxx_api.h"
)
execute_process(
COMMAND sed -i "351s|^|//|" "${onnxruntime_SOURCE_DIR}/include/onnxruntime_cxx_api.h"
)
endif()

target_include_directories(${target_name} PUBLIC
${onnxruntime_SOURCE_DIR}/include
)
target_link_directories(${target_name} PUBLIC
${onnxruntime_SOURCE_DIR}/lib
)
target_link_libraries(${target_name} PUBLIC onnxruntime)
endfunction()
3 changes: 2 additions & 1 deletion docker/Dockerfile.jetson
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \
libmagick++-dev \
# needed for pytorch
libopenblas-dev \
ninja-build
ninja-build \
libopencv-dev

RUN pip3 install typing-extensions PyYAML cpplint

Expand Down
2 changes: 1 addition & 1 deletion docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ run-jetson-cuda-check:
# Note that to re-run cmake inside the container you'll need the really long CMake command
# in the Dockerfile.jetson.
jetson-develop:
cd .. && docker run -it --net=host --runtime=nvidia --platform=linux/arm64 --volume=./:/obcpp --device=/dev/ttyACM0 ghcr.io/tritonuas/obcpp:jetson /bin/bash
cd .. && docker run -it --net=host --runtime=nvidia --platform=linux/arm64 --volume=./:/obcpp --device=/dev/ttyTHS1 ghcr.io/tritonuas/obcpp:jetson /bin/bash
# cd .. && docker run -it --net=host --runtime=nvidia --platform=linux/arm64 --volume=./:/obcpp ghcr.io/tritonuas/obcpp:jetson /bin/bash
3 changes: 3 additions & 0 deletions docker/sitl-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ services:
# # - 5010:5010
not-stolen-israeli-code:
image: ghcr.io/tritonuas/not-stolen-israeli-code:latest
volumes:
- ~/dev/tritonuas/not-stolen-israeli-code/backgrounds:/not-stolen-israeli-code/backgrounds
- ~/dev/tritonuas/not-stolen-israeli-code/emergent_target_pics:/not-stolen-israeli-code/emergent_target_pics
ports:
- 5069:5000
volumes:
Expand Down
Empty file added images/mapping/.gitkeep
Empty file.
18 changes: 13 additions & 5 deletions include/core/mission_parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#include <unordered_map>
#include <vector>

// Make sure Airdrop type is known before it's used
#include "pathing/cartesian.hpp"
#include "protos/obc.pb.h"
#include "protos/obc.pb.h" // Include for Airdrop definition
#include "utilities/constants.hpp"
#include "utilities/datatypes.hpp"

Expand All @@ -29,16 +30,20 @@ class MissionParameters {

Polygon getFlightBoundary();
Polygon getAirdropBoundary();
Polygon getMappingBoundary();
Polyline getWaypoints();
std::vector<Bottle> getAirdropBottles();
// CHANGE: Return type is now std::vector<Airdrop>
std::vector<Airdrop> getAirdrops();

// Getters for multiple values
// Use when need to get multiple values
// Important to use this instead of the singular getters
// to avoid race conditions
std::tuple<Polygon, Polygon, Polyline, std::vector<Bottle>> getConfig();
// CHANGE: Tuple element type is now std::vector<Airdrop>
std::tuple<Polygon, Polygon, Polygon, Polyline, std::vector<Airdrop>> getConfig();

// returns error string to be displayed back to the user
// Ensure CartesianConverter<GPSProtoVec> template parameter matches usage
std::optional<std::string> setMission(Mission, CartesianConverter<GPSProtoVec>);

void saveToFile(std::string filename);
Expand All @@ -50,13 +55,16 @@ class MissionParameters {

Polygon flightBoundary;
Polygon airdropBoundary;
Polygon mappingBoundary;
Polyline waypoints;
std::vector<Bottle> bottles;
// CHANGE: Member variable type is now std::vector<Airdrop>
std::vector<Airdrop> airdrops;

std::optional<Mission> cached_mission{};

// internal function which doesn't apply the mutex
void _setBottle(Bottle bottle);
// CHANGE: Renamed function and changed parameter type to const Airdrop&
void _setAirdrop(const Airdrop& airdrop);
};

#endif // INCLUDE_CORE_MISSION_PARAMETERS_HPP_
20 changes: 13 additions & 7 deletions include/core/mission_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <array>
#include <chrono>
#include <cmath>
#include <functional>
#include <memory>
#include <mutex>
Expand Down Expand Up @@ -52,8 +53,8 @@ class MissionState {
void setAirdropPath(const MissionPath& airdrop_path);
MissionPath getAirdropPath();

void markBottleAsDropped(BottleDropIndex bottle);
std::unordered_set<BottleDropIndex> getDroppedBottles();
void markAirdropAsDropped(AirdropIndex airdrop);
std::unordered_set<AirdropIndex> getDroppedAirdrops();

/*
* Gets a locking reference to the underlying tick for the given tick subclass T.
Expand Down Expand Up @@ -103,12 +104,15 @@ class MissionState {
std::shared_ptr<CameraInterface> getCamera();
void setCamera(std::shared_ptr<CameraInterface> camera);

MissionParameters mission_params; // has its own mutex
// Getters and setters for mapping status.
bool getMappingIsDone();
void setMappingIsDone(bool isDone);

MissionParameters mission_params; // has its own mutex

OBCConfig config;

std::optional<bottle_t> next_bottle_to_drop;
std::optional<airdrop_t> next_airdrop_to_drop;

private:
std::mutex converter_mut;
Expand All @@ -124,20 +128,22 @@ class MissionState {
std::mutex airdrop_path_mut;
MissionPath airdrop_path;

std::mutex dropped_bottles_mut;
std::unordered_set<BottleDropIndex> dropped_bottles;
std::mutex dropped_airdrops_mut;
std::unordered_set<AirdropIndex> dropped_airdrops;

std::shared_ptr<MavlinkClient> mav;
std::shared_ptr<AirdropClient> airdrop;
std::shared_ptr<CVAggregator> cv;
std::shared_ptr<CameraInterface> camera;

std::mutex cv_mut;
// Represents a single detected target used in pipeline
std::vector<DetectedTarget> cv_detected_targets;
// Gives an index into cv_detected_targets, and specifies that that bottle is matched
// with the detected_target specified by the index
std::array<size_t, NUM_AIRDROP_BOTTLES> cv_matches;
std::array<size_t, NUM_AIRDROPS> cv_matches;

bool mappingIsDone;

void _setTick(Tick* newTick); // does not acquire the tick_mut
};
Expand Down
45 changes: 33 additions & 12 deletions include/cv/aggregator.hpp
Original file line number Diff line number Diff line change
@@ -1,38 +1,55 @@
#ifndef INCLUDE_CV_AGGREGATOR_HPP_
#define INCLUDE_CV_AGGREGATOR_HPP_

#include <mutex>
#include <memory>
#include <vector>
#include <atomic>
#include <cmath>
#include <functional>
#include <future>
#include <memory>
#include <mutex>
#include <queue>
#include <functional>
#include <thread>
#include <unordered_map>
#include <vector>

#include "cv/utilities.hpp"
#include "cv/pipeline.hpp"
#include "cv/utilities.hpp"
#include "protos/obc.pb.h"
#include "utilities/constants.hpp"
#include "utilities/lockptr.hpp"

struct CVResults {
std::vector<DetectedTarget> detected_targets;
// mapping from bottle -> index into detected_targets
// (optional is none if we don't have a match yet)
std::unordered_map<BottleDropIndex, std::optional<size_t>> matches;
struct AggregatedRun {
int run_id; // Unique integer ID for this pipeline run
cv::Mat annotatedImage; // The "big image" with bounding boxes drawn
std::vector<Bbox> bboxes; // All bounding boxes in that image
std::vector<GPSCoord> coords; // Matching lat-longs for each bounding box
};

struct CVResults {
std::vector<AggregatedRun> runs; // Each pipeline invocation => 1 run
};

struct MatchedResults {
std::unordered_map<AirdropIndex, AirdropTarget> matched_airdrop;
};

class CVAggregator {
public:
explicit CVAggregator(Pipeline&& p);

~CVAggregator();

// Spawn a thread to run the pipeline on the given imageData
void runPipeline(const ImageData& image);

// Lockable pointer to retrieve aggregator results
LockPtr<CVResults> getResults();

// Lockable pointer to retrieve matched results (after manual match)
LockPtr<MatchedResults> getMatchedResults();

// For the endpoint to reset the current list of structs
std::vector<AggregatedRun> popAllRuns();

private:
void worker(ImageData image, int thread_num);

Expand All @@ -41,10 +58,14 @@ class CVAggregator {
std::mutex mut;
int num_worker_threads;

// For when too many pipelines are active at the same time
// For when too many pipelines are active at once
std::queue<ImageData> overflow_queue;

// Shared aggregator results
std::shared_ptr<CVResults> results;

// Shared matched results
std::shared_ptr<MatchedResults> matched_results;
};

#endif // INCLUDE_CV_AGGREGATOR_HPP_
Loading
Loading