Flight state machine
The flight-control state machine of the Bebop 2 4.7.1 flight program: 30 states, 64 events and 231 transitions, decoded from the firmware. The transitions for every state, each with its own diagram, are on their own page, and the commands that cause some of them are in the ARSDK command reference.
Static analysis of usr/bin/dragon-prog from the 4.7.1 rootfs. No connection to any drone, controller, or network host was made, and no mcbebop tool was used. Disassembly is the scratchpad dp.dis (text vaddr = file offset + 0x10000, data vaddr = file offset + 0x20000). The decode is a script, fsm_decode.py, which writes fsm-transitions.json and fsm-transitions.csv; every table below is generated from that JSON.
Tags: Verified (I read the instructions, listing, symbol, config, or ran the script this session), Agent-cited (taken from an earlier report in this folder), Inference (my reading beyond the bytes), Open (not determined).
Summary
Section titled “Summary”- The machine has 30 states and 231 transitions, built by one constructor at 0x1536d4: 30
bl 0x151dc4calls register state objects with an id, and 231bl 0x152c00calls register (from, event, to) triples. All 231 resolve; none has a computed argument. Verified. - State ids are an enum (1 to 44, with gaps at 15, 19, 21, 28, 30 to 33, 35 to 40). The name function 0x150cd8 gives the enum names (EMERGENCY_STATE, LANDED_STATE and so on). Events are an enum 0 to 63, named by function 0x22d230. Verified.
- Boot goes Init, event 2 INIT_OK, Landed. Takeoff goes Landed, event 3, WaitMotorRamping, event 20, TakeoffGround, event 6, Takeoff, then Hovering or TakeoffFlying and Flying. Verified table; the conditions behind each event are listed in the event section.
- Landing is reached by event 8 (land command or stick down) or 10 (battery critical) from 16 flying states, goes through Landing, event 17 GROUND_DETECTED, WaitMotorBraking, event 18, Landed. Verified.
- Event 0 EMERGENCY_EVENT goes to Emergency from 27 of the 30 states. The exceptions are Init, MagnetoCalibration, and LandingFlying, and LandingFlying is the only one whose code posts event 0 anyway, so that event is dropped there with the “No transition” log. Verified.
- Emergency entry sends the motor-stop command word (type 2) and Emergency returns to Landed (event 1) only once the stop word reads 1 and no battery-critical bit, hub+0x45d, or +0x2c8 == 2 latch is set. Verified.
- Events are processed from a queue each tick, before the current state’s process function runs. An event with no transition from the current state is logged at level 3 and discarded. Verified in 0x151a34 and 0x152528.
- Posters were found for 57 of the 60 events that appear in the table (events 7, 21, 51 have no post site), plus 22 event-0 posts that use a register argument. Event 4, 27, 31, 32 are defined but have neither a post site nor a transition.
- ARSDK Takeoff (message 7), Landing (12), Emergency (13) and Piloted-POI start/stop (22, 23) were traced from the behaviour dispatcher at 0x6b44c through Manager wrappers into feature virtual methods that post the events. The links for return home, move-by, follow-me, flight plan and animations were not traced end to end.
- The two scans that matter for negative results (callers of 0x152c00, post sites of event N) were repeated with a known positive: 0x151dc4 finds its 30 calls, and the post scan finds events 15, 16, 10, 8 and 55 as the earlier note did.
Method and counts
Section titled “Method and counts”| Item | Result | Tag |
|---|---|---|
bl 0x152c00 in the whole listing |
231, all inside the constructor range 0x1536d4..0x15b58c | Verified |
| Resolved to (from, event, to) | 231 | Verified (script) |
| Calls that are not transitions | 0. State registration uses a different function, 0x151dc4 (30 calls), and is not counted here | Verified |
| Unresolved or computed arguments | 0. Each call loads r1 and r3 from [r4,#off] (state objects) and r2 from mov r2,#imm, except the first (0x154828) where r1 is mov r1,r0 with r0 loaded from [r4,#0x84] at 0x1546a4 (Init), which my script seeds explicitly |
Verified |
| Other references to 0x152c00 | none: no b tail calls, no function-pointer words (the raw byte search hits twice at unaligned offsets 0x70503 and 0x84e07, which are inside code) |
Verified |
| Non-zero action stores before the calls | 0. The fifth call argument (stack word, a std::function guard that the engine calls after a transition at 0x151b4c) is always the empty one | Verified |
| Distinct (from, event) pairs | 231 of 231, so there are no duplicate or conflicting transitions | Verified |
Cross-check against the earlier decode (trans.py) |
identical on 230 of 231 rows; the earlier script printed the from-state of row 1 (0x154828) as “3” because r1 came from mov r1,r0. It is Init |
Verified |
| Events defined (name function) | 64 (0 to 63); 60 appear in the table; absent: 4, 27, 31, 32 | Verified |
Event post sites (bl or b to 0x152398) |
145 with an immediate r1, 22 with a register r1 (all event 0, see below) | Verified (script) |
| Function starts for “from where” | heuristic (dynamic symbols, bl targets, push {..lr}); a poster function address can be off by a few bytes for functions with a one-instruction stub in front |
Inference |
The states
Section titled “The states”The id is the value passed as r2 to 0x151dc4 and stored at state+4; the controller tick copies it to hub+0x7c8 (0x1525c8), which is what the battery poster and the flip gate test. Entry, process, and exit are vtable words 2, 4, and 5 (the vtable symbol address plus 8, 16, 20): the engine calls vptr[0] on entry (0x151b6c), vptr[3] on exit (0x151b34), and vptr[2] as process (0x1526d4). Word 3 is the default statePreProcess (0x150b74) for all 30 classes; words 6 and 7 are destructor-like (checked for Emergency: 0x23207c is bx lr, 0x23214c calls operator delete). The table lists ids in order. “Entry fn” is the address; the role column says what the entry and process functions do. Config keys quoted are from rootfs/etc/colibry/common/states.cfg, event.cfg, controller.cfg, reference.cfg.
| Id | State (enum name) | Class vtable | Entry / process / exit | Role and evidence | Tag |
|---|---|---|---|---|---|
| 1 | Emergency (EMERGENCY_STATE) | 0x578760 | 0x232080 / 0x232288 / 0x232078 | Motor stop. Entry 0x232080 writes 3 to sample+0x62c and +0x628 and command type 2 (stop) to the word at hub+0xc, and clears hub+0x45a (0x2320d4). Process 0x232288 zeroes outputs and runs helper 0x232160: stop word 0 re-posts event 0 (self loop, retry), 1 posts EMERGENCY_RESET unless battery-critical bits (hub+0x7cc & 3), hub+0x45d, or flag +0x2c8 == 2 on the 0x103740 object keep it latched, other values wait. Strings ‘Emergency process: Braking failed/finished’. | Verified |
| 2 | Landed (LANDED_STATE) | 0x578910 | 0x23764c / 0x23773c / 0x237614 | On the ground, motors off. Entry (0x2376d0) and exit (0x237620) clear hub+0xd81 (landing-requested flag). Process 0x23773c zeroes outputs, then helper 0x2376dc: hub+0x45d non-zero posts event 0; if param+0x49c and hub+0x858 > 0 it posts TAKEOFF_COMMAND (retry counter set to 3 by the takeoff handler). Leaves for ramping (3), magnetometer calibration (38), thrown takeoff (54), or Emergency (10, 46). | Verified |
| 3 | TakeoffGround (TAKEOFF_GROUND_STATE) | 0x578700 | 0x2313b0 / 0x231318 / 0x2311e8 | Motors spinning, aircraft still on the ground, waiting for lift-off. Entry selects the ‘User’ parameter profile. Process 0x231318 compares a float at hub+0x73c with param+0xe04 and calls the controller mode setter 0x1511a4; helper 0x231298 posts TAKEOFF_GROUND_FINISHED when hub+0x458 is non-zero. states.cfg has minThrustForTakeoffDetection = 8.3080 under the Takeoff heading. | Verified for instructions; threshold-to-key mapping and meaning of hub+0x458 Inference |
| 4 | Takeoff (TAKEOFF_STATE) | 0x578a60 | 0x23b35c / 0x23b2ec / 0x23b194 | Automatic climb after lift-off. Entry selects ‘User’. Helper 0x23b1f0 posts TAKEOFF_FINISHED when a float at hub+0x6f0 passes param+0xe10, VERTICAL_COMMAND or HORIZONTAL_COMMAND from the pilot stick flags (hub+0x85c, stick value hub+0x86c through 0x23f6d4). states.cfg takeOffHeightToExitTakeoff = 95 [%]. | Verified shape; threshold identity Inference |
| 5 | Landing (LANDING_STATE) | 0x5786d0 | 0x2309ac / 0x230720 / 0x230484 | Descent in manual mode. Entry selects ‘User’ and ‘Fast’, process uses ‘Normal’ (landing-speed profile, reference.cfg landingSpeedSet: Normal 1.1 m/s, Fast 2.0 m/s). Helper 0x2304e8 posts GROUND_DETECTED, LANDING_INTERRUPT, HORIZONTAL_COMMAND, LANDING_GPS_COMMAND, or event 0. | Verified strings and posts; why ‘Fast’ versus ‘Normal’ is chosen Open |
| 6 | Hovering (HOVERING_STATE) | 0x578ac0 | 0x23c3e4 / 0x23c374 / 0x23c1b0 | Position hold under manual control. Entry ‘User’. Shared helper 0x23c1d8 posts HORIZONTAL_COMMAND when hub+0x85c is set, HOVERING_GPS_COMMAND when hub+0x409 and hub+0x594 are set, LANDING_COMMAND when the vertical stick is pushed down past a limit (hub+0x6f4, stick value hub+0x86c against param+0xe14 times param+0x768), DEMO_MAGIC_CARPET_COMMAND when hub+0x450 and param+0x49c. states.cfg minVerticalSpeedPercentageForLanding = 0.8 sits under ‘Hovering/Hovering GPS’. | Verified posts and operands; the 0.8 key mapping is Inference |
| 7 | Flying (FLYING_STATE) | 0x5789a0 | 0x238b18 / 0x238ab0 / 0x2389d0 | Manual flight with horizontal stick input. Entry ‘User’. Helper 0x2389ec reads hub+0x85c and posts NO_HORIZONTAL_COMMAND (leads to GoToFix, the braking state). | Verified post; the flag-clear condition is Inference |
| 8 | WaitMotorRamping (WAIT_MOTOR_RAMPING_STATE) | 0x578b80 | 0x23e3ac / 0x23e230 / 0x23e21c | Waits for the motors to spin up after a start command. Entry 0x23e3ac stores start progress 3 (pending) in sample+0x624, command type 1 (start) in the word at hub+0xc, and hub+0xc0 = 1; process 0x23e230 reads start progress sample+0x624 and the spinning word sample+0x630: progress 1 stores type 3 and posts RAMPING_FINISHED_TAKEOFF; progress 0 posts event 0 (or event 20 if already spinning). Exit sets hub+0x45a = 1. Strings ‘Wait motor ramping finished: success’, ‘: ramping failed’, ‘: already spinning’. | Verified |
| 9 | WaitMotorBraking (WAIT_MOTOR_BRAKING_STATE) | 0x578b20 | 0x23d3a8 / 0x23d4bc / 0x23d424 | Waits for the motors to stop. Entry clears hub+0x45a (0x23d3fc). Process 0x23d4bc posts BRAKING_FINISHED or BRAKING_FAILED (self loop retry) from the stop-progress words; strings ‘Braking finished success/failure’. states.cfg waitAfterBrakingFinishedDuration = 2.2 s sits under ‘Wait motor braking’. | Verified posts and strings; use of the 2.2 s key by this state Inference |
| 10 | Flip (FLIP_STATE) | 0x578670 | 0x22dec0 / 0x22ea78 / 0x22f0e8 | The flip manoeuvre. Entry 0x22dec0 builds the manoeuvre and logs ‘Flip entry, estimated duration’. Process 0x22ea78 is a 4-byte stub (bx lr). FLIP_FINISHED comes from timing helper 0x22d770. Exit 0x22f0e8 restores the ‘Flying’ and ‘Default’ profiles. | Verified; details in bebop2-flip-acceptance.md (Agent-cited) |
| 11 | GoToFix (GOTOFIX_STATE) | 0x578a90 | 0x23bbac / 0x23bb04 / 0x23b8ec | Braking and settle after horizontal input stops. Entry ‘User’. Helper 0x23b97c posts GOTOFIX_FINISHED, HORIZONTAL_COMMAND, DEMO_MAGIC_CARPET_COMMAND. states.cfg ‘GoToFix’ keys: maxTimeOutInGoToFixState_s 10, minTimeOutInGoToFixState_s 2, angleMaxBrakingGoToFix 20. | Verified posts; key use Inference |
| 12 | Init (INIT_STATE) | 0x578850 | 0x234ae8 / 0x234b50 / 0x234b04 | Boot state, the machine starts here. Process 0x234b50 zeroes about ten controller outputs, then posts INIT_OK once hub+0x45f is non-zero (0x234c08..0x234c20). Nothing transitions into it. | Verified for instructions. Meaning of hub+0x45f (estimators ready) Inference |
| 13 | WaitThrownTakeoff (WAIT_THROWN_TAKEOFF) | 0x578be0 | 0x23f294 / 0x23f10c / 0x23f4e4 | Waits for a hand throw. Entry selects ‘ThrownTakeoff’ (event.cfg tooMuchAngleSet 150 deg). Helper 0x23f018 posts FREEFALL_DETECTED, THROWN_COMMAND_ABORTED on timeout (‘Wait thrown takeoff timeout’, states.cfg waitForThrowTimeout 10 s). Exit restores ‘Default’. | Verified |
| 14 | DemoMagicCarpet (DEMO_MAGIC_CARPET_STATE) | 0x578730 | 0x231b0c / 0x231a88 / 0x231998 | Hidden demo state, entry ‘Demo’ profile. Process 0x231a88 posts DEMO_MAGIC_CARPET_ABORTED when its latch (state+0x10) falls; helper 0x2319d4 posts event 0. Detailed in bebop2-magic-carpet.md. | Verified; rest Agent-cited |
| 16 | TakeoffFlying (TAKEOFF_FLYING_STATE) | 0x578940 | 0x2379e0 / 0x23797c / 0x23782c | Second takeoff phase after horizontal input during the climb. Entry ‘User’. Helper 0x237880 posts TAKEOFF_FINISHED, VERTICAL_COMMAND, NO_HORIZONTAL_COMMAND. | Verified posts; role Inference |
| 17 | NavGps (NAV_GPS_STATE) | 0x578b50 | 0x23dc14 / 0x23db74 / 0x23d658 | Flight-plan (waypoint) navigation. Entry ‘Flightplan’ profile, log ‘Nav Gps entry – Index’. Helper 0x23da18 posts NAV_GPS_STOP, NAV_GPS_LOST, HORIZONTAL_COMMAND. Exit 0x23d658 logs why the plan ended: finished, user command, GPS fix lost, break or stop command. | Verified |
| 18 | HoveringGps (HOVERING_GPS_STATE) | 0x578af0 | 0x23cb48 / 0x23cac8 / 0x23c924 | Position hold using GPS. Entry ‘User’. Helper 0x23c948 posts HORIZONTAL_COMMAND, NAV_GPS_LOST, LANDING_COMMAND. It ties with FollowMe for the most outgoing edges (17): flight plan, return home, follow-me, look-at-me, POI, move-by, wall lock, animation. | Verified |
| 20 | HoveringRescue (HOVERING_RESCUE_STATE) | 0x5786a0 | 0x22fc14 / 0x22f770 / 0x22f918 | Stabilising hover after a thrown release (entered from WaitThrownTakeoff on FREEFALL_DETECTED). Entry selects ‘Rescue’, ‘Freefall’ and ‘User’ profiles (controller.cfg has a ‘Rescue’ gain set). Helper 0x22f580 posts event 0 or RESCUE_FINISHED, string ‘Rescue timer after take off fast exceeded threshold’. states.cfg hoveringRescue* keys: MinDuration 0.7 s, MaxDuration 3.0 s. | Verified for profiles, posts and strings; role Inference |
| 22 | MagnetoCalibration (MAGNETO_CALIBRATION_STATE) | 0x578790 | 0x2322d0 / 0x232390 / 0x232308 | Magnetometer calibration on the ground. Process 0x232390 reads hub+0x5cc and calls hook 0x150c2c, posts MAGNETO_CALIBRATION_FINISHED (39) or ABORTED (33) through helper 0x23234c. Has no event-0 transition. | Verified for posts; stages Open |
| 23 | ReturnHome (RETURN_HOME_STATE) | 0x578880 | 0x23510c / 0x234de0 / 0x234c28 | Automatic return to the home point. Entry builds a flight plan (‘Flightplan’ profile; ‘Failed to build RTH flight plan : return home type not defined’). Process posts RETURN_HOME_FINISHED, NAV_GPS_LOST; string ‘Return home altitude updated (US detected)’. states.cfg has no return-home keys; event.cfg minDistanceForReturnHome = 20. | Verified |
| 24 | LandingGps (LANDING_GPS_STATE) | 0x5788e0 | 0x236c48 / 0x2369b0 / 0x236824 | Landing under GPS control. Entry ‘User’ and ‘Fast’, process ‘Normal’. Helper 0x23682c posts GROUND_DETECTED, LANDING_GPS_ABORT, HORIZONTAL_COMMAND, event 0, using the latch hub+0x45b. | Verified |
| 25 | LandingFlying (LANDING_FLYING_STATE) | 0x578970 | 0x238318 / 0x238098 / 0x237f3c | Landing with pilot input allowed. Entry ‘User’ and ‘Fast’, process ‘Normal’. Helper 0x237f58 posts GROUND_DETECTED, NO_HORIZONTAL_COMMAND and event 0, but the table has no event-0 transition (see special behaviours). | Verified |
| 26 | FollowMe (FOLLOW_ME_STATE) | 0x578820 | 0x23439c / 0x234028 / 0x234150 | Follow-me tracking mode, ‘FollowMe’ profile. Process 0x234028 posts FOLLOW_ME_COMMAND (restart), LOW_TARGET_POSITION_ACCURACY (‘Abort follow me: user position accuracy is not good enough’), ANIMATION_COMPLETED, ANIMATION_CANCELLED, USER_CMD_DURING_ANIMATION, GEOFENCE_LIMITS_EXCEEDED, NAV_GPS_LOST. The animation events show it also hosts boomerang, candle, dolly, helicoid and swing animations. | Verified posts; animation hosting Inference from the shared event set |
| 27 | LookAtMe (LOOK_AT_ME_STATE) | 0x578a00 | 0x23a2e4 / 0x23a178 / 0x239b90 | Camera tracks a target while the pilot flies, entry reuses the ‘FollowMe’ profile. Process 0x23a178 posts FOLLOW_ME_ABORTED (‘Look at me ABORT: user estimation state is unknown’), event 0. | Verified for posts and string; role Inference |
| 29 | EmergencyLanding (EMERGENCY_LANDING_STATE) | 0x5788b0 | 0x235bc4 / 0x2357e0 / 0x236464 | Forced descent. Entry selects ‘User’ and ‘Flyaway’ (controller.cfg rpmMaxAttitudeCommandSet Flyaway yaw 9, reference.cfg angleRefMaxSet Flyaway 10 deg); exit restores ‘Default’ and ‘Flying’. Process 0x2357e0 posts GROUND_DETECTED, then event 0 (which sends it to Emergency); event 17 here goes to Emergency. | Verified |
| 34 | RelativeNavigation (RELATIVE_NAVIGATION_STATE) | 0x5789d0 | 0x2394cc / 0x239444 / 0x2391bc | Move-by (relative displacement). Entry ‘Flightplan’ profile. Process 0x239444 posts MOVE_BY_FINISHED, HORIZONTAL_COMMAND (back to Flying), event 0. states.cfg moveByAngleTarget 2 deg, moveByDistanceTarget 0.1 m. | Verified posts; key use Inference |
| 41 | WallLock (WALL_LOCK_STATE) | 0x578bb0 | 0x23ea30 / 0x23e960 / 0x23e41c | Wall-tracking hold, ‘WallLock’ profile. Process 0x23e960 posts WALL_UNLOCK (‘No wall detected, unlock wall’) or event 0. | Verified for posts and string; role Inference |
| 42 | FlyingThrottle (FLYING_THROTTLE_STATE) | 0x578a30 | 0x23ab58 / 0x23aaf0 / 0x23a8f0 | Flight with the vertical channel as a raw throttle. Entry selects ‘User’ and ‘Throttle’ (controller.cfg ctrlGainAltitudeSet Throttle: all gains 0). Process posts only event 0; HEIGHT_MODE_COMMAND (62) leaves it. | Verified for profile and posts; role Inference from the zero gains |
| 43 | PilotedPOI (PILOTED_POI_STATE) | 0x5787f0 | 0x2336bc / 0x233548 / 0x232d28 | Piloted point-of-interest orbit, entry reuses the ‘FollowMe’ profile. Process 0x233548 posts ANIMATION_COMPLETED, ANIMATION_CANCELLED, USER_CMD_DURING_ANIMATION, GEOFENCE_LIMITS_EXCEEDED, NAV_GPS_LOST, event 0. | Verified posts; role Inference from the name and feature class |
| 44 | Animation (ANIMATION_STATE) | 0x5787c0 | 0x23279c / 0x232630 / 0x232408 | Scripted camera animation host, ‘Animation’ profile. Process 0x232630 posts ANIMATION_COMPLETED, ANIMATION_CANCELLED, USER_CMD_DURING_ANIMATION, GEOFENCE_LIMITS_EXCEEDED, NAV_GPS_LOST. Entered only from HoveringGps on event 55. | Verified |
The state objects are built in the constructor in this order and stored at manager offsets 0x84..0xf8; state_offset -> class was resolved from the vtable symbol in each constructor (inline for 21 states, out-of-line constructors for GoToFix, Landing, WaitMotorBraking, NavGps, ReturnHome, LookAtMe, PilotedPOI, RelativeNavigation, WallLock). Verified.
Entry functions of the flying states select named parameter profiles by string key. Those keys are rows in the *Set tables of controller.cfg and reference.cfg (for example ("Rescue", {...}) and ("Throttle", {...})), so the profile name in each entry function is real configuration, not a label. Which parameter each profile changes was read only where quoted above. Verified for the strings, Inference for effects.
The events
Section titled “The events”Event ids are posted through 0x152398 (appends the id to a lock-protected queue; logs “controller event: %s(%d)” at level 6, 0x1523e8). Names come from the switch function 0x22d230 (branch table at 0x22d23c). “Table” counts transitions that use the event. Addresses in parentheses are the bl or b to 0x152398.
| Id | Name | Table | Posted by, and from where | Tag |
|---|---|---|---|---|
| 0 | EMERGENCY_EVENT | 27 | User emergency command: ManualFlightCommands slot w7 0x14d970 (post 0x14d97c, cause 1 in hub+0x7d0), reached from behaviour message 13 EMERGENCY through Manager wrapper 0xd29fc (call 0x6cb5c). Per-state templates post it when sample+0x630 == 0 (motors not spinning, cause 4, 22 posts with a register argument, for example 0x2305d4, 0x231300) or when hub+0x45d != 0 (cause 2; most of the 28 posts with an immediate, for example 0x2312e8, 0x23c31c). Emergency re-posts it to itself at 0x232200. | Verified |
| 1 | EMERGENCY_RESET | 1 | Emergency helper 0x232160, post 0x232238, once the stop word is 1 and nothing latches the state. | Verified |
| 2 | INIT_OK | 1 | Init process 0x234b50, post 0x234c20, when hub+0x45f is non-zero. | Verified |
| 3 | TAKEOFF_COMMAND | 2 | Takeoff handler 0x14d8a4 (post 0x14d8c8) when hub+0x45a == 0; Landed helper 0x2376dc (post 0x237728) while param+0x49c and hub+0x858 > 0. | Verified |
| 4 | TAKEOFF_ABORTED | 0 | No post site and no transition. | Verified negative |
| 5 | TAKEOFF_FINISHED | 2 | Takeoff helper 0x23b1f0 (0x23b2e4) and TakeoffFlying helper 0x237880 (0x237974), after a float at hub+0x6f0 passes param+0xe10. | Verified |
| 6 | TAKEOFF_GROUND_FINISHED | 1 | TakeoffGround helper 0x231298 (0x231310) when hub+0x458 != 0. | Verified |
| 7 | TAKEOFF_STOPPED_BY_USER | 2 | In the table (Takeoff 7 to Hovering, TakeoffFlying 7 to Flying) but no post site found. | Open |
| 8 | LANDING_COMMAND | 19 | Land handler: ManualFlightCommands slot w5 0x14d6d4 (0x14d6e4), reached from message 12 LAND through Manager wrapper 0xd28dc (call 0x6cc7c). Also stick-down tests in Hovering helper 0x23c1d8 (0x23c2c8) and HoveringGps helper 0x23c948 (0x23cac0). | Verified |
| 9 | LANDING_INTERRUPT | 3 | Takeoff handler 0x14d8a4 tail call 0x14d950 when hub+0x45a != 0 and hub+0xd81 == 0; Landing 0x2304e8 (0x230688), LandingGps 0x23682c (0x236968), LandingFlying 0x237f58 (0x23805c). | Verified |
| 10 | BATTERY_CRITICAL | 19 | Controller tick helper 0x1524a0 (post 0x152520): hub+0x7cc & 3 set and current state id not in 1, 5, 9, 24, 25; also sets hub+0xd81. | Verified |
| 11 | HORIZONTAL_COMMAND | 9 | Pilot flag hub+0x85c (set by ManualFlightCommands slot w8 0x14d6e8) tested in Hovering 0x23c1d8, Takeoff 0x23b1f0, GoToFix 0x23b97c, HoveringGps 0x23c948, NavGps 0x23da18, Landing 0x2304e8, LandingGps 0x23682c, RelativeNavigation 0x239288. | Verified |
| 12 | NO_HORIZONTAL_COMMAND | 3 | Flying 0x2389ec (0x238aa8), TakeoffFlying 0x237880, LandingFlying 0x237f58. | Verified |
| 13 | VERTICAL_COMMAND | 2 | Takeoff 0x23b1f0 (0x23b2d4), TakeoffFlying 0x237880 (0x237964). | Verified |
| 14 | GOTOFIX_FINISHED | 1 | GoToFix helper 0x23b97c (0x23b9c8). | Verified |
| 15 | FLIP_COMMAND | 4 | AnimationsQuad slot w6 0x145730 (0x145810, tail call 0x145820) after the speed and battery gate. | Verified, Agent-cited note |
| 16 | FLIP_FINISHED | 1 | Flip timing helper 0x22d770 (0x22d7a4, 0x22d7e4). | Verified, Agent-cited note |
| 17 | GROUND_DETECTED | 4 | Ground detection in Landing 0x2304e8, EmergencyLanding 0x235750, LandingGps 0x23682c, LandingFlying 0x237f58 (latch hub+0x45b in LandingGps and LandingFlying). | Verified |
| 18 | BRAKING_FINISHED | 1 | WaitMotorBraking process 0x23d4bc (0x23d574). | Verified |
| 19 | BRAKING_FAILED | 1 | WaitMotorBraking process 0x23d4bc (0x23d5a0). | Verified |
| 20 | RAMPING_FINISHED_TAKEOFF | 1 | WaitMotorRamping process 0x23e230 (0x23e2bc, 0x23e34c). | Verified |
| 21 | RAMPING_FINISHED_FREEFALL | 1 | In the table (WaitMotorRamping 21 to Takeoff) but no post site found. | Open |
| 22 | FREEFALL_DETECTED | 1 | WaitThrownTakeoff helper 0x23f018 (0x23f0e8). | Verified |
| 23 | THROWN_COMMAND_ABORTED | 1 | ManualFlightOptional slot w8 0x14ddf0 (0x14de00), reached from message 11 THROWN_TAKEOFF_ABORTED through wrapper 0xd256c (call 0x6d27c); WaitThrownTakeoff 0x23f018 timeout (0x23f098) and process 0x23f10c (0x23f248). | Verified |
| 24 | NAV_GPS_COMMAND | 1 | 0x128398 (post 0x12848c); no vtable or direct caller found. | Verified post, trigger Open |
| 25 | HOVERING_GPS_COMMAND | 1 | Hovering helper 0x23c1d8 (0x23c36c) when hub+0x409 and hub+0x594 are set. | Verified |
| 26 | NAV_GPS_LOST | 6 | GPS-validity test (hub+0x409) in HoveringGps 0x23c948, NavGps 0x23da18, ReturnHome 0x234ca0, Animation 0x232470, PilotedPOI 0x233348, FollowMe 0x233c98. | Verified posts; condition polarity Inference |
| 27 | NAV_GPS_ABORT | 0 | No post site and no transition. | Verified negative |
| 28 | NAV_GPS_STOP | 1 | FlightPlan stop 0x127768 (0x1277a4); NavGps helper 0x23da18 (0x23da54). | Verified |
| 29 | DEMO_MAGIC_CARPET_COMMAND | 3 | Demo slot w9 0x126974 (0x126984); Hovering 0x23c1d8 (0x23c350, hub+0x450 and param+0x49c); GoToFix 0x23b97c (0x23bae4). | Verified |
| 30 | DEMO_MAGIC_CARPET_ABORTED | 1 | DemoMagicCarpet helper 0x2319d4 (0x231a54). | Verified, Agent-cited note |
| 31 | MAGNETO_CALIBRATION_FINISHED_GPS_ON | 0 | No post site and no transition. | Verified negative |
| 32 | MAGNETO_CALIBRATION_FINISHED_GPS_OFF | 0 | No post site and no transition. | Verified negative |
| 33 | MAGNETO_CALIBRATION_ABORTED | 1 | MagnetoCalibration helper 0x23234c (0x23238c). | Verified |
| 34 | RETURN_HOME_FINISHED | 1 | ReturnHome helper 0x234ca0 (0x234d50). | Verified |
| 35 | RETURN_HOME_COMMAND | 13 | ReturnHome slots w4 0x135130 (0x135178) and w13 0x135208 (0x135298); message 14 RETURN_HOME case 0x6ca88 is the likely source. | Verified posts; message link Inference |
| 36 | RETURN_HOME_ABORTED | 1 | ReturnHome slot w5 0x135028 (0x135050); ReturnHome entry 0x23510c (0x2354bc). | Verified |
| 37 | LANDING_GPS_ABORT | 1 | LandingGps helper 0x23682c (0x2368d8). | Verified |
| 38 | MAGNETO_CALIBRATION_COMMAND | 1 | 0x137740 (0x13775c) in the GlobalNavigationEstimation vtable; message 124 CALIBRATION_MAGNETO is the likely source. | Verified post; link Agent-cited and Inference |
| 39 | MAGNETO_CALIBRATION_FINISHED | 1 | MagnetoCalibration helper 0x23234c (0x23237c). | Verified |
| 40 | LANDING_GPS_COMMAND | 1 | Landing helper 0x2304e8 (0x230708). | Verified |
| 41 | FOLLOW_ME_COMMAND | 4 | FollowMe slot w7 0x136160 (0x136240), 0x1363b0 (0x136420), FollowMe helper 0x233c98 (0x233f38). | Verified |
| 42 | FOLLOW_ME_ABORTED | 2 | FollowMe slot w8 0x13614c (0x13615c); LookAtMe helper 0x23a060 (0x23a0a4). | Verified |
| 43 | LOOK_AT_ME_COMMAND | 7 | FollowMe slot w7 0x136160 (0x136290), the second mode of the same start function. | Verified |
| 44 | PILOTED_POI_COMMAND | 6 | PilotedPOI slot w4 0x1368d0 (0x136964), reached from message 22 START_POI through wrapper 0xd2be8 (call 0x6ca20). | Verified |
| 45 | PILOTED_POI_ABORTED | 1 | PilotedPOI slot w5 0x136740 (0x13674c), message 23 STOP_POI through wrapper 0xd2c88 (call 0x6c998). | Verified |
| 46 | SENSOR_DEFECTIVE_BAROMETER | 21 | Barometer gate 0x14e6ac (post 0x14e704), called once per sample from 0x103f5c: flag at +0x2c8 of the 0x103740 object == 2, byte +0xc of its argument clear, state id not 1 or 29. | Verified gate; meaning of +0x2c8 Inference |
| 47 | EMERGENCY_LANDING_COMMAND | 19 | 0x22cd34 (post 0x22d1ec), in the Mykonos3 estimator-state vtable region 0x578648, with hub+0x7d0 = 8 and the string ‘Flyaway detected’. | Verified; flyaway link Inference |
| 48 | MOVE_BY_COMMAND | 3 | AutonomousNavigation slot w4 0x1358a4 (0x1358f8); message 16 MOVE_BY_COMMAND is the likely source (wrapper 0xd1c84). | Verified post; message link Inference |
| 49 | MOVE_BY_FINISHED | 1 | RelativeNavigation helper 0x239288 (0x23940c). | Verified |
| 50 | MOVE_BY_ABORTED | 1 | AutonomousNavigation slot w5 0x135890 (0x1358a0). | Verified |
| 51 | WALL_LOCK_COMMAND | 2 | In the table (Hovering and HoveringGps) but no post site found. | Open |
| 52 | WALL_UNLOCK | 1 | WallLock helper 0x23e848 (0x23e88c). | Verified |
| 53 | RESCUE_FINISHED | 1 | HoveringRescue helper 0x22f580 (0x22f6f4). | Verified |
| 54 | WAIT_THROWN_FREEFALL_COMMAND | 1 | ManualFlightOptional slot w7 0x14dd3c (0x14dd68), ‘Wait thrown takeoff command’; message 9 WAIT_THROWN_TAKEOFF is the likely source. | Verified post; link Inference |
| 55 | DO_ANIMATION_COMMAND | 2 | Eight animation start functions (0x1466f0, 0x147204, 0x147db0, 0x1488f8, 0x1493d8, 0x14a558, 0x14bec0, 0x14d4a0), message 152 ANIMATION_START. | Verified posts; message Agent-cited |
| 56 | ANIMATION_COMPLETED | 3 | Animation timer 0x145bb8 (0x145d04) and the Animation, PilotedPOI, FollowMe process helpers. | Verified |
| 57 | ANIMATION_CANCELLED | 3 | FlightPlan stop 0x127768 (0x1277e4) and the Animation, PilotedPOI, FollowMe process helpers. | Verified |
| 58 | NEW_ANIMATION_WITH_INVALID_PARAMETERS | 1 | The same eight animation start functions as event 55, on invalid parameters. | Verified |
| 59 | USER_CMD_DURING_ANIMATION | 3 | Animation 0x232470, PilotedPOI 0x233348, FollowMe 0x233c98 helpers. | Verified |
| 60 | GEOFENCE_LIMITS_EXCEEDED | 3 | Animation, PilotedPOI, FollowMe helpers (0x23261c, 0x233464, 0x233fdc). | Verified |
| 61 | LOW_TARGET_POSITION_ACCURACY | 1 | FollowMe helper 0x233c98 (0x233de0). | Verified |
| 62 | HEIGHT_MODE_COMMAND | 1 | Gate 0x14d9c8 (post 0x14da54): argument set and state id 42. Caller not found. | Verified gate; trigger Open |
| 63 | THROTTLE_MODE_COMMAND | 4 | Gate 0x14d9c8 (post 0x14da30): argument clear and state id 6, 18, 7, or 11. Caller not found. | Verified gate; trigger Open |
Event 0 carries a cause word in hub+0x7d0: 1 user emergency command, 2 hub+0x45d, 4 motors not spinning (sample+0x630 == 0), 8 flyaway (event 47). Verified for the stores. That the tick sends it outward as a bit mask (0x103a6c, hook id 50) is Agent-cited from psoc-error-consumers.md. The 22 register-argument posts are all mov r1,rX after cmp rX,#0 where rX was loaded from sample+0x630, so r1 is 0 on that path; the script classifies them by that pattern (a cmp rX,#0 within 140 instructions before the post and a 4 stored to hub+0x7d0), and I read 0x2305d4, 0x22f674, 0x231300, 0x2325f0 and 0x234dd8 by hand. Verified.
Special behaviours
Section titled “Special behaviours”Engine and tick order. One tick (0x152528, called from the per-sample entry at 0x103f54) first calls the current state’s statePreProcess if it is not the default (none is), then runs the event loop 0x151a34, then the state’s process function, then copies the current state id to hub+0x7c8, calls the battery check 0x1524a0, and publishes hub+0x45a as a Data<bool>. The event loop pops each queued id, looks up the current state in the map at fsm+0x2c and then the event in the inner map; on a hit it calls the old state’s exit (vptr[3]), sets the new state, runs the optional action, sets the new state’s active flag, and calls its entry (vptr[0]). Events posted during an entry are appended to the same queue and are handled in the same loop. A self transition (for example Flying 55 to Flying) runs exit and entry again. Verified at 0x151b28..0x151b74 and 0x1526a8..0x1526dc. The constructor stores Init into fsm+0x40 and fsm+0x48 (0x154804..0x15480c); which of the two fields the first tick uses as “current” was not traced. Open.
The “No transition from current state” rule. When the lookup fails at either level the loop jumps to 0x151bc4, which logs through ulog_log_write level 3 (the string is the one cited in bebop2-flip-acceptance.md, EventsFsm: No transition from current state!), pops the event and continues. There is no error return, no state change and no message to the controller. Every event that a state does not list is therefore silently dropped, which is how the table behaves for a second FLIP_COMMAND, for BATTERY_CRITICAL during a flip, and for event 0 in LandingFlying. Verified for the loop; log text Agent-cited.
Emergency from everywhere. Event 0 has a transition to Emergency from 27 states, including Emergency itself (a self loop that retries the stop). The three states without one are Init (never flying), MagnetoCalibration (on the ground), and LandingFlying. For LandingFlying the helper 0x237f58 does post event 0 (0x238020, cause 2 or 4), and the table has no (LandingFlying, 0) row, so a motor-not-spinning or hub+0x45d condition during that state is dropped; the state is left only through events 12, 17, 46, 47, 9 and 35. By contrast the sibling LandingGps and Landing both map event 0 to Emergency. Verified for the table and the post; whether the dropped event is reached in practice (for example because the state is entered rarely) Open. Other universal edges: event 46 goes to Emergency from Landed, TakeoffGround, WaitThrownTakeoff and to EmergencyLanding from 18 flying states (not from TakeoffFlying or DemoMagicCarpet); event 47 goes to EmergencyLanding from 19 states (not from Landed, DemoMagicCarpet, WaitThrownTakeoff, HoveringRescue, WaitMotor*).
Emergency exit. EMERGENCY_RESET (1) goes to Landed, but 0x232160 only posts it when the stop word sample+0x62c is 1, hub+0x7cc & 3 is clear (battery not critical), hub+0x45d is 0, and the 0x103740 object’s +0x2c8 is not 2. If any of those holds it clears the command word and stays in Emergency. EmergencyLanding sends event 17 (ground detected) to Emergency, not to Landed. Verified for the branch structure; what +0x2c8 == 2 means (the barometer-defective gate uses the same value) Inference.
Takeoff path. ARSDK takeoff (message 7) ends in 0x14d8a4. If hub+0x45a (a motors-running flag: set by WaitMotorRamping exit and HoveringRescue entry, cleared by Emergency entry and WaitMotorBraking entry) is 0 it posts TAKEOFF_COMMAND (3) and, if param+0x49c, sets hub+0x858 to 3 so Landed re-posts it on following ticks. If the motors are already running and hub+0xd81 is 0 it posts LANDING_INTERRUPT (9), which cancels a landing in progress (Landing 9 to Hovering, LandingGps 9 to HoveringGps, LandingFlying 9 to Flying); if hub+0xd81 is set it only logs “Could not apply takeoff command due to critical battery level” and sends hook id 56. The table path is Landed, 3, WaitMotorRamping, 20, TakeoffGround, 6, Takeoff, then 5 or 7 or 13 to Hovering, 11 to TakeoffFlying, which finishes to Flying (5), Flying (7) or Flying (13). A start refusal (progress 0, for example an uncleared motor errno, see psoc-error-consumers.md) makes WaitMotorRamping post event 0 and the machine enters Emergency. Verified.
Thrown takeoff. Landed, 54, WaitThrownTakeoff; then 3 to TakeoffGround, 22 FREEFALL_DETECTED to HoveringRescue, 23 or 8 to WaitMotorBraking. HoveringRescue exits with 53 to GoToFix. WaitMotorRamping 21 (RAMPING_FINISHED_FREEFALL) to Takeoff has no poster. Verified table.
Landing path. Event 8 or 10 from any of 16 flying states (Takeoff, TakeoffFlying, Hovering, Flying, GoToFix, NavGps, DemoMagicCarpet, HoveringGps, ReturnHome, FollowMe, LookAtMe, PilotedPOI, RelativeNavigation, WallLock, Animation, FlyingThrottle) goes to Landing. On the ground-ish states (TakeoffGround, WaitMotorRamping, WaitThrownTakeoff) it goes to WaitMotorBraking; Landed treats 10 as Emergency. Landing then moves to LandingFlying (11), LandingGps (40), WaitMotorBraking (17), or back to Hovering (9). WaitMotorBraking posts 18 to Landed or 19 to itself. Battery-critical posting is skipped in states 1, 5, 9, 24, 25 (0x1524c0..0x1524f4), which is what stops it re-posting during a landing; when it does post it also sets hub+0xd81, a landing-requested flag that the land helper 0x14d6ac sets too and that Landed entry and exit clear. Verified.
The flip gate. Event 15 has transitions only from Hovering, Flying, HoveringGps, DemoMagicCarpet (to Flip, state 10), and Flip leaves only through 16 FLIP_FINISHED (to GoToFix) or event 0. From GoToFix and Animation the ARSDK-side gate passes but the event is dropped. Flip’s own process function is a stub. Verified for the table; the gate itself Agent-cited from bebop2-flip-acceptance.md.
The demo state. DemoMagicCarpet (14) is entered only by event 29 from Takeoff, Hovering, GoToFix (Takeoff 29, Hovering 29, GoToFix 29 rows), left by 30 to Landing, 8/10 to Landing, 15 to Flip, 0 to Emergency. The poster of 29 is Demo slot w9 (0x126974) and the hub+0x450 gate in Hovering and GoToFix. hub+0x450 has no setter other than its zero initialiser at 0x1606d0 (Agent-cited, bebop2-magic-carpet.md). Verified table; rest Agent-cited.
Height and throttle modes. Gate 0x14d9c8 posts THROTTLE_MODE_COMMAND (63) if its argument is 0 and the current state id is 6, 18, 7 (or 11 when the argument is 0), and HEIGHT_MODE_COMMAND (62) if the argument is non-zero and the state is 42; otherwise it returns -11. Table: Hovering, Flying, GoToFix, HoveringGps 63 to FlyingThrottle, FlyingThrottle 62 to GoToFix. The caller is not known. Verified gate; trigger Open.
States with few entry points. Animation only from HoveringGps (55). WallLock only from Hovering and HoveringGps (51). MagnetoCalibration only from Landed (38). WaitThrownTakeoff only from Landed (54). HoveringRescue only from WaitThrownTakeoff (22). NavGps only from HoveringGps (24). Init from nothing. Verified.
Diagrams
Section titled “Diagrams”There are 37 small diagrams, drawn from the transition table by a script. One is here and the rest sit on the transitions page, each above the table for its state, so a picture and its text are side by side. Three things about how they are drawn:
- The events that leave almost every state (emergency, emergency landing, barometer defective, the landing command and battery critical) are drawn once, below, and left out of every other diagram. Without that the per-state pictures were still over 2,000 pixels wide.
- Edge labels carry only the event number, so a diagram is read alongside the events table.
- The six states with the biggest fan of transitions are split into one picture for the transitions entering them and one for those leaving.
The sources parse with the real Mermaid 11 parser. That check was passed before anyone had looked at a single picture, and it said nothing about whether they could be read: only rendering them and viewing the result, on a phone as well as a desktop, showed that the first versions were far too wide, and the diagrams were redrawn smaller. Syntax passing is not the same as readable. The sources are kept in the project repository, and each diagram comes in a light and a dark version that follow the site theme.
Events that leave almost every state
Section titled “Events that leave almost every state”What is not established
Section titled “What is not established”Unresolved or unposted events. Events 7 TAKEOFF_STOPPED_BY_USER, 21 RAMPING_FINISHED_FREEFALL and 51 WALL_LOCK_COMMAND are in the table but have no post site. Events 4, 27, 31, 32 are defined but neither posted nor in the table. The posters of 62 and 63 (gate 0x14d9c8), 24 (0x128398), and the four items behind the Hovering and GoToFix flags (hub+0x450, hub+0x409, hub+0x594, hub+0x458) have no traced upstream. Open.
Computed arguments. None remain in the transition table. For event posts, 22 sites use a register argument; all were classified as event 0 by the cmp-zero pattern (script, with 0x2305d4, 0x22f674, 0x231300, 0x2325f0 and 0x234dd8 read by hand). The other 17 were classified by the same script pattern without reading each one. Verified for the five read by hand, Inference for the other 17.
States whose role is thinly read. TakeoffFlying (events and name only), PilotedPOI (events and the shared FollowMe profile), LookAtMe, WallLock and MagnetoCalibration (calibration stages), HoveringRescue (profile names and timer keys only), and DemoMagicCarpet beyond the earlier note. For these, the role line above is Verified for events and strings and Inference for the purpose.
Meaning of hub flags. hub+0x45a (motors running) is inferred from its writers; hub+0x45d (posts event 0 with cause 2) has no strb writer except the zero initialiser at 0x1606cc (other store forms were not searched), so how it becomes non-zero is Open; hub+0x45f, 0x458, 0x409, 0x594, 0x450, 0x858, and the +0x2c8 field of the 0x103740 object are read but not named. Param+0x49c is read in several takeoff and demo gates and is unnamed.
Message to feature links. The link from message id to Manager wrapper was verified for 7, 11, 12, 13, 22, 23 only. Messages 14, 15, 16, 124, 152, and the follow-me callbacks are traced to the mailbox but not into the feature call. The type-13 mailbox consumer (0xb4f18) updates a separate piloting-status tracker (field at +0xc4); its relation to this FSM was not traced.
Initial-state field. Which of fsm+0x40 and fsm+0x48 the engine treats as current at the first tick (the constructor sets both to Init).
Not looked at. The Mykonos3 estimator FSM (EstimatorStateInit, EstimatorStateRunningFlying, event enum eEstimatorEvents) is a second machine of the same kind; only its link to event 47 was read. The trajectory FSM (Navigation::TrajectoryManagerFSMImpl) was not read.
Comments
Spotted a mistake, or tried this on your own Bebop? Leave a note. Comments are kept on this site's own server.