mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-17 04:02:21 -05:00
cleanups
This commit is contained in:
@@ -76,7 +76,7 @@ func (c *WSClient) applyMixerGain(control string, gain float64) {
|
||||
return
|
||||
}
|
||||
|
||||
// Convert linear gain to dB, matching softvol max_dB=12.0 in /etc/asound.conf.
|
||||
// Convert linear gain to dB, matching softvol max_dB=12.0 in the generated ALSA routing.
|
||||
db := 20.0 * math.Log10(normalized)
|
||||
if db > 12.0 {
|
||||
db = 12.0
|
||||
|
||||
@@ -272,8 +272,8 @@ func DefaultConfig() Config {
|
||||
Height: 480,
|
||||
FPS: 30,
|
||||
Bitrate: 2000000,
|
||||
Inverted: true,
|
||||
SensorMode: "1296:972",
|
||||
Inverted: false,
|
||||
SensorMode: "",
|
||||
},
|
||||
AudioCapture: AudioCaptureConfig{
|
||||
Profile: "alsa",
|
||||
@@ -471,12 +471,7 @@ func validateAudioConfig(cfg *AudioConfig) {
|
||||
}
|
||||
|
||||
func validateMediaConfig(cfg *MediaConfig, serverURL string, roverName string) error {
|
||||
/*
|
||||
The nested media config is the source of truth for the publisher scripts,
|
||||
so defaults that used to live in shell are normalized here before any env
|
||||
file is written. This keeps the Pi behavior stable while making laptop
|
||||
and future publisher variants explicit configuration choices.
|
||||
*/
|
||||
// Normalize shared settings before they become profile command variables.
|
||||
if cfg.RTSPPort <= 0 {
|
||||
cfg.RTSPPort = 8554
|
||||
}
|
||||
|
||||
+15
-11
@@ -20,7 +20,7 @@ const (
|
||||
)
|
||||
|
||||
// HostStats is the wire format sent from roverd to the server. It avoids
|
||||
// Roomba-specific sensor naming so the browser can treat these values as Pi
|
||||
// Roomba-specific sensor naming so the browser can treat these values as Linux
|
||||
// host health, not robot telemetry.
|
||||
type HostStats struct {
|
||||
UptimeSec *float64 `json:"uptimeSec,omitempty"`
|
||||
@@ -136,17 +136,21 @@ func CollectHostStats(ctx context.Context) HostStats {
|
||||
}
|
||||
}
|
||||
|
||||
if coreV, err := readCoreVoltage(ctx); err != nil {
|
||||
stats.addError("coreVoltage", err)
|
||||
} else {
|
||||
stats.CoreVoltageV = &coreV
|
||||
}
|
||||
// Firmware voltage/throttle telemetry is optional on non-Pi hosts.
|
||||
if _, err := exec.LookPath("vcgencmd"); err == nil {
|
||||
if coreV, err := readCoreVoltage(ctx); err != nil {
|
||||
stats.addError("coreVoltage", err)
|
||||
} else {
|
||||
stats.CoreVoltageV = &coreV
|
||||
}
|
||||
|
||||
if raw, flags, err := readThrottleFlags(ctx); err != nil {
|
||||
stats.addError("throttled", err)
|
||||
} else {
|
||||
stats.ThrottledRaw = raw
|
||||
stats.applyThrottleFlags(flags)
|
||||
}
|
||||
|
||||
if raw, flags, err := readThrottleFlags(ctx); err != nil {
|
||||
stats.addError("throttled", err)
|
||||
} else {
|
||||
stats.ThrottledRaw = raw
|
||||
stats.applyThrottleFlags(flags)
|
||||
}
|
||||
|
||||
if wifi, err := collectWiFiStats(ctx); err != nil {
|
||||
|
||||
@@ -239,7 +239,7 @@ func (c *ManagementClient) forwardHostStats(ctx context.Context, conn *websocket
|
||||
|
||||
send := func() bool {
|
||||
// Host stats are collected on demand so each outbound message describes
|
||||
// the current Pi state. Collection failures are encoded into the stats
|
||||
// the current host state. Collection failures are encoded into the stats
|
||||
// payload, which keeps this telemetry path from closing the rover socket.
|
||||
stats := CollectHostStats(ctx)
|
||||
// Throughput is derived here because this loop owns the ordered, periodic
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
"fps": 30,
|
||||
"bitrate": 2000000,
|
||||
"inverted": false,
|
||||
"sensorMode": "1296:972"
|
||||
"sensorMode": ""
|
||||
},
|
||||
"audioCapture": {
|
||||
"profile": "alsa",
|
||||
|
||||
@@ -671,7 +671,7 @@ func (c *WSClient) handleRebootTimeout() {
|
||||
c.connMu.Unlock()
|
||||
|
||||
c.console.Notify("Control server has been disconnected for 6 minutes. Rebooting the rover now.")
|
||||
c.log.Printf("rebooting pi after prolonged websocket disconnect")
|
||||
c.log.Printf("rebooting rover after prolonged websocket disconnect")
|
||||
cmd := exec.Command("systemctl", "reboot")
|
||||
if err := cmd.Start(); err != nil {
|
||||
c.log.Printf("reboot command failed: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user