mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-16 19:52:17 -05:00
roverstate yay yay. future implements for non-roomba rovers...
Container image / image (push) Failing after 54s
Container image / image (push) Failing after 54s
This commit is contained in:
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
@@ -18,7 +18,7 @@ Select the appropriate architecture binary on a rover. The default object suppli
|
||||
|
||||
## Connections and state
|
||||
|
||||
- `/rover`: existing control commands, acknowledgements, sensors, and operational toggle state. The planned full `roverState` replacement is not implemented yet.
|
||||
- `/rover`: control commands, acknowledgements, sensors, and complete `roverState` snapshots.
|
||||
- `/rover/management`: configuration hello, management commands/acknowledgements, host statistics, and daemon events.
|
||||
- Derive the management address from the configured `ws://host[:port]/rover` or `wss://host[:port]/rover` control URL; there is no second server address to maintain.
|
||||
- Management starts independently of hardware initialization and remains available after serial/peripheral startup failure.
|
||||
@@ -64,7 +64,7 @@ Do this on the intended server/rover, not the development machine:
|
||||
2. With an authenticated admin Socket.IO session, call `roverManagement:list` and `roverManagement:get`. Expect configuration and schema even when the rover's serial device cannot open.
|
||||
3. Change a harmless setting such as description in the returned full object and call `roverManagement:save`. Expect an acknowledgement, disconnect/reconnect, and a new hello containing that setting. Confirm `/etc/roverd.json` matches and survives a service restart.
|
||||
4. Submit an incomplete object. Expect an error, no file replacement, and no restart.
|
||||
5. Confirm host statistics and autocharge/watchdog/daemon notices still reach their existing UI/alert consumers through management. Headlight/laser state must remain on control.
|
||||
5. Confirm host statistics and autocharge/watchdog/daemon notices still reach their existing UI/alert consumers through management. Headlight/laser state must arrive as a complete `roverState` snapshot on control.
|
||||
6. Verify reboot/update requests use management, the normal user reboot restrictions still apply, and non-admin clients cannot read/save configuration or invoke the admin command endpoint.
|
||||
7. Confirm new movement commands cannot execute while a save/reboot/update is stopping the rover, and that control disconnect safety still works independently of management.
|
||||
|
||||
@@ -72,6 +72,8 @@ Record acknowledgement errors, reconnect hello contents, relevant journal/server
|
||||
|
||||
## Pending stages
|
||||
|
||||
Browser/live verification of the configuration page, shared `roverState`, YAML media catalogs/child supervision, universal ALSA routing, standalone bootstrap, and replacement update workflow remain pending. The current updater and systemd media supervisor have moved transport but retain their existing implementations until those stages.
|
||||
Browser/live verification of configuration and operational state, YAML media catalogs/child supervision, universal ALSA routing, standalone bootstrap, and replacement update workflow remain pending. The current updater and systemd media supervisor have moved transport but retain their existing implementations until those stages.
|
||||
|
||||
Apply-field targets the currently management-connected fleet. It clones each rover’s own configuration, replaces an existing field, and sends the complete object for rover-side validation. Inspect individual results for failures. Missing fields and changed connections are reported; offline changes are not queued. Paths traverse object fields, not array elements. Array-valued fields can be replaced as a whole.
|
||||
|
||||
Control state messages have the shape `{ "type": "roverState", "state": { "headlightOn": false, "laserOn": null } }`. Null indicates an unavailable role. Each message replaces the server object; disconnect clears it. The roster exposes `roverState` directly, rather than per-device `state` objects.
|
||||
|
||||
@@ -159,15 +159,15 @@ The order below is a working sequence, not a requirement to leave incompatible i
|
||||
- [x] Rename `pi/` to `rover/` and update references.
|
||||
- [x] Replace machine-specific build targets/tags with architecture-specific artifacts and resolve hardware support split.
|
||||
- [x] Group every native GPIO setting under the disabled-by-default Pi GPIO peripheral switch in the current configuration and samples.
|
||||
- [ ] Expose the grouped Pi GPIO configuration in the new JSON schema/UI.
|
||||
- [x] Expose the grouped Pi GPIO configuration in the new JSON schema/UI.
|
||||
- [x] Register Pi GPIO through the common peripheral provider path, including BRC lifecycle ownership and uniform role-conflict handling.
|
||||
- [ ] Connect peripheral operational state to the new shared `roverState` object.
|
||||
- [x] Connect peripheral operational state to the new shared `roverState` object.
|
||||
- [x] Gate GPIO provider registration, initialization, and BRC startup behind the parent switch; retain saved child settings. Hardware validation remains pending.
|
||||
- [x] Implement complete JSON configuration serialization, schema, validation, atomic saves, and restart flow (live save/reconnect verification pending).
|
||||
- [x] Implement separate management connection and in-memory server management state.
|
||||
- [x] Move reboot, update, media management, host statistics, and daemon status messages to management; update consumers. Preserve the separately authorized user reboot path.
|
||||
- [x] Separate management lifecycle from hardware startup failures (deployment verification pending).
|
||||
- [ ] Implement full-object `roverState` and consolidate server/UI operational-state consumers.
|
||||
- [x] Implement full-object `roverState` and consolidate server/UI operational-state consumers (live verification pending).
|
||||
- [ ] Add bundled YAML catalogs and one custom YAML profile per media category.
|
||||
- [ ] Preserve AIY HAT as an explicit profile and expose ordinary audio-device selection on every architecture, including TTS/horn/mixer paths.
|
||||
- [ ] Generate ALSA routing from shared input/output selections; connect microphone, TTS, horn, forwarded audio, and independent volume controls to the resulting logical devices.
|
||||
@@ -264,3 +264,12 @@ Verification for this stage:
|
||||
- Configuration UI/backend implementation is now present; end-to-end deployment verification remains pending. Profile/status/output controls, unified rover state, audio/media supervision, and bootstrap/update rework are still separate outstanding stages.
|
||||
|
||||
- Placement correction: rover configuration is embedded in the existing fleet management panel alongside the rover roster. Removed the separate administration tab.
|
||||
|
||||
### Unified operational state (2026-11-16)
|
||||
|
||||
- Roverd owns a complete `roverState` object with `headlightOn` and `laserOn`; null indicates an unavailable role. Sends on control connection/reconnection and logical changes. Pending notifications coalesce to the latest complete snapshot.
|
||||
- Server replaces one current object, exposes it in roster snapshots, and clears it on disconnect. Superseded sockets cannot overwrite state or remove a newer connection. Removed per-toggle event handling and separate server state stores.
|
||||
- Desktop/mobile/HUD controls, darkness reward restoration, and learning snapshots read the shared object. Telemetry and daemon management remain separate.
|
||||
- All four architecture binaries rebuilt successfully; focused frontend lint and server syntax checks passed. The two existing roster lifecycle tests passed after updating their state fixture. No new tests added.
|
||||
- Still verify live initial state, toggles through both GPIO/Firmata, reconnect state, disconnect clearing, and darkness restoration. Production UI assets have not been rebuilt.
|
||||
- Next implementation stage: YAML media profiles, command environments and child-process supervision, alongside the planned universal audio routing.
|
||||
|
||||
+94
-66
@@ -15,39 +15,41 @@ import (
|
||||
)
|
||||
|
||||
type WSClient struct {
|
||||
autoCharge *AutoChargeController
|
||||
commandMu sync.Mutex
|
||||
stopping atomic.Bool
|
||||
controlEvents chan RoverEvent
|
||||
cfg *Config
|
||||
adapter *SerialAdapter
|
||||
sensorFrames <-chan []byte
|
||||
events chan RoverEvent
|
||||
media *MediaSupervisor
|
||||
servo CameraServoController
|
||||
horn *HornSynth
|
||||
headlight ToggleController
|
||||
laser ToggleController
|
||||
peripherals *PeripheralManager
|
||||
log *log.Logger
|
||||
console *ConsoleNotifier
|
||||
recoverMu sync.Mutex
|
||||
recovering bool
|
||||
watchdogMu sync.Mutex
|
||||
watchdogOpen bool
|
||||
watchdogOK bool
|
||||
ttsQueue chan *ttsPayload
|
||||
chromeTTS *chromeTTSDaemon
|
||||
lastAux motorPWMPayload
|
||||
autoSideOn bool
|
||||
connMu sync.Mutex
|
||||
connected bool
|
||||
disconnectT *time.Timer
|
||||
rebootT *time.Timer
|
||||
seekIssued bool
|
||||
rebootIssued bool
|
||||
audioLevels AudioLevels
|
||||
audioMu sync.RWMutex
|
||||
autoCharge *AutoChargeController
|
||||
commandMu sync.Mutex
|
||||
stopping atomic.Bool
|
||||
stateChanged chan struct{}
|
||||
stateMu sync.Mutex
|
||||
roverState RoverState
|
||||
cfg *Config
|
||||
adapter *SerialAdapter
|
||||
sensorFrames <-chan []byte
|
||||
events chan RoverEvent
|
||||
media *MediaSupervisor
|
||||
servo CameraServoController
|
||||
horn *HornSynth
|
||||
headlight ToggleController
|
||||
laser ToggleController
|
||||
peripherals *PeripheralManager
|
||||
log *log.Logger
|
||||
console *ConsoleNotifier
|
||||
recoverMu sync.Mutex
|
||||
recovering bool
|
||||
watchdogMu sync.Mutex
|
||||
watchdogOpen bool
|
||||
watchdogOK bool
|
||||
ttsQueue chan *ttsPayload
|
||||
chromeTTS *chromeTTSDaemon
|
||||
lastAux motorPWMPayload
|
||||
autoSideOn bool
|
||||
connMu sync.Mutex
|
||||
connected bool
|
||||
disconnectT *time.Timer
|
||||
rebootT *time.Timer
|
||||
seekIssued bool
|
||||
rebootIssued bool
|
||||
audioLevels AudioLevels
|
||||
audioMu sync.RWMutex
|
||||
}
|
||||
|
||||
func NewWSClient(cfg *Config, adapter *SerialAdapter, frames <-chan []byte, events chan RoverEvent, media *MediaSupervisor, servo CameraServoController, headlight ToggleController, laser ToggleController, peripherals *PeripheralManager, logger *log.Logger, console *ConsoleNotifier) *WSClient {
|
||||
@@ -64,21 +66,21 @@ func NewWSClient(cfg *Config, adapter *SerialAdapter, frames <-chan []byte, even
|
||||
horn = NewHornSynth(cfg.Horn, logger)
|
||||
}
|
||||
client := &WSClient{
|
||||
controlEvents: make(chan RoverEvent, 16),
|
||||
cfg: cfg,
|
||||
adapter: adapter,
|
||||
sensorFrames: frames,
|
||||
events: events,
|
||||
media: media,
|
||||
servo: servo,
|
||||
horn: horn,
|
||||
headlight: headlight,
|
||||
laser: laser,
|
||||
peripherals: peripherals,
|
||||
log: logger,
|
||||
console: console,
|
||||
ttsQueue: ttsQueue,
|
||||
chromeTTS: chromeTTS,
|
||||
stateChanged: make(chan struct{}, 1),
|
||||
cfg: cfg,
|
||||
adapter: adapter,
|
||||
sensorFrames: frames,
|
||||
events: events,
|
||||
media: media,
|
||||
servo: servo,
|
||||
horn: horn,
|
||||
headlight: headlight,
|
||||
laser: laser,
|
||||
peripherals: peripherals,
|
||||
log: logger,
|
||||
console: console,
|
||||
ttsQueue: ttsQueue,
|
||||
chromeTTS: chromeTTS,
|
||||
audioLevels: AudioLevels{
|
||||
HornGain: 1.0,
|
||||
TTSGain: 1.0,
|
||||
@@ -109,6 +111,7 @@ func (c *WSClient) Run(ctx context.Context) error {
|
||||
defer c.chromeTTS.Shutdown()
|
||||
}
|
||||
|
||||
c.refreshState()
|
||||
if err := c.sendHello(ctx, conn); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -128,7 +131,7 @@ func (c *WSClient) Run(ctx context.Context) error {
|
||||
}
|
||||
}()
|
||||
go c.forwardSensors(ctx, conn)
|
||||
go c.forwardEvents(ctx, conn)
|
||||
go c.forwardState(ctx, conn)
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
@@ -284,12 +287,7 @@ func (c *WSClient) handleToggleCommand(name string, toggle ToggleController, pay
|
||||
if err := toggle.HandleAction(payload.Action); err != nil {
|
||||
return err
|
||||
}
|
||||
// Event names and payload keys use logical device names. GPIO polarity has
|
||||
// already been handled inside GPIOToggle, so the server only sees whether
|
||||
// the headlight or laser should be considered on.
|
||||
c.emitEvent(fmt.Sprintf("%s.state", name), map[string]any{
|
||||
fmt.Sprintf("%sOn", name): toggle.On(),
|
||||
})
|
||||
c.refreshState()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -472,20 +470,53 @@ func (c *WSClient) forwardSensors(ctx context.Context, conn *websocket.Conn) {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *WSClient) forwardEvents(ctx context.Context, conn *websocket.Conn) {
|
||||
if c.events == nil {
|
||||
// RoverState is a complete operational snapshot; nil means the role is absent.
|
||||
type RoverState struct {
|
||||
HeadlightOn *bool `json:"headlightOn"`
|
||||
LaserOn *bool `json:"laserOn"`
|
||||
}
|
||||
|
||||
func (c *WSClient) refreshState() {
|
||||
next := RoverState{}
|
||||
if c.headlight != nil {
|
||||
value := c.headlight.On()
|
||||
next.HeadlightOn = &value
|
||||
}
|
||||
if c.laser != nil {
|
||||
value := c.laser.On()
|
||||
next.LaserOn = &value
|
||||
}
|
||||
c.stateMu.Lock()
|
||||
old, _ := json.Marshal(c.roverState)
|
||||
updated, _ := json.Marshal(next)
|
||||
c.roverState = next
|
||||
c.stateMu.Unlock()
|
||||
if string(old) != string(updated) {
|
||||
select {
|
||||
case c.stateChanged <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *WSClient) forwardState(ctx context.Context, conn *websocket.Conn) {
|
||||
send := func() error {
|
||||
c.stateMu.Lock()
|
||||
state := c.roverState
|
||||
c.stateMu.Unlock()
|
||||
return writeJSON(ctx, conn, map[string]any{"type": "roverState", "state": state})
|
||||
}
|
||||
if err := send(); err != nil {
|
||||
conn.CloseNow()
|
||||
return
|
||||
}
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case evt := <-c.controlEvents:
|
||||
if evt.Type == "" {
|
||||
evt.Type = "event"
|
||||
}
|
||||
if err := writeJSON(ctx, conn, evt); err != nil {
|
||||
c.log.Printf("event send failed: %v", err)
|
||||
case <-c.stateChanged:
|
||||
if err := send(); err != nil {
|
||||
conn.CloseNow()
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -494,9 +525,6 @@ func (c *WSClient) forwardEvents(ctx context.Context, conn *websocket.Conn) {
|
||||
|
||||
func (c *WSClient) emitEvent(event string, data map[string]any) {
|
||||
events := c.events
|
||||
if event == "headlight.state" || event == "laser.state" {
|
||||
events = c.controlEvents
|
||||
}
|
||||
if events == nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ module.exports = {
|
||||
|
||||
const prevHeadlights = {};
|
||||
ctx.listOnlineRovers().forEach((rover) => {
|
||||
const state = rover?.headlight?.state;
|
||||
const state = rover?.roverState;
|
||||
const headlightOn = Boolean(state && state.headlightOn === true);
|
||||
prevHeadlights[String(rover.id)] = headlightOn;
|
||||
try {
|
||||
|
||||
@@ -8,39 +8,8 @@ const { sendAlert } = require('../alertService');
|
||||
const ALERT_COLOR = '#00bcd4';
|
||||
const { handleAck } = require('../commandService');
|
||||
|
||||
function coerceBool(value) {
|
||||
if (typeof value === 'boolean') return value;
|
||||
if (typeof value === 'number') return value !== 0;
|
||||
if (typeof value === 'string') {
|
||||
const normalized = value.trim().toLowerCase();
|
||||
if (normalized === 'true') return true;
|
||||
if (normalized === 'false') return false;
|
||||
if (normalized === '1') return true;
|
||||
if (normalized === '0') return false;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const HEARTBEAT_INTERVAL_MS = 15000;
|
||||
|
||||
function handleToggleEvent(roverId, msg) {
|
||||
if (msg.event === 'headlight.state') {
|
||||
const headlightOn = coerceBool(msg.data?.headlightOn);
|
||||
if (headlightOn != null) {
|
||||
roverManager.setToggleState(roverId, 'headlight', headlightOn);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (msg.event === 'laser.state') {
|
||||
const laserOn = coerceBool(msg.data?.laserOn);
|
||||
if (laserOn != null) {
|
||||
roverManager.setToggleState(roverId, 'laser', laserOn);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
roverWSS.on('connection', (ws) => {
|
||||
let roverId = null;
|
||||
ws.isAlive = true;
|
||||
@@ -80,19 +49,19 @@ roverWSS.on('connection', (ws) => {
|
||||
sendAlert({ color: ALERT_COLOR, title: 'Rover Online', message: roverId });
|
||||
return;
|
||||
}
|
||||
if (!roverId) return;
|
||||
if (!roverId || roverManager.rovers.get(roverId)?.ws !== ws) return;
|
||||
if (msg.type === 'sensor') {
|
||||
roverManager.handleSensorFrame(roverId, msg);
|
||||
} else if (msg.type === 'ack') {
|
||||
handleAck(msg);
|
||||
} else if (msg.type === 'event') {
|
||||
handleToggleEvent(roverId, msg);
|
||||
} else if (msg.type === 'roverState') {
|
||||
roverManager.setRoverState(roverId, msg.state);
|
||||
}
|
||||
});
|
||||
|
||||
ws.on('close', () => {
|
||||
clearInterval(heartbeat);
|
||||
if (roverId) {
|
||||
if (roverId && roverManager.rovers.get(roverId)?.ws === ws) {
|
||||
roverManager.removeRover(roverId);
|
||||
sendAlert({ color: ALERT_COLOR, title: 'Rover Offline', message: roverId });
|
||||
}
|
||||
|
||||
@@ -116,8 +116,7 @@ function createRuntime({ config, logger }) {
|
||||
// Do not serialize the live record: it contains sockets and circular state.
|
||||
return {
|
||||
meta: record.meta, sensors: record.lastSensor, hostStats: record.lastHostStats,
|
||||
batteryState: record.batteryState, headlightState: record.headlightState,
|
||||
laserState: record.laserState, drivers: [...(record.drivers || [])],
|
||||
batteryState: record.batteryState, roverState: record.roverState, drivers: [...(record.drivers || [])],
|
||||
locked: record.locked, privateOpen: record.privateOpen,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ const {
|
||||
getRosterForSocket,
|
||||
broadcastRoster,
|
||||
setNeedsHelp,
|
||||
setToggleState,
|
||||
setRoverState,
|
||||
handleHostStats,
|
||||
canSeeRover,
|
||||
canRequestControl,
|
||||
@@ -284,7 +284,7 @@ module.exports = {
|
||||
getRosterForSocket,
|
||||
broadcastRoster,
|
||||
setNeedsHelp,
|
||||
setToggleState,
|
||||
setRoverState,
|
||||
handleHostStats,
|
||||
handleSensorFrame,
|
||||
requestControl,
|
||||
|
||||
@@ -41,8 +41,7 @@ function createRosterLifecycle(deps) {
|
||||
locked: false,
|
||||
lockReason: null,
|
||||
batteryState: null,
|
||||
headlightState: null,
|
||||
laserState: null,
|
||||
roverState: null,
|
||||
room: `rover:${id}`,
|
||||
lastSeen: Date.now(),
|
||||
lastMovementAt: Date.now(),
|
||||
@@ -79,22 +78,7 @@ function createRosterLifecycle(deps) {
|
||||
} else {
|
||||
record.privateOpen = true;
|
||||
}
|
||||
if (!meta?.headlight?.enabled) {
|
||||
record.headlightState = null;
|
||||
} else if (record.headlightState == null) {
|
||||
record.headlightState = {
|
||||
headlightOn: Boolean(meta.headlight.initialOn),
|
||||
updatedAt: Date.now(),
|
||||
};
|
||||
}
|
||||
if (!meta?.laser?.enabled) {
|
||||
record.laserState = null;
|
||||
} else if (record.laserState == null) {
|
||||
record.laserState = {
|
||||
laserOn: Boolean(meta.laser.initialOn),
|
||||
updatedAt: Date.now(),
|
||||
};
|
||||
}
|
||||
record.roverState = null;
|
||||
rovers.set(id, record);
|
||||
spectatorSockets.forEach((socketId) => {
|
||||
const sock = io.sockets.sockets.get(socketId);
|
||||
@@ -118,6 +102,7 @@ function createRosterLifecycle(deps) {
|
||||
it can clean the reverse membership index and Socket.IO room membership.
|
||||
*/
|
||||
require('../dockingService').disconnect(record);
|
||||
record.roverState = null;
|
||||
rovers.delete(id);
|
||||
removeRoverDrivers(id, record);
|
||||
stopDockGuard(id);
|
||||
@@ -249,12 +234,9 @@ function createRosterLifecycle(deps) {
|
||||
// controls. Preserve that order here instead of rebuilding the inventory,
|
||||
// because ESP32 registration order is also the driver's display order.
|
||||
peripherals: Array.isArray(record.meta?.peripherals) ? record.meta.peripherals : [],
|
||||
headlight: record.meta?.headlight
|
||||
? { ...record.meta.headlight, state: record.headlightState }
|
||||
: record.meta?.headlight,
|
||||
laser: record.meta?.laser
|
||||
? { ...record.meta.laser, state: record.laserState }
|
||||
: record.meta?.laser,
|
||||
headlight: record.meta?.headlight,
|
||||
laser: record.meta?.laser,
|
||||
roverState: record.roverState,
|
||||
locked: record.locked || (isPrivateRecord(record) && !isPrivateOpen(record)),
|
||||
lockReason: record.lockReason || (isPrivateRecord(record) && !isPrivateOpen(record) ? 'private' : null),
|
||||
needsHelp: Boolean(record.needsHelp),
|
||||
@@ -290,19 +272,14 @@ function createRosterLifecycle(deps) {
|
||||
});
|
||||
}
|
||||
|
||||
function setToggleState(roverId, device, on) {
|
||||
function setRoverState(roverId, state) {
|
||||
const record = rovers.get(roverId);
|
||||
if (!record) return;
|
||||
if (typeof on !== 'boolean') return;
|
||||
if (device !== 'headlight' && device !== 'laser') return;
|
||||
const stateKey = device === 'headlight' ? 'headlightState' : 'laserState';
|
||||
const onKey = `${device}On`;
|
||||
record[stateKey] = {
|
||||
[onKey]: on,
|
||||
updatedAt: Date.now(),
|
||||
};
|
||||
if (!record || !state || typeof state !== 'object' || Array.isArray(state)) return;
|
||||
if (!['headlightOn', 'laserOn'].every((key) => Object.hasOwn(state, key)
|
||||
&& (state[key] === null || typeof state[key] === 'boolean'))) return;
|
||||
record.roverState = state;
|
||||
broadcastRoster();
|
||||
managerEvents.emit('rover', { roverId, action: device, record });
|
||||
managerEvents.emit('rover', { roverId, action: 'roverState', record });
|
||||
}
|
||||
|
||||
function setNeedsHelp(roverId, needsHelp) {
|
||||
@@ -367,7 +344,7 @@ function createRosterLifecycle(deps) {
|
||||
syncSpectatorRooms,
|
||||
broadcastRoster,
|
||||
setNeedsHelp,
|
||||
setToggleState,
|
||||
setRoverState,
|
||||
handleHostStats,
|
||||
canSeeRover,
|
||||
canRequestControl,
|
||||
|
||||
@@ -12,8 +12,7 @@ function createRosterManager(meta) {
|
||||
id: meta.name,
|
||||
meta,
|
||||
batteryState: null,
|
||||
headlightState: null,
|
||||
laserState: null,
|
||||
roverState: null,
|
||||
locked: false,
|
||||
lockReason: null,
|
||||
lastSeen: 123,
|
||||
|
||||
@@ -20,8 +20,8 @@ export default function BottomLeftPod({ roverId }) {
|
||||
const headlight = useControlSelector((control) => control.pipeline?.headlight);
|
||||
const laser = useControlSelector((control) => control.pipeline?.laser);
|
||||
const hornDevice = useControlSelector((control) => control.pipeline?.horn);
|
||||
const headlightOn = useControlSelector((control) => Boolean(control.pipeline?.headlightState?.headlightOn));
|
||||
const laserOn = useControlSelector((control) => Boolean(control.pipeline?.laserState?.laserOn));
|
||||
const headlightOn = useControlSelector((control) => Boolean(control.pipeline?.roverState?.headlightOn));
|
||||
const laserOn = useControlSelector((control) => Boolean(control.pipeline?.roverState?.laserOn));
|
||||
const hornActive = useControlSelector((control) => Boolean(control.state.horn?.active));
|
||||
const { setHeadlight, setLaser, startHorn, stopHorn } = useControlActions();
|
||||
const canControl = useCanControlRover(roverId);
|
||||
|
||||
@@ -27,9 +27,8 @@ function AuxColumnContent({ accessoriesAvailable, onShowAccessories }) {
|
||||
const camera = useControlSelector((control) => control.state.camera);
|
||||
const horn = useControlSelector((control) => control.state.horn);
|
||||
const headlight = useControlSelector((control) => control.pipeline?.headlight);
|
||||
const headlightState = useControlSelector((control) => control.pipeline?.headlightState);
|
||||
const roverState = useControlSelector((control) => control.pipeline?.roverState);
|
||||
const laser = useControlSelector((control) => control.pipeline?.laser);
|
||||
const laserState = useControlSelector((control) => control.pipeline?.laserState);
|
||||
const pipelineHorn = useControlSelector((control) => control.pipeline?.horn);
|
||||
const { setServoAngle, setHeadlight, setLaser, setAuxMotors, startHorn, stopHorn } = useControlActions();
|
||||
const dockTelemetry = useTelemetrySelector(roverId, selectDockTelemetry, dockTelemetryEqual);
|
||||
@@ -152,7 +151,7 @@ function AuxColumnContent({ accessoriesAvailable, onShowAccessories }) {
|
||||
<GPIOToggleControl
|
||||
label="Headlight"
|
||||
icon={FaLightbulb}
|
||||
on={headlightState?.headlightOn}
|
||||
on={roverState?.headlightOn}
|
||||
disabled={controlsDisabled}
|
||||
onToggle={handleHeadlightToggle}
|
||||
heightClass="h-full"
|
||||
@@ -162,7 +161,7 @@ function AuxColumnContent({ accessoriesAvailable, onShowAccessories }) {
|
||||
<GPIOToggleControl
|
||||
label="Laser"
|
||||
icon={FaCrosshairs}
|
||||
on={laserState?.laserOn}
|
||||
on={roverState?.laserOn}
|
||||
disabled={controlsDisabled || roomLightsLockedOn}
|
||||
onToggle={handleLaserToggle}
|
||||
heightClass="h-full"
|
||||
|
||||
@@ -48,8 +48,7 @@ export function useCommandPipeline(options = {}) {
|
||||
[rosterEntry],
|
||||
);
|
||||
|
||||
const headlightState = useMemo(() => rosterEntry?.headlight?.state ?? null, [rosterEntry]);
|
||||
const laserState = useMemo(() => rosterEntry?.laser?.state ?? null, [rosterEntry]);
|
||||
const roverState = rosterEntry?.roverState ?? null;
|
||||
const emitCommand = useCallback(
|
||||
(payload, cb) => {
|
||||
if (!roverId || !socket.connected) {
|
||||
@@ -234,9 +233,8 @@ export function useCommandPipeline(options = {}) {
|
||||
rosterEntry,
|
||||
servoConfig,
|
||||
headlight,
|
||||
headlightState,
|
||||
roverState,
|
||||
laser,
|
||||
laserState,
|
||||
horn,
|
||||
peripherals,
|
||||
emitCommand,
|
||||
@@ -256,9 +254,8 @@ export function useCommandPipeline(options = {}) {
|
||||
rosterEntry,
|
||||
servoConfig,
|
||||
headlight,
|
||||
headlightState,
|
||||
roverState,
|
||||
laser,
|
||||
laserState,
|
||||
horn,
|
||||
peripherals,
|
||||
emitCommand,
|
||||
|
||||
@@ -58,9 +58,8 @@ function DriveDockPanel() {
|
||||
const camera = useControlSelector((control) => control.state.camera);
|
||||
const horn = useControlSelector((control) => control.state.horn);
|
||||
const headlight = useControlSelector((control) => control.pipeline?.headlight);
|
||||
const headlightState = useControlSelector((control) => control.pipeline?.headlightState);
|
||||
const roverState = useControlSelector((control) => control.pipeline?.roverState);
|
||||
const laser = useControlSelector((control) => control.pipeline?.laser);
|
||||
const laserState = useControlSelector((control) => control.pipeline?.laserState);
|
||||
const pipelineHorn = useControlSelector((control) => control.pipeline?.horn);
|
||||
const { setServoAngle, setHeadlight, setLaser, startHorn, stopHorn } = useControlActions();
|
||||
const dockTelemetry = useTelemetrySelector(roverId, selectDockTelemetry, dockTelemetryEqual);
|
||||
@@ -126,7 +125,7 @@ function DriveDockPanel() {
|
||||
{headlightAvailable && (
|
||||
<GPIOToggleControl
|
||||
label="Headlight"
|
||||
on={headlightState?.headlightOn}
|
||||
on={roverState?.headlightOn}
|
||||
disabled={!roverId}
|
||||
onToggle={auxControls.setHeadlight}
|
||||
keyLabel={headlightLabel}
|
||||
@@ -135,7 +134,7 @@ function DriveDockPanel() {
|
||||
{laserAvailable && (
|
||||
<GPIOToggleControl
|
||||
label="Laser"
|
||||
on={laserState?.laserOn}
|
||||
on={roverState?.laserOn}
|
||||
disabled={!roverId || roomLightsLockedOn}
|
||||
onToggle={auxControls.setLaser}
|
||||
keyLabel={laserLabel}
|
||||
|
||||
Reference in New Issue
Block a user