Hi, as in the subject, I would like to know if there is a method to get the actual state of a FSM. I know in principle is not hard to store it in variables but I was looking for a cleaner way yo get it.
Thanks, Alain
![]() The Orocos ProjectSmarter control in robotics & automation! |
|
Get the state of a rFSM state machine.
Hi, as in the subject, I would like to know if there is a method to get the actual state of a FSM. I know in principle is not hard to store it in variables but I was looking for a cleaner way yo get it. Thanks, Alain |
Get the state of a rFSM state machine.
Hi Alain,
On Mon, May 27, 2013 at 09:29:48AM +0200, alain [dot] scialoja [..] ... wrote:
> Hi,
> as in the subject, I would like to know if there is a method to get the
> actual state of a FSM. I know in principle is not hard to store it in
> variables but I was looking for a cleaner way yo get it.
You can access it by indexing the FSM:
'fsm._act_leaf'
will give you the rFSM-node of the current state, to
get the string name (fqn) add:
'fsm._act_leaf._fqn'
Note that 'fsm._act_leaf' can also be 'false' if the FSM has never
been entered before, so it may be better to do:
function get_active_state(fsm)
if fsm._act_leaf then return fsm._act_leaf._fqn end
return false
end
Needless to say that this is not part of the officially supported API.
Best regards
Markus
Get the state of a rFSM state machine.
Thank you Markus,
I need this to make a Supervisor FSM that checks if the position in space of my robot corresponds with the right state. There is already another FSM that coordinates the states transitions based on the position of the end effector but since it doesn't know the actual state I think it is not safe enough. Btw I don't have any previous experience with FSMs so I believe a well designed FSM wouldn't have this problem. Any feedback will be appreciated.
Kind regards,
Alain
On 27/mag/2013, at 12:24, Markus Klotzbuecher <markus [dot] klotzbuecher [..] ...> wrote:
> Hi Alain,
>
> On Mon, May 27, 2013 at 09:29:48AM +0200, alain [dot] scialoja [..] ... wrote:
>> Hi,
>> as in the subject, I would like to know if there is a method to get the
>> actual state of a FSM. I know in principle is not hard to store it in
>> variables but I was looking for a cleaner way yo get it.
>
> You can access it by indexing the FSM:
>
> 'fsm._act_leaf'
>
> will give you the rFSM-node of the current state, to
> get the string name (fqn) add:
>
> 'fsm._act_leaf._fqn'
>
> Note that 'fsm._act_leaf' can also be 'false' if the FSM has never
> been entered before, so it may be better to do:
>
> function get_active_state(fsm)
> if fsm._act_leaf then return fsm._act_leaf._fqn end
> return false
> end
>
> Needless to say that this is not part of the officially supported API.
>
> Best regards
> Markus
>
>
Get the state of a rFSM state machine.
On Mon, 27 May 2013, Alain Scialoja wrote:
> Thank you Markus,
> I need this to make a Supervisor FSM that checks if the position in space
> of my robot corresponds with the right state.
That is not the right job for a Coordinator/Supervisor... Another
activity/component should do the checking, and only inform the Supervisor
via an event if something "inappropriate" has happened.
> There is already another
> FSM that coordinates the states transitions based on the position of the
> end effector but since it doesn't know the actual state I think it is not
> safe enough. Btw I don't have any previous experience with FSMs so I
> believe a well designed FSM wouldn't have this problem. Any feedback will
> be appreciated.
>
> Kind regards,
> Alain
Herman
> On 27/mag/2013, at 12:24, Markus Klotzbuecher <markus [dot] klotzbuecher [..] ...> wrote:
>
>> Hi Alain,
>>
>> On Mon, May 27, 2013 at 09:29:48AM +0200, alain [dot] scialoja [..] ... wrote:
>>> Hi,
>>> as in the subject, I would like to know if there is a method to get the
>>> actual state of a FSM. I know in principle is not hard to store it in
>>> variables but I was looking for a cleaner way yo get it.
>>
>> You can access it by indexing the FSM:
>>
>> 'fsm._act_leaf'
>>
>> will give you the rFSM-node of the current state, to
>> get the string name (fqn) add:
>>
>> 'fsm._act_leaf._fqn'
>>
>> Note that 'fsm._act_leaf' can also be 'false' if the FSM has never
>> been entered before, so it may be better to do:
>>
>> function get_active_state(fsm)
>> if fsm._act_leaf then return fsm._act_leaf._fqn end
>> return false
>> end
>>
>> Needless to say that this is not part of the officially supported API.
>>
>> Best regards
>> Markus
Get the state of a rFSM state
I forgot to mention that I want to retrieve the state from another FSM.