add esc detection and arming/disarming features - #4
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds ESC-oriented UX to the main toolbar by tracking which nodes behave like ESCs (via uavcan.equipment.esc.Status) and exposing a one-click arm/disarm workflow (arm via broadcast RawCommand/safety messages; disarm via restarting detected ESC nodes).
Changes:
- Track ESC node IDs by listening for
uavcan.equipment.esc.Statustransfers and derive an “armed” state from node modes. - Add a toolbar button to arm ESCs (streaming commands until ESCs leave MAINTENANCE or a timeout) and to disarm by restarting detected ESC nodes.
- Minor window handling adjustments (subwindow focus behavior) and new UI icon.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (subWindowRef[windowPath]) { | ||
| subWindowRef[windowPath].focus(); | ||
| return; | ||
| } |
| }); | ||
| } else { | ||
| console.error(`Main: Failed to open ${windowPath}`); | ||
| console.error(`Main: Failed to open ${windowName}`); |
| const anyInMaintenance = () => | ||
| Object.values(localNode.nodeMonitors || {}).some(n => n?.status?.mode === MODE_MAINTENANCE); | ||
|
|
||
| if (!anyInMaintenance()) { | ||
| showMessage('ESC already armed — restart to drop back into maintenance mode', 'info'); | ||
| return; | ||
| } | ||
| if (armBurstRef.current) return; // already arming | ||
|
|
||
| showMessage('Arming in progress — REMOVE PROPELLERS!', 'warning'); | ||
| setArming(true); | ||
|
|
||
| let count = 0; | ||
| armBurstRef.current = setInterval(() => { | ||
| try { | ||
| localNode.sendUavcanEquipmentEscRawCommand(0, Array(8).fill(0)); | ||
| localNode.sendArdupilotIndicationSafetyState(0, 255); // SAFETY_OFF | ||
| localNode.sendUavcanEquipmentSafetyArmingStatus(0, 255); // FULLY_ARMED | ||
| } catch (error) { | ||
| console.error('Arm: error sending arm command:', error); | ||
| } | ||
| count++; | ||
|
|
||
| // Keep streaming through the whole arm sequence. Stop once no ESC is left in MAINTENANCE. | ||
| if (!anyInMaintenance()) { |
There was a problem hiding this comment.
this is ture, the arming is message sent from autopilot or the dronecan tool, not esc status, the text statement should be clear, otherwise chould be misleanding
| useEffect(() => { | ||
| return () => { | ||
| if (armBurstRef.current) { | ||
| clearInterval(armBurstRef.current); | ||
| armBurstRef.current = null; | ||
| } | ||
| }; | ||
| }, []); |
| const [dnaServerActive, setDnaServerActive] = useState(false); | ||
| const [arming, setArming] = useState(false); | ||
| const armBurstRef = useRef(null); | ||
| const [escNodeIds, setEscNodeIds] = useState([]); |
|
I think the arming feature should keep in the ESC panel |
|
The reason for trying to implement these changes was as mentioned:
Let me know your thoughts on this, and if any edits need to be made with the previous changes so that the points listed above can be solved. We can close this otherwise. Thanks! |
Hi, sure is convenient to show some important indicator status on the home page instead of see it in the panel. the webtool primary role is considered as monitor, I will try to make it not sending any control command by default, normally autopilot is the main role to control the periph at the bus. to the third point, I think the "stop all" is the button is disarm all esc if you control them via the esc pannel |
|
Is it okay if I look into modifying this solution to add indicator status and make the disarm/arm buttons clearly evident in ESC panel? Let me know how I should proceed with this |
that would be nice, thanks for that |
arm/disarm toggle and channel-wise ESC info
|
updated the following:
|
Features Added
esc.Statusonce operational, and then remembers that after the node is reset, which is helpful when restarting the ESCs connected to the bus.