Improve odometry with rotation estimation, daemon stability, and RTSP fixes

- Add rotation estimation via log-polar phase correlation (EstimateRotation,
  rotateGray) — de-rotate before translation to avoid aliasing
- Track cumulative field rotation in Tracker, reject low-confidence frames
- Extract RTSP grabber into internal/rtspgrab module
- Daemon: pause odometry during slew (motion blur), auto-resume after settle
  delay, add /pause and /resume HTTP endpoints, switch shooting mode before
  opening camera, use ReqOpenCamera with rtsp_encode_type=1
- WebSocket heartbeat (ping/pong every 10s) to prevent idle disconnects
- FFmpeg low-latency flags (-fflags nobuffer, -probesize, -analyzeduration)
- Add SendRaw API for custom payloads, increase daemon HTTP timeout to 60s

💘 Generated with Crush

Assisted-by: Crush:/models/Qwen3.6-27B-uncensored-heretic-v2-Native-MTP-Preserved-Q4_K_M.gguf
This commit is contained in:
Jacquin Antoine
2026-07-13 23:00:30 +02:00
parent 8daa9b4d58
commit d319ef6b4a
12 changed files with 522 additions and 143 deletions

View File

@ -705,7 +705,12 @@ func cmdPreview() *cobra.Command {
must(scope.OpenCamera(cam))
time.Sleep(2 * time.Second)
url := fmt.Sprintf("rtsp://%s:554/%s/stream0", flagIP, ch)
ffmpegCmd := exec.Command("ffmpeg", "-rtsp_transport", "tcp",
ffmpegCmd := exec.Command("ffmpeg",
"-rtsp_transport", "tcp",
"-fflags", "nobuffer",
"-flags", "low_delay",
"-probesize", "4096",
"-analyzeduration", "1000000",
"-i", url, "-frames:v", "1", "-q:v", "2", "-y", out)
if err := ffmpegCmd.Run(); err != nil {
die("ffmpeg: %v (is ffmpeg installed?)", err)
@ -936,7 +941,12 @@ func cmdOrient() *cobra.Command {
defer ticker.Stop()
grab := func(out string) error {
return exec.Command("ffmpeg", "-rtsp_transport", "tcp",
return exec.Command("ffmpeg",
"-rtsp_transport", "tcp",
"-fflags", "nobuffer",
"-flags", "low_delay",
"-probesize", "4096",
"-analyzeduration", "1000000",
"-i", url, "-frames:v", "1", "-q:v", "2", "-y", out).Run()
}

View File

@ -1,71 +0,0 @@
package main
import (
"fmt"
"os"
"os/exec"
"time"
"github.com/antitbone/dwarfctl/internal/api"
)
func main() {
ip := "192.168.88.1"
if len(os.Args) > 1 {
ip = os.Args[1]
}
scope := api.New("rtsp-test")
scope.SetDebug(true)
fmt.Println("Connecting to", ip)
if err := scope.Connect(ip); err != nil {
die("connect: %v", err)
}
defer scope.Close()
fmt.Println("Opening wide camera...")
if err := scope.OpenCamera(api.CameraWide); err != nil {
die("open camera: %v", err)
}
fmt.Println("Wide camera opened. Waiting 3s for stream to initialize...")
time.Sleep(3 * time.Second)
url := fmt.Sprintf("rtsp://%s:554/ch1/stream0", ip)
out := "/tmp/rtsp_test_frame.jpg"
fmt.Println("Grabbing frame via ffmpeg...")
cmd := exec.Command("ffmpeg", "-rtsp_transport", "tcp",
"-i", url, "-frames:v", "1", "-q:v", "2", "-y", out)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
die("ffmpeg: %v", err)
}
info, _ := os.Stat(out)
if info != nil {
fmt.Printf("SUCCESS: frame saved (%d bytes)\n", info.Size())
}
// Also try tele
fmt.Println("\nOpening tele camera...")
if err := scope.OpenCamera(api.CameraTele); err != nil {
die("open tele: %v", err)
}
time.Sleep(3 * time.Second)
url0 := fmt.Sprintf("rtsp://%s:554/ch0/stream0", ip)
out0 := "/tmp/rtsp_test_tele.jpg"
fmt.Println("Grabbing tele frame...")
cmd0 := exec.Command("ffmpeg", "-rtsp_transport", "tcp",
"-i", url0, "-frames:v", "1", "-q:v", "2", "-y", out0)
cmd0.Stdout = os.Stdout
cmd0.Stderr = os.Stderr
cmd0.Run()
if i, _ := os.Stat(out0); i != nil {
fmt.Printf("SUCCESS: tele frame saved (%d bytes)\n", i.Size())
}
}
func die(format string, args ...any) {
fmt.Fprintf(os.Stderr, "ERROR: "+format+"\n", args...)
os.Exit(1)
}