hbp_nrp_cle.cle.ClosedLoopEngine module

Implementation of the closed loop engine.

class ClosedLoopEngine(robot_control_adapter, robot_comm_adapter, brain_control_adapter, brain_comm_adapter, transfer_function_manager, external_module_manager, dt)[source]

Bases: hbp_nrp_cle.cle.DeterministicClosedLoopEngine.DeterministicClosedLoopEngine

Implementation of the closed loop engine that runs Transfer Functions (TF), brain simulation (B) and world simulation (W) concurrently for best effort performance

World simulation is run in parallel in a separate process; Transfer Functions and brain simulation are run as python Threads.

Notes about synchronization: TF, B and W start at cle.clock == 0 The difference between clocks is within one CLE timestep: i.e. abs(TF_t - B_t) < timestep , abs(TF_t - W_t) < timestep

e.g. rospy.get_time() in a Transfer Function will not return, very likely, the same t which the TF has been called with (the t parameter). What is guaranteed is that the time difference stays within one CLE timestep. In fact, the components are waited on for step completion at the end of a simulated step (run_step method) and their relative intra-step speed depends on their respective workload and scheduling.

run_step(timestep_s)[source]

Runs simulations and TFs for the given time step in seconds.

Parameters

timestep_s – simulation time, in seconds

Returns

Updated simulation time, otherwise -1

shutdown()[source]

Shuts down the simulation.

start()[source]

Starts the orchestrated simulations