Skip to content

Add built-in web remote and low battery failsafe - #50

Open
parhipov wants to merge 1 commit into
okalachev:masterfrom
parhipov:web-remote
Open

parhipov wants to merge 1 commit into
okalachev:masterfrom
parhipov:web-remote

Conversation

@parhipov

Copy link
Copy Markdown

What

A remote control page served by the drone itself: connect a phone to the flix Wi-Fi network, open http://192.168.4.1/ and fly. No app to install.

Web remote

  • Two virtual sticks (the throttle holds its position), expo curve, adjustable sensitivity.
  • ARM / STOP buttons, STAB / ACRO / RAW switch.
  • Attitude indicator, per-motor output, battery voltage, link latency and packet loss, loop rate.
  • Tilt control: roll and pitch follow the phone's tilt relative to its pose when the mode is switched on, with a gain slider. An experimental lift control changes the throttle when the phone is raised or lowered.
  • Console with the drone's log, command input with history, and save log that downloads the telemetry received by the page as CSV.

Tilt control
Console

The PR also adds a low battery failsafe (safety.ino): when the voltage is measured, arming is refused at or below PWR_VOLT_LOW, and the drone lands if the voltage stays there for 3 s in flight.

How it works

  • flix/webrc.ino runs WebServer in its own task on core 0. The task only stores the latest stick values and queued commands; loopWebRC() applies them inside the main loop, so a slow client never stalls the flight loop.
  • flix/webrc_page.h is the page (plain HTML/CSS/JS, no external resources).
  • The page sends the sticks at 20 Hz. When it stops (browser closed, Wi-Fi lost), the existing RC loss failsafe lands the drone.
  • The page only displays telemetry until the user touches a stick, presses ARM or enables TILT, so an open page doesn't override an SBUS or MAVLink remote.
  • The server is not started in ESP-NOW mode or with Wi-Fi disabled.

Testing

  • Flown on a classic ESP32 (ESP32-D0WDQ6, MPU-6500, brushed motors) from Chrome on Android: stick control and tilt control.
  • Builds for esp32 and esp32c3 targets locally; I did not finish checking the other targets.
  • Not tested: the simulator build (I only added the stubs to gazebo/flix.h), iOS, the low battery landing in a real flight, and the lift control beyond first tries, so it is marked experimental.

Notes

  • Size: with this change the firmware takes 93% of the default app partition on a classic ESP32 and 98% on ESP32-C3, which is tight.
  • Tilt control needs the motion sensors, which browsers give to secure origins only. The docs describe the Chrome flag (chrome://flags → Insecure origins treated as secure).
  • The page has no authentication, same as MAVLink over the drone's Wi-Fi.
  • Happy to split the low battery failsafe into a separate PR, or to drop the lift control, if you prefer.

🤖 Generated with Claude Code

Web remote: the firmware serves a remote control page at
http://192.168.4.1/ (AP mode) or at the drone's IP (STA mode), so the
drone can be flown from a phone browser without any app.

- Two virtual sticks (the throttle holds its position), expo curve and
  adjustable sensitivity; arm/stop buttons; STAB/ACRO/RAW switch.
- Tilt control: roll and pitch follow the phone's tilt relative to its
  pose when the mode is switched on, with a gain slider. Experimental
  lift control changes the throttle when the phone is raised or lowered.
- Attitude indicator, motor outputs, battery voltage, link latency and
  packet loss, loop rate.
- Console with the drone's log, command input and history; the telemetry
  received by the page can be saved as CSV.
- The page only displays telemetry until the user touches a stick, arms
  or enables the tilt control, so it doesn't fight another remote.

The HTTP server runs in its own task on core 0 and only stores the latest
sticks and queued commands, which loopWebRC() applies in the main loop.
When the page stops sending, the regular RC loss failsafe lands the drone.

Low battery failsafe: when the voltage is measured, refuse arming at or
below PWR_VOLT_LOW and land if the voltage stays there for 3 s in flight.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@parhipov

Copy link
Copy Markdown
Author

A note on the tilt control (flying by the phone's gyroscope): it is more of a fun feature than a serious one. It is mostly for kids, and for that it works well: it turned out simple and really enjoyable to fly. But overall it is a toy, so feel free to treat it as optional.

@parhipov

Copy link
Copy Markdown
Author

One more thought: it probably makes sense to build a mobile app on top of this page, if you want one. It should not be hard to do, both for Android (an APK) and for iOS.

@parhipov

Copy link
Copy Markdown
Author

About the failing build_book check: the book itself builds fine (the Build book step passes). The job fails on the next step, Wait for Build to complete (docs.yml#L50-L54), and I think this will happen on any pull request from a fork:

  1. The step has if: ${{ env.FULL }}, and FULL is the string "false" here. A non-empty string is truthy in GitHub expressions, so the step runs anyway. if: ${{ env.FULL == 'true' }} would skip it.
  2. It waits for build_linux on ${{ github.sha }}. For a pull_request event this is the merge commit (30c9d4c), while build_linux runs on the PR head (8e289c9), so the check is never found: "The requested check was never run against this ref". ${{ github.event.pull_request.head.sha || github.sha }} would point it to the right commit.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant