hbp_nrp_excontrol.StateMachineInstance module

This module contains the class which encapsulates the dynamically loaded smach state machines

and provides the routines for their execution in parallel.

class StateMachineInstance(sm_id, sim_id, sim_dir, cle_error_pub=None, source_path=None)[source]

Bases: object

The class that encapsulates experiment controlling state machines and manages their execution in separate processes


Loads the specified script file and initializes the encapsulated state machine.

property is_running

Gets for the encapsulated state machine whether its process is running or not


True if the state machine process is running, False otherwise.

property is_started

Gets a value indicating whether the state machine has been started


Queries the return code of the current state machine process


Requests termination of the encapsulated state machine. As the termination happens asynchronously this method will return immediately after setting the request flag. If the state machine has already finished execution the method simply returns.


Restarts the state machine

property result

Gets the result of the state machine


Shuts down this state machine

property sm_id

Gets the unique state machine identifier specified upon creation.


The unique state machine identifier.

property sm_path

Gets or sets the path to the state machine code


Starts the execution of the state machine in a separate thread.


fail_if_started – If True, the state machines raises an Exception in case the state machine was started previously


Blocks until the encapsulated state machine has finished execution and a result is available

This will wait until the state machine process has terminated or the timeout has passed. If the timeout passed without the state machine process to terminate, a SIGINT is passed to the process and we wait again. If this does not help, a SIGTERM is sent and we wait again. Finally, we send a SIGKILL and wait for the process to complete.


timeout – Maximum waiting time in seconds

create_state_machine(sm_id, path)[source]

Creates a state machine instance descriptor for the given state machine

  • sm_id – The id of the state machine

  • path – The path to the state machine source code


A state machine descriptor