Skip to content

Instantly share code, notes, and snippets.

@auginator
Last active June 24, 2022 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save auginator/3bdc45ffae44afecb9666a3865c42d7a to your computer and use it in GitHub Desktop.
Save auginator/3bdc45ffae44afecb9666a3865c42d7a to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: "robotStateTransitions",
initial: "auto",
context: {
lastControlledState: "AUTO",
},
actions: {
robotModeAutonomous: assign({
lastControlledState: (context ) => "auto" }),
robotModeManual: assign({
lastControlledState: (context ) => "manual"
})},
states: {
auto: {
entry: "robotModeAutonomous",
on: {
MANUAL: "manual",
RUN_STOP: "runstopped",
LOW_EFFORT: "loweffort",
},
},
manual: {
entry: "robotModeManual",
on: {
AUTO: "auto",
RUN_STOP: "runstopped",
LOW_EFFORT: "manual",
},
},
runstopped: {
on: {
AUTO: undefined,
MANUAL: undefined,
LOW_EFFORT: "loweffort",
DISENGAGE_RUNSTOP: "auto",
},
},
loweffort: {
on: {
RUN_STOP: "runstopped",
DISENGAGE_LOW_EFFORT: "auto",
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment