Ticket #59 (closed feature: implemented)

Opened 4 years ago

Last modified 3 years ago

Lua state machine

Reported by: tim Owned by: tim
Priority: major Milestone: 0.3
Component: Fawkes Version:
Keywords: FSM Cc:
Git Branch:

Description (last modified by tim) (diff)

For reactive behaviours, a reactive agent and challenge applications in the RoboCup@Home league a generally usable Lua (finite) state machine (FSM) is necessary.

The state machine should obey the following criteria:

  • minimum amount of code overhead for the state machine
  • allow for hierarchical usage, this does not mean that it needs explicit API support, but for example that it does not use a global variable that prevents us from instantiating several state machines
  • Allow for the usage of our usual design patterns, like executing code on the entry to a state and not (necessarily) on the transition to the state. This allows for easier recycling of states, like driving to a standby position from different states does not need the very same code in every transition, which is more likely to be defined for the outgoing state
  • Allow safe state transitions. An example from the AtHome? league: the robot is grasping a cup. Now the time is up and to get the points for exiting the arena it should abort the current action. This would mean to retract the arm and then leave, and not drive with the extended arm. So if the "leave arena" transition is executed by a trigger, the state machine should make it simple for this safe behaviour.

Desired but not required features:

  • Visualization of the state machine (offline)
  • Visualization of the current FSM state and flow (online)

No decisions made, yet.

Change History

Changed 4 years ago by tim

  • status changed from new to assigned
  • description modified (diff)

Up to now I've read a few papers about Computer Game AI. The examples are usually at a very basic level and do not give much new information. An interesting thing which we might want to use is "Goal Driven AI", which basically means defining a policy which is then executed. After the FSM is implemented there might be a way to safe some code with this.

I had a closer look at the  state machine compiler (SMC). The SMC can create code for a number of languages, including Lua. However, this also means that it cannot exploit all the features available in a particular language. The major problem is, that it is not meant to be used with our typical usage patterns. Although supported, it is discouraged in the  FAQ.

I'm currently working on the Lua side determining if we want an own custom FSM language or if we want to have it a plain Lua API. Pros for the custom language include:

  • FSM domain specific language can make the code simpler
  • From the code it should be easy to generate a graph, for instance using graphviz

Cons for this are:

  • A parser has to be written
  • Inside a state or transition we would like to allow arbitrary Lua code. This means that a full Lua parser needs to be used and makes is somewhat big (there is an  LPeg-based parser called  Leg).

Changed 3 years ago by tim

  • milestone changed from RC2008 to Basic Platform

Changed 3 years ago by tim

  • status changed from assigned to closed
  • resolution set to implemented

Implemented, several revisions. We employ hybrid state machines (HSM) now. See trunk/src/lua/fawkes/fsm.lua and [trunk/src/lua/fawkes/fsm/jumpstate.lua for the implementation.

These features are now used in the skiller and the luaagent plugin. We should try it to write challenge agents for AtHome? as it features HSM visualization and some debug tools.

Note: See TracTickets for help on using tickets.

This list contains all users that will be notified about changes made to this ticket.

These roles will be notified: Reporter, Subscriber, Participant

  • Fawkes Trac List(Always)
  • Tim Niemueller(Reporter, Owner, Participant)