jrl-umi3218 / lipm_walking_controller

Walking controller based on linear inverted pendulum tracking
BSD 2-Clause "Simplified" License
18 stars 11 forks source link

FSM transition to a desired state in LIPMWalking::WalkInternal #51

Open miladm94 opened 10 months ago

miladm94 commented 10 months ago

Hi,

It appears that the mc_rtc FSM consistently executes the first state transition of LIPMWalking::WalkInternal after completing the Initial state. I wish to have the ability to choose any state transition from LIPMWalking::WalkInternal based on the output of the checktTansition function of the Initial state. For instance, I might need to transition from Initial to the DoubleSupport state under certain conditions.

Is there a method to specify the transition to a particular state in the meta state list?

Thank you.

gergondet commented 10 months ago

Hi @miladm94

That's not super easy and I'm not sure why you'd want to directly enter the double support state. In fact, I'm not even sure it's ok to go into the double support state without going into the standing state at first.

However you could do something like this to achieve what you want:

# states.yaml

# Existing states for reminder

LIPMWalking::WalkInternal:
  base: Meta
  transitions:
  - [LIPMWalking::Standing, DoubleSupport, LIPMWalking::DoubleSupport]
  - [LIPMWalking::DoubleSupport, SingleSupport, LIPMWalking::SingleSupport]
  - [LIPMWalking::DoubleSupport, Standing, LIPMWalking::Standing]
  - [LIPMWalking::SingleSupport, DoubleSupport, LIPMWalking::DoubleSupport]

LIPMWalking::WalkFSM:
  base: Parallel
  states: [LIPMWalking::RunStabilizer, LIPMWalking::WalkInternal]

# New states that directly starts in double support

# Note: this is the simplest solution but it still goes through the Standing state at some point
LIPMWalking::WalkInternal::DS:
  base: LIPMWalking::WalkInternal
  initial: LIPMWalking::DoubleSupport

LIPMWalking::WalkFSM::DS:
  base: Parallel
  states: [LIPMWalking::RunStabilizer, LIPMWalking::WalkInternal::DS]
# LIPMWalking.in.yaml
init: LIPMWalking::Initial
transitions:
  - [LIPMWalking::Initial, Standing, LIPMWalking::WalkFSM]
  - [LIPMWalking::Initial, DoubleSupport, LIPMWalking::WalkFSM::DS]