2 Commits

Author SHA1 Message Date
Hermes 1704d8a833 CUB-228: add battery_calibration_offset to cameras table
CI/CD / lint-and-typecheck (pull_request) Successful in 6s
CI/CD / test (pull_request) Successful in 6s
CI/CD / build (pull_request) Failing after 4m47s
CI/CD / deploy (pull_request) Has been skipped
- Add column to 001_create_tables.sql for fresh databases
- Add migration 002 for existing databases (idempotent via
  pragma_table_info check)
- Implement runIncrementalMigrations in db.go
- Add BatteryCalibrationOffset to Camera model
- Update all camera SELECT queries (cameras List, detail, MQTT
  subscriber getCamera, register)
2026-05-22 22:31:54 -04:00
overseer 1a8f67a392 Merge pull request 'feat: add v3 hardware case and update hub network' (#6) from agent/hermes/remoterig-hardware-v3-network into dev
Build (Dev) / build (push) Failing after 9s
CI/CD / lint-and-typecheck (push) Successful in 9m29s
CI/CD / test (push) Successful in 9m27s
CI/CD / build (push) Failing after 4m50s
CI/CD / deploy (push) Has been skipped
Reviewed-on: #6
2026-05-22 19:43:40 -04:00
12 changed files with 110 additions and 119 deletions
+8 -11
View File
@@ -1,7 +1,7 @@
# RemoteRig — Camera Node Hardware Design # RemoteRig — Camera Node Hardware Design
> **Version:** 0.2.0 | **Status:** Draft > **Version:** 0.2.0 | **Status:** Draft
> **Target:** GoPro Hero 3 Black/Silver + ESP-01S/ESP8266 + ESP32-C3 Super Mini + USB power bank > **Target:** GoPro Hero 3 Black/Silver + ESP8266 + ESP32 + USB power bank
## Overview ## Overview
@@ -29,8 +29,8 @@ Each camera node is two ESP boards in a small case that clips to the tripod/stan
| Item | Qty | Cost | Notes | | Item | Qty | Cost | Notes |
|------|-----|------|-------| |------|-----|------|-------|
| ESP32-C3 Super Mini | 1 | ~$5 | MQTT bridge — talks to hub; board footprint 22.5 × 18.0mm | | ESP32 Dev Board | 1 | ~$5 | MQTT bridge — talks to hub |
| ESP-01S / ESP8266 | 1 | ~$3 | Camera bridge — talks to GoPro; module envelope 24.7 × 14.3 × 12.0mm | | ESP8266 D1 Mini | 1 | ~$3 | Camera bridge — talks to GoPro |
| USB power bank (5000mAh+) | 1 | ~$10 | Powers both boards + GoPro | | USB power bank (5000mAh+) | 1 | ~$10 | Powers both boards + GoPro |
| Micro-USB cable (short) | 2 | ~$2 | Power bank → boards + GoPro | | Micro-USB cable (short) | 2 | ~$2 | Power bank → boards + GoPro |
| Jumper wires F-F | 3 | ~$0.25 | UART TX/RX/GND between boards | | Jumper wires F-F | 3 | ~$0.25 | UART TX/RX/GND between boards |
@@ -45,8 +45,8 @@ Each camera node is two ESP boards in a small case that clips to the tripod/stan
**Pipeline:** `hardware/DESIGN_PIPELINE.md` **Pipeline:** `hardware/DESIGN_PIPELINE.md`
Four exported prototype files: Four exported prototype files:
1. **Case body** — holds both boards side-by-side with extra wiring/service clearance, cable ports, rear mounting boss 1. **Case body** — holds both boards stacked, cable ports, rear dovetail-style receiver
2. **Case lid** — screw-on cover with ventilation and underside locating lip for flush seating 2. **Case lid** — screw-on cover with ventilation
3. **Tripod clamp** — separate screw-tightened C-clamp sized around a 35mm stand/pole 3. **Tripod clamp** — separate screw-tightened C-clamp sized around a 35mm stand/pole
4. **Full preview** — combined visualization STL only, not intended as the print job 4. **Full preview** — combined visualization STL only, not intended as the print job
@@ -105,11 +105,8 @@ The ESP8266 and GoPro talk over Wi-Fi — **no data cable between them**. The on
| | W × D × H (mm) | | | W × D × H (mm) |
|---|---| |---|---|
| Board envelope basis | ESP32-C3 Super Mini: 22.5 × 18.0; ESP-01S: 24.7 × 14.3 × 12.0 | | Case body external | ~56.8 × 38.2 × 19.0 |
| Internal CAD allowance | ~71.2 × 34.0 × 22.0; intentionally includes wiring gutters and vertical connector clearance | | Lid external | ~56.8 × 32.8 × 4.0 |
| Case body external | ~76.0 × 42.6 × 26.0 including rear mount boss depth; main shell ~76.0 × 38.8 × 26.0 | | Tripod clamp | ~43.0 × 56.9 × 16.0 |
| Lid external | ~76.0 × 38.8 × 3.6; includes 1.6mm underside locating lip |
| Tripod clamp | ~43.0 × 53.5 × 16.0 |
| Clamp-to-case mount | Two side-by-side M3 screws through flat mounting plate |
| Clamp pole fit | Nominal 35mm; smaller poles TBD / may need inserts | | Clamp pole fit | Nominal 35mm; smaller poles TBD / may need inserts |
| Total weight | TBD after prototype print | | Total weight | TBD after prototype print |
Binary file not shown.
Binary file not shown.
Binary file not shown.
+53 -94
View File
@@ -1,39 +1,26 @@
// RemoteRig — Dual-ESP Tripod Case v3 // RemoteRig — Dual-ESP Tripod Case v3
// v3e changes: board-specific envelope for ESP32-C3 Super Mini + ESP-01S with wiring clearance. // v3 changes: screw-tightened tripod clamp + dovetail slide interface.
// Coordinate system: all case/lid geometry uses bottom-origin Z. // Coordinate system: all case/lid geometry uses bottom-origin Z.
$fn = 36; $fn = 36;
// Board dimensions from selected modules. // Board dimensions
// ESP32-C3 Super Mini: 22.5 x 18.0 mm footprint. esp8266_w = 34.2; esp8266_d = 25.6; esp8266_h = 5;
// ESP-01S / ESP8266: 24.7 x 14.3 x 12.0 mm envelope. esp32_w = 52; esp32_d = 28; esp32_h = 5;
// The case is intentionally larger than board footprints because the field board_gap = 3;
// build needs room for Dupont/UART wiring, power leads, bend radius, and fingers. stack_h = esp8266_h + esp32_h + board_gap;
esp32c3_w = 22.5; esp32c3_d = 18.0; esp32c3_h = 6.0; // height allowance includes headers/pins TBD inner_w = max(esp8266_w, esp32_w);
esp01s_w = 24.7; esp01s_d = 14.3; esp01s_h = 12.0; inner_d = max(esp8266_d, esp32_d);
board_gap = 8.0; // side-by-side service gap between boards inner_h = stack_h + 2;
wire_x = 8.0; // wiring gutter at left/right ends
wire_y = 8.0; // wiring gutter along front/back edges
wire_z = 10.0; // vertical wiring/connector clearance above tallest module
inner_w = esp32c3_w + esp01s_w + board_gap + wire_x*2;
inner_d = max(esp32c3_d, esp01s_d) + wire_y*2;
inner_h = max(esp32c3_h, esp01s_h) + wire_z;
// Case parameters // Case parameters
wall = 2.0; wall = 2.0;
tol = 0.4; tol = 0.4;
outer_w = inner_w + wall*2 + tol*2; // 76.0mm with current board/wiring envelope outer_w = inner_w + wall*2 + tol*2; // 56.8mm
outer_d = inner_d + wall*2 + tol*2; // 38.8mm with current board/wiring envelope outer_d = inner_d + wall*2 + tol*2; // 32.8mm
outer_h = inner_h + wall*2; // 26.0mm with current board/wiring envelope outer_h = inner_h + wall*2; // 19mm
corner_r = 2.5; corner_r = 2.5;
// Lid fit parameters
lid_top_thick = 2.0;
lid_lip_h = 1.6;
lid_clearance = 0.6; // clearance around underside locating lip
lid_lip_wall = 1.2; // thickness of perimeter lip/frame
// Tripod clamp parameters // Tripod clamp parameters
pole_dia = 35; // nominal stand/pole diameter pole_dia = 35; // nominal stand/pole diameter
clamp_thick = 4.0; // ring wall thickness clamp_thick = 4.0; // ring wall thickness
@@ -42,16 +29,15 @@ mouth_width = 13.0; // clamp opening
m3_clearance = 3.4; // M3 screw clearance m3_clearance = 3.4; // M3 screw clearance
nut_flat = 6.4; // M3 nut trap flat-to-flat nut_flat = 6.4; // M3 nut trap flat-to-flat
// Case ↔ clamp interface // Dovetail slide interface
// v3b removes the dovetail: use a flat two-screw mounting plate instead. // Male rail is on the case; matching female socket is on the tripod clamp.
// This is simpler to print, easier to inspect, and field-serviceable. // This is easier to inspect and avoids the previous mismatched "two lips + tab" geometry.
mount_plate_w = 24.0; rail_z = outer_h * 0.78;
mount_plate_h = 16.0; rail_depth = 5.0;
mount_plate_thick = 4.0; rail_neck_w = 12.0; // narrow width at case wall / slot opening
mount_hole_spacing = 14.0; // side-by-side M3 case-mount screws rail_outer_w = 18.0; // wider retained edge
mount_screw_clear = 3.4; // M3 clearance through clamp plate rail_clearance = 0.45; // FDM sliding clearance per side-ish
mount_case_pilot = 2.7; // pilot/insert hole through case boss socket_wall = 2.2;
mount_boss_r = 1.2;
// Cable ports // Cable ports
usb_port_w = 12; usb_port_h = 6; usb_port_w = 12; usb_port_h = 6;
@@ -121,20 +107,15 @@ module screw_post(x, y) {
} }
} }
module case_mount_boss() { module case_male_dovetail_rail() {
// Flat rear boss on the case. The clamp plate bolts directly to this face. // Positive tapered rail on the case back. Cross-section is narrow at the
// Holes run front/back (Y axis) for M3 screws, heat-set inserts, or nuts. // wall and wider at the outside, so the clamp socket captures it.
boss_y = outer_d/2 + mount_plate_thick/2 - 0.2; translate([0, outer_d/2 - 0.15, outer_h/2])
difference() { dovetail_prism(rail_z, rail_neck_w, rail_outer_w, rail_depth);
translate([0, boss_y, outer_h/2])
rounded_cube_centered(mount_plate_w, mount_plate_thick, mount_plate_h, mount_boss_r);
for (xoff = [-mount_hole_spacing/2, mount_hole_spacing/2]) { // Bottom stop so the clamp socket cannot slide past the case.
translate([xoff, outer_d/2 + mount_plate_thick/2, outer_h/2]) translate([0, outer_d/2 + rail_depth/2, outer_h*0.12])
rotate([90, 0, 0]) rounded_cube_centered(rail_outer_w + 3.0, rail_depth + 0.8, 2.4, 0.8);
cylinder(d=mount_case_pilot, h=mount_plate_thick + wall*3, center=true, $fn=24);
}
}
} }
module case_body() { module case_body() {
@@ -142,48 +123,22 @@ module case_body() {
case_shell(); case_shell();
for (x = [-1, 1], y = [-1, 1]) for (x = [-1, 1], y = [-1, 1])
screw_post(x*(outer_w/2 - 5), y*(outer_d/2 - 5)); screw_post(x*(outer_w/2 - 5), y*(outer_d/2 - 5));
case_mount_boss(); case_male_dovetail_rail();
}
}
module lid_locating_lip() {
// Thin underside frame that drops into the case opening. This registers the
// lid so it cannot skate/rock on the rim, while staying clear of screw posts.
lip_outer_w = inner_w + tol - lid_clearance;
lip_outer_d = inner_d + tol - lid_clearance;
lip_inner_w = lip_outer_w - lid_lip_wall*2;
lip_inner_d = lip_outer_d - lid_lip_wall*2;
translate([0, 0, -lid_lip_h])
difference() {
rounded_cube0(lip_outer_w, lip_outer_d, lid_lip_h, 1.0);
translate([0, 0, -0.1])
rounded_cube0(lip_inner_w, lip_inner_d, lid_lip_h + 0.2, 0.7);
// Corner reliefs so the lip doesn't interfere with screw posts.
for (x = [-1, 1], y = [-1, 1]) {
translate([x*(outer_w/2 - 5), y*(outer_d/2 - 5), lid_lip_h/2])
cylinder(d=7.0, h=lid_lip_h + 0.4, center=true, $fn=24);
}
} }
} }
module case_lid() { module case_lid() {
difference() { difference() {
union() { rounded_cube0(outer_w, outer_d, wall*2, 1.8);
// Thinner top cover; underside lip handles registration.
rounded_cube0(outer_w, outer_d, lid_top_thick, 0.8);
lid_locating_lip();
}
for (x = [-1, 1], y = [-1, 1]) { for (x = [-1, 1], y = [-1, 1]) {
translate([x*(outer_w/2 - 5), y*(outer_d/2 - 5), -lid_lip_h - 0.5]) translate([x*(outer_w/2 - 5), y*(outer_d/2 - 5), -0.5])
cylinder(d=2.4, h=lid_top_thick + lid_lip_h + 1, center=false, $fn=20); cylinder(d=2.4, h=wall*2 + 1, center=false, $fn=20);
} }
for (x = [-outer_w/4, 0, outer_w/4]) { for (x = [-outer_w/4, 0, outer_w/4]) {
translate([x, 0, lid_top_thick/2]) translate([x, 0, wall*2/2])
cube([8, outer_d*0.6, lid_top_thick*3], center=true); cube([8, outer_d*0.6, wall*3], center=true);
} }
} }
} }
@@ -192,7 +147,7 @@ module clamp_ring_with_mouth() {
outer_r = pole_dia/2 + clamp_thick; outer_r = pole_dia/2 + clamp_thick;
difference() { difference() {
cylinder(r=outer_r, h=clamp_width, center=true, $fn=72); cylinder(r=outer_r, h=clamp_width, center=true, $fn=72);
cylinder(r=pole_dia/2 + tol, h=clamp_width + 1, center=true, $fn=72); cylinder(r=pole_dia/2 + rail_clearance, h=clamp_width + 1, center=true, $fn=72);
// Mouth opens toward +Y. Width is intentionally generous for snap-on placement before tightening. // Mouth opens toward +Y. Width is intentionally generous for snap-on placement before tightening.
translate([0, outer_r, 0]) translate([0, outer_r, 0])
cube([mouth_width, outer_r*2, clamp_width + 2], center=true); cube([mouth_width, outer_r*2, clamp_width + 2], center=true);
@@ -219,21 +174,25 @@ module clamp_ears() {
} }
} }
module clamp_mount_plate() { module clamp_dovetail_socket() {
outer_r = pole_dia/2 + clamp_thick; outer_r = pole_dia/2 + clamp_thick;
plate_y = -outer_r - mount_plate_thick/2 + 0.2; socket_outer_w = rail_outer_w + socket_wall*2;
socket_depth = rail_depth + socket_wall*2;
// Flat plate matching the case boss. Two M3 clearance holes pass through // Solid boss on the rear of the clamp, opposite the tightening mouth.
// along Y so the clamp bolts to the case with ordinary hardware. // A matching dovetail void is cut through it along Z so the case rail
// slides in from the top/bottom with practical FDM clearance.
difference() { difference() {
translate([0, plate_y, 0]) translate([0, -outer_r - socket_depth/2 + socket_wall, 0])
rounded_cube_centered(mount_plate_w, mount_plate_thick, mount_plate_h, mount_boss_r); rounded_cube_centered(socket_outer_w, socket_depth, clamp_width, 1.2);
for (xoff = [-mount_hole_spacing/2, mount_hole_spacing/2]) { translate([0, -outer_r - 0.15, 0])
translate([xoff, plate_y, 0]) dovetail_prism(
rotate([90, 0, 0]) clamp_width + 1.0,
cylinder(d=mount_screw_clear, h=mount_plate_thick + 2, center=true, $fn=24); rail_neck_w + rail_clearance,
} rail_outer_w + rail_clearance,
rail_depth + 0.6
);
} }
} }
@@ -241,7 +200,7 @@ module tripod_clamp() {
union() { union() {
clamp_ring_with_mouth(); clamp_ring_with_mouth();
clamp_ears(); clamp_ears();
clamp_mount_plate(); clamp_dovetail_socket();
} }
} }
@@ -252,7 +211,7 @@ module tripod_clip() {
module full_case() { module full_case() {
case_body(); case_body();
translate([0, 0, outer_h]) case_lid(); translate([0, 0, outer_h + 2]) case_lid();
translate([0, outer_d/2 + pole_dia/2 + clamp_thick + 8, outer_h/2]) translate([0, outer_d/2 + pole_dia/2 + clamp_thick + 8, outer_h/2])
rotate([90, 0, 0]) tripod_clamp(); rotate([90, 0, 0]) tripod_clamp();
} }
Binary file not shown.
+2 -2
View File
@@ -132,10 +132,10 @@ func GetCameraDetail(database *db.DB) http.HandlerFunc {
// Get camera info // Get camera info
var c models.Camera var c models.Camera
err := database.QueryRowContext(r.Context(), ` err := database.QueryRowContext(r.Context(), `
SELECT camera_id, friendly_name, mac_address, created_at, updated_at SELECT camera_id, friendly_name, mac_address, battery_calibration_offset, created_at, updated_at
FROM cameras WHERE camera_id = ? FROM cameras WHERE camera_id = ?
`, cameraID).Scan( `, cameraID).Scan(
&c.CameraID, &c.FriendlyName, &c.MacAddress, &c.CameraID, &c.FriendlyName, &c.MacAddress, &c.BatteryCalibrationOffset,
&c.CreatedAt, &c.UpdatedAt, &c.CreatedAt, &c.UpdatedAt,
) )
if err == sql.ErrNoRows { if err == sql.ErrNoRows {
+28
View File
@@ -14,6 +14,9 @@ import (
//go:embed migrations/001_create_tables.sql //go:embed migrations/001_create_tables.sql
var migration001 string var migration001 string
//go:embed migrations/002_add_camera_calibration.sql
var migration002 string
// DB wraps the sql.DB with connection-level settings. // DB wraps the sql.DB with connection-level settings.
type DB struct { type DB struct {
*sql.DB *sql.DB
@@ -62,6 +65,12 @@ func Open(path string) (*DB, error) {
return nil, err return nil, err
} }
log.Println("Migrations complete") log.Println("Migrations complete")
} else {
// Run incremental migrations on existing databases
if err := runIncrementalMigrations(db); err != nil {
db.Close()
return nil, err
}
} }
return &DB{db}, nil return &DB{db}, nil
@@ -83,6 +92,25 @@ func migrate(db *sql.DB, sql string) error {
return nil return nil
} }
// runIncrementalMigrations applies migrations that haven't been run yet on
// an existing database (one where the 001 schema already exists).
func runIncrementalMigrations(db *sql.DB) error {
// Migration 002: add battery_calibration_offset if it doesn't exist
var colCount int
err := db.QueryRow(`SELECT COUNT(*) FROM pragma_table_info('cameras') WHERE name = 'battery_calibration_offset'`).Scan(&colCount)
if err != nil {
return err
}
if colCount == 0 {
log.Println("Running migration 002: add battery_calibration_offset")
if err := migrate(db, migration002); err != nil {
return err
}
}
return nil
}
// splitSQL splits a SQL string on semicolons, respecting quoted strings. // splitSQL splits a SQL string on semicolons, respecting quoted strings.
func splitSQL(sql string) []string { func splitSQL(sql string) []string {
var stmts []string var stmts []string
@@ -6,6 +6,7 @@ CREATE TABLE IF NOT EXISTS cameras (
camera_id TEXT PRIMARY KEY, camera_id TEXT PRIMARY KEY,
friendly_name TEXT NOT NULL, friendly_name TEXT NOT NULL,
mac_address TEXT UNIQUE, mac_address TEXT UNIQUE,
battery_calibration_offset REAL,
created_at DATETIME NOT NULL DEFAULT (datetime('now')), created_at DATETIME NOT NULL DEFAULT (datetime('now')),
updated_at DATETIME NOT NULL DEFAULT (datetime('now')) updated_at DATETIME NOT NULL DEFAULT (datetime('now'))
); );
@@ -0,0 +1,5 @@
-- Migration 002: Add battery_calibration_offset to cameras table
-- This column stores a per-camera calibration value for converting raw battery
-- readings (e.g. GoPro Hero 3 byte at offset 57) into percentage values.
ALTER TABLE cameras ADD COLUMN battery_calibration_offset REAL;
+2 -2
View File
@@ -404,9 +404,9 @@ func extractCameraID(topic string) string {
func getCamera(db *db.DB, cameraID string) (models.Camera, error) { func getCamera(db *db.DB, cameraID string) (models.Camera, error) {
var cam models.Camera var cam models.Camera
err := db.QueryRow( err := db.QueryRow(
"SELECT camera_id, friendly_name, COALESCE(mac_address,''), created_at, updated_at FROM cameras WHERE camera_id = ?", "SELECT camera_id, friendly_name, COALESCE(mac_address,''), COALESCE(battery_calibration_offset, NULL), created_at, updated_at FROM cameras WHERE camera_id = ?",
cameraID, cameraID,
).Scan(&cam.CameraID, &cam.FriendlyName, &cam.MacAddress, &cam.CreatedAt, &cam.UpdatedAt) ).Scan(&cam.CameraID, &cam.FriendlyName, &cam.MacAddress, &cam.BatteryCalibrationOffset, &cam.CreatedAt, &cam.UpdatedAt)
return cam, err return cam, err
} }
+1
View File
@@ -10,6 +10,7 @@ type Camera struct {
CameraID string `json:"camera_id"` CameraID string `json:"camera_id"`
FriendlyName string `json:"friendly_name"` FriendlyName string `json:"friendly_name"`
MacAddress string `json:"mac_address,omitempty"` MacAddress string `json:"mac_address,omitempty"`
BatteryCalibrationOffset *float64 `json:"battery_calibration_offset,omitempty"`
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"` UpdatedAt time.Time `json:"updated_at"`
} }