Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
864111e
started on the rpi interface
mountainduu Jan 25, 2025
078eae9
[LIB] add boost
dzodkin33 Jan 29, 2025
c733592
[ADD] some basic socket design ideas
dzodkin33 Jan 29, 2025
f94e54a
hold
dzodkin33 Feb 6, 2025
d55398d
[ADD] TCP interfaces, data structs
dzodkin33 Feb 25, 2025
efe4aa1
[add] implementation files
dzodkin33 Feb 25, 2025
9d082df
[ADD] changed headers, constr and connect funcs in cpp
dzodkin33 Feb 28, 2025
8f7530f
[ADD] basic client + send function
dzodkin33 Mar 7, 2025
7d65cf6
TCP Client and Server
smhitle Apr 15, 2025
bcfdaa0
merge main
AskewParity Apr 18, 2025
6e3b256
change boost import
AskewParity Apr 18, 2025
cb845f6
added VERY INEFFICIENT way to make serialization to work
AskewParity Apr 18, 2025
a396fa6
Changes to the client. Modified interface.hpp/.cpp to match the requi…
smhitle May 6, 2025
83e9ef6
chore: remove boost:serialization
AskewParity May 7, 2025
00d6adf
Undid changes to interface.cpp. Provided skeleton code, now compiles
smhitle May 8, 2025
7548cfb
Prototypal code for the entire process
smhitle May 9, 2025
2a3b163
Testing on jetson
smhitle May 9, 2025
d5a7adf
Added log statements for debugging
smhitle May 9, 2025
d573496
Added a mock rpi server
smhitle May 9, 2025
0d12b7f
Deleted unused files, switched to UDP instead of TCP
smhitle May 15, 2025
6c68c3f
Added server mock stuff
smhitle May 16, 2025
4121c05
Changed cout's to LOG_F's
smhitle May 18, 2025
b8eb719
Can read in udp packets correctly (hopefully)
smhitle May 22, 2025
4d3f717
Updated mock udp server
smhitle May 25, 2025
6f78c76
Updated cmake for server mock
smhitle May 25, 2025
19cacc7
Mock server works for dev container purposes
smhitle May 25, 2025
b1ba268
Merge remote-tracking branch 'origin' into dev/camera/tcp-socket/tyler
AskewParity Nov 9, 2025
a9f90d7
chore: update integration/cmake
AskewParity Nov 9, 2025
d0d76d4
fix: mock camera (merge incorrect)
AskewParity Nov 9, 2025
98d302a
fix: linking issue for camera and mavlink
AskewParity Nov 14, 2025
2e1baf6
chore: removed deprecated tcp files
miyatakazuya Jan 25, 2026
43bd3ca
feat: update rpi config + plane request logic
miyatakazuya Jan 25, 2026
4140fd7
bug: fixed cmake
miyatakazuya Jan 25, 2026
ee20f3d
feat: matched client to specifications. Socket still times out sometimes
miyatakazuya Jan 25, 2026
f4cdabb
bug: compilation fixes
miyatakazuya Jan 25, 2026
a11407a
feat: added camera count and interval
miyatakazuya Jan 25, 2026
abbb74a
fix: filename collision
miyatakazuya Feb 5, 2026
cf16f78
kaz codes looky looky here
dsoto0125 Feb 20, 2026
0feb640
kaz looky looky part 2
dsoto0125 Feb 20, 2026
250d648
Merge branch 'main' into feat/pi-client
AskewParity Feb 22, 2026
5e69301
feat: added mav
miyatakazuya Feb 22, 2026
38491b3
feat: added cmake changes
miyatakazuya Feb 24, 2026
080d5ab
fix: add io_context to state
miyatakazuya Feb 24, 2026
b7a3a1b
fix: cmake linking
miyatakazuya Feb 26, 2026
3d7042c
feat: implemented timeout
miyatakazuya Feb 27, 2026
88e2bf5
chore: changed logging
miyatakazuya Feb 27, 2026
574c898
fix: cmake for mock/lucid
miyatakazuya Mar 1, 2026
7cea1f5
chore: pruned deprecated camera
miyatakazuya Mar 1, 2026
519d726
chore: removed deprected configs
miyatakazuya Mar 1, 2026
a99076b
chore: removed extraneous
miyatakazuya Mar 1, 2026
39f93dd
feat: updated README
miyatakazuya Mar 1, 2026
e78c919
fix: lint
miyatakazuya Mar 1, 2026
06ec426
chore: removed comments
miyatakazuya Mar 2, 2026
d6b4b8f
feat: moved the ntohl conversions
miyatakazuya Mar 2, 2026
374f3e8
feat: Implemented enum CameraRequest
miyatakazuya Mar 2, 2026
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ include(${DEPS_DIRECTORY}/matplot/matplot.cmake)
include(${DEPS_DIRECTORY}/protobuf/protobuf.cmake)
include(${DEPS_DIRECTORY}/loguru/loguru.cmake)
include(${DEPS_DIRECTORY}/imagemagick/imagemagick.cmake)
include(${DEPS_DIRECTORY}/boost/boost.cmake)
# =============================

# =============================
Expand Down
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,47 @@ The airdrop payloads are currently programmed to connect to a WIFI network with
this information on boot. To make sure that it is broadcasting correctly, you
can try and connect to it via your phone or other device.

## Jetson Setup (PiCamera)
> How to setup networking for a new Jetsoj

### 1. Clean Up Old Connections
Remove any previous attempts to avoid conflicts.
```bash
sudo nmcli con delete "pi-link" 2>/dev/null
sudo nmcli con delete "Wired connection 1" 2>/dev/null
sudo nmcli con delete "Wired connection 2" 2>/dev/null
```

### 2. Create the "MAC-Locked" Connection
We configure the Jetson to listen for the specific MAC address we set on the Pi (`00:dc:c8:f7:75:14`). This ensures the connection works even if the Jetson names the interface `usb0`, `usb2`, or `eth1`.

```bash
# Create connection binding to the specific MAC address
# IP: 192.168.77.1
sudo nmcli con add type ethernet con-name "pi-static" ifname "*" mac "00:dc:c8:f7:75:14" ip4 192.168.77.1/24

# Set to manual (Static IP)
sudo nmcli con modify "pi-static" ipv4.method manual

# Bring it up
sudo nmcli con up "pi-static"
```

### 3. Verify the Connection
```bash
ip addr show pi-static
```

### 4. Test the Connection
```bash
ping 192.168.77.2
```
> This should return packets if the connection is set up correctly.

### Pi-Connection Config:
**Jetson (Server/Receiver):** `192.168.77.1`
**Raspberry Pi (Client/Sender):** `192.168.77.2`

## Setup

Now that everything is installed, here is the process to build and run the
Expand Down Expand Up @@ -289,6 +330,33 @@ When testing the pipeline, you will likely want to also use the `mock` camera.
...
```
which will use `not-stolen-israeli-code` as the mock camera.

---

#### PiCamera

Alternatively, you can use the `PiCamera` camera, which will use the PiCamera
on the Jetson to capture images. This must done alongside [camera-things](https://github.com/tritonuas/camera-things/).

```json
"camera": {
...
"type": "PiCamera",
...
```
Verify that the camera network is set up correctly by running:

```bash
ip addr show pi-static
```
> should list pi-static as active, if not run `sudo nmcli con up pi-static`

Test the connection by running:
```bash
ping 192.168.77.2
```
> Make sure the raspy server is running on the pi!


### SITL

Expand Down
26 changes: 1 addition & 25 deletions configs/dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,33 +68,9 @@
"runway": "right",
"num_targets": 2,
"connection_timeout": 10
},
"lucid": {
"sensor_shutter_mode": "Rolling",

"acquisition_frame_rate_enable": true,
"target_brightness": 20,
"exposure_auto": "Continuous",
"exposure_time": 3000,
"exposure_auto_damping": 1,
"exposure_auto_algorithm": "Median",
"exposure_auto_upper_limit": 500,
"exposure_auto_lower_limit": 360,

"stream_auto_negotiate_packet_size": true,
"stream_packet_resend_enable": true,

"device_link_throughput_limit_mode": "On",
"device_link_throughput_limit": 125000000,

"gamma_enable": true,
"gamma": 0.5,
"gain_auto": "Continuous",
"gain_auto_upper_limit": 10,
"gain_auto_lower_limit": 1
}
},
"mavlink": {
"log_params": false
}
}
}
34 changes: 5 additions & 29 deletions configs/jetson.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"takeoff": {
"altitude_m": 60.0,
"payload_size": 2
"payload_size": 2
},
"pathing": {
"laps": 10,
Expand All @@ -26,10 +26,10 @@
"iterations_per_waypoint": 512,
"rewire_radius": 256.0,
"optimize": true,
"point_fetch_method": "nearest",
"point_fetch_method": "nearest",
"allowed_to_skip_waypoints": false,
"generate_deviations": false
},
},
"coverage": {
"altitude_m": 30.0,
"camera_vision_m": 6.0,
Expand Down Expand Up @@ -60,40 +60,16 @@
},
"camera": {
"_comment": "See CameraConfig struct in datatypes.hpp for detailed explanations",
"type": "picamera",
"type": "PiCamera",
"save_dir": "/obcpp/images/",
"save_images_to_file": true,
"mock": {
"not_stolen_port": 6060,
"runway": "right",
"num_targets": 2
},
"lucid": {
"sensor_shutter_mode": "Rolling",

"acquisition_frame_rate_enable": true,
"target_brightness": 20,
"exposure_auto": "Continuous",
"exposure_time": 3000,
"exposure_auto_damping": 1,
"exposure_auto_algorithm": "Median",
"exposure_auto_upper_limit": 500,
"exposure_auto_lower_limit": 360,

"stream_auto_negotiate_packet_size": true,
"stream_packet_resend_enable": true,

"device_link_throughput_limit_mode": "On",
"device_link_throughput_limit": 125000000,

"gamma_enable": true,
"gamma": 0.5,
"gain_auto": "Continuous",
"gain_auto_upper_limit": 10,
"gain_auto_lower_limit": 1
}
},
"mavlink": {
"log_params": false
}
}
}
16 changes: 16 additions & 0 deletions deps/boost/boost.cmake
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The long term solution is to add this to the docker-file correct? If that is the case, I should start looking into implementing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think we can look into using libboost-dev from the apt repository instead.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function(target_add_boost target_name)
include(FetchContent)

FetchContent_Declare(boost
URL https://github.com/boostorg/boost/releases/download/boost-1.87.0/boost-1.87.0-b2-nodocs.tar.gz
URL_HASH SHA256=d6c69e4459eb5d6ec208250291221e7ff4a2affde9af6e49c9303b89c687461f
DOWNLOAD_EXTRACT_TIMESTAMP true
)
FetchContent_MakeAvailable(boost)
# target_link_libraries(${target_name} PRIVATE
# boost
# )
target_include_directories(${target_name} PUBLIC ${boost_SOURCE_DIR})


endfunction()
77 changes: 0 additions & 77 deletions include/camera/picamera.hpp

This file was deleted.

65 changes: 65 additions & 0 deletions include/camera/rpi.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#ifndef INCLUDE_CAMERA_RPI_HPP_
#define INCLUDE_CAMERA_RPI_HPP_

#include <string>
#include <memory>
#include <optional>
#include <shared_mutex>
#include <thread>
#include <deque>
#include <vector>

#include <nlohmann/json.hpp>
#include "camera/interface.hpp"
#include "network/mavlink.hpp"
#include "network/udp_client.hpp"

using json = nlohmann::json;
using namespace std::chrono_literals; // NOLINT

namespace asio = boost::asio;

enum class CameraRequest : std::uint8_t {
START = 's',
PICTURE = 'I',
END = 'e',
LOCK = 'l'
};

class RPICamera : public CameraInterface {
private:
UDPClient client;
asio::io_context io_context_;
std::atomic_bool connected;

/**
* Converts the 3-plane raw data to BGR cv::Mat, handling stride/padding
*/
std::optional<cv::Mat> imgConvert(const std::vector<std::vector<uint8_t>>& planes);

/**
* Reads the 3 planes (Y, U, V) from the camera
*/
std::vector<std::vector<uint8_t>> readImage();

public:
explicit RPICamera(CameraConfig config, asio::io_context* io_context_);
~RPICamera();

void connect() override;
bool isConnected() override;

std::optional<ImageData> getLatestImage() override {return std::nullopt;}
std::deque<ImageData> getAllImages() override {return std::deque<ImageData>();}

std::optional<ImageData> takePicture(const std::chrono::milliseconds& timeout,
std::shared_ptr<MavlinkClient> mavlinkClient) override;

void startTakingPictures(const std::chrono::milliseconds& interval,
std::shared_ptr<MavlinkClient> mavlinkClient) override;
void stopTakingPictures() override;
void startStreaming() override;
void ping();
};

#endif // INCLUDE_CAMERA_RPI_HPP_
3 changes: 3 additions & 0 deletions include/core/mission_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <queue>
#include <unordered_set>
#include <vector>
#include <boost/asio.hpp>

#include "camera/interface.hpp"
#include "core/mission_parameters.hpp"
Expand Down Expand Up @@ -113,6 +114,7 @@ class MissionState {
OBCConfig config;

std::optional<airdrop_t> next_airdrop_to_drop;
boost::asio::io_context raspy_io;

private:
std::mutex converter_mut;
Expand All @@ -139,6 +141,7 @@ class MissionState {
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_AIRDROPS> cv_matches;
Expand Down
Loading