[Rock-dev] Component state transitions not recognized in ruby script

Sylvain Joyeux bir.sylvain at gmail.com
Mon Jan 9 17:24:45 CET 2017


It's a bug, but one that's easy to work around on your side.

On your side, the problem is with calling state(STOPPED). Call stop()
to stop the task.

Long explanation of the bug:

oroGen components have two channels to report states. The "standard"
RTT channel - the RTT lifecycle state machine which calls the hooks -
and the oroGen "extended states" mechanism that uses a port to report
state changes. The latter is the one that allows you to have more
states than the 'standard' RTT states.

Calling state(STOPPED) announces the state transition to the oroGen
extended states mechanism, but does not actually transition the RTT
state machine. It obviously should ensure that both are in sync in all
cases.

Sylvain

On Thu, Jan 5, 2017 at 8:39 AM,  <Karl.Kangur at esa.int> wrote:
> Hello fellow roboticians,
>
> I'm trying to make a simple state machine using a ruby script in ROCK, as a
> test I made a component that runs some internal process and then calls
> state(STOPPED) internally in the updateHook() method. When viewing the
> component with rock-display the state is properly transitioning from RUNNING
> to STOPPED.
>
> In the ruby script I am continuously polling the state of the component with
> component.state == :STOPPED, once this returns true I wait for 5 seconds and
> then call component.start to start it again. The issue is that I get the
> following error:
>
> /home/computer/dev/tools/orocos.rb/lib/orocos/task_context.rb:93:in
> `do_start': failed to start the '/component' task of type component::Task.
> Tasks must be in STOPPED state before calling start, but was in RUNNING
> (Orocos::StateTransitionFailed)
>     from /home/computer/dev/tools/orocos.rb/lib/orocos/task_context.rb:93:in
> `block in start'
>     from /home/computer/dev/tools/orocos.rb/lib/orocos/corba.rb:116:in
> `refine_exceptions'
>     from /home/computer/dev/tools/orocos.rb/lib/orocos/task_context.rb:91:in
> `start'
>     from script.rb:57:in `block in <main>'
>     from /home/computer/dev/tools/orocos.rb/lib/orocos/process.rb:695:in
> `block in run'
>     from /home/computer/dev/tools/orocos.rb/lib/orocos/process.rb:1098:in
> `guard'
>     from /home/computer/dev/tools/orocos.rb/lib/orocos/process.rb:694:in
> `run'
>     from script.rb:12:in `<main>'
>
> This is strange as, like I mentioned, rock-display reports that the
> component is in the STOPPED state.
>
> If I call component.stop, right after having checked that component.state ==
> :STOPPED returns true, the script works properly. I would like to avoid that
> since it adds redundancy. It seems state(STOPPED) is not properly recognized
> from the ruby side, or I am not doing it properly. In any case I have not
> found any documentation or examples on how to do it this way, the only
> documentation I found was the task states which describe what I did:
> http://rock-robotics.org/stable/documentation/orogen/task_states.html
>
> Is this a bug or am I doing it wrong?
>
> I saw that with Roby it's possible to do state machine stuff, but it looks
> way too complicated for such a trivial task.
>
> Thank you for your time,
>
> Karl Kangur
>
> This message and any attachments are intended for the use of the addressee
> or addressees only.
> The unauthorised disclosure, use, dissemination or copying (either in whole
> or in part) of its
> content is not permitted.
> If you received this message in error, please notify the sender and delete
> it from your system.
> Emails can be altered and their integrity cannot be guaranteed by the
> sender.
>
> Please consider the environment before printing this email.
>
>
> _______________________________________________
> Rock-dev mailing list
> Rock-dev at dfki.de
> http://www.dfki.de/mailman/cgi-bin/listinfo/rock-dev
>


More information about the Rock-dev mailing list