soar.controller¶
Controller classes and functions for controlling robots, simulated or real.
-
class
soar.controller.Controller(client_future, robot, brain, simulated, gui, step_duration=0.1, realtime=True, world=None, log=None)¶ Bases:
objectA class for interacting with simulated or real robots.
Initialized by the client and used to call the user defined methods of the robot and brain.
-
running¶ bool – Indicates whether the controller is currently running–that is, repeatedly stepping.
-
started¶ bool – Indicates whether the controller has been started.
-
stopped¶ bool – Indicates whether the controller has been stopped.
-
step_count¶ int – The number of steps that have elapsed so far.
-
elapsed¶ float – The number of seconds spent actually running. Unless a step takes longer than
step_duration, this will typically be thestep_countmultiplied bystep_duration. If any steps take longer, the additional time will also be counted here.
Parameters: - client_future – The function to call to schedule a future for the client to execute.
- gui – The currently
soar.gui.soar_ui.SoarUIinstance, if any, orNoneif in headless mode. - simulated (bool) – If
True, the controller will simulate the robot. Otherwise it will treat the robot as real. - robot – An instance of
soar.robot.base.BaseRobotor a subclass. - brain – The currently loaded brain module, supporting the
on_load(),on_start(),on_step(),on_stop(), andon_shutdown()methods. - realtime (bool) – If
True, stepping takes real time–that is, the controller will sleep for whatever time is not used running the step, until the step has taken at leaststep_durationseconds. Otherwise, no sleeping will occur; however the elapsed time will behave as if each step was at leaststep_durationlong. - world – An instance of
soar.sim.world.Worldor one of its subclasses if one is loaded, orNone. - step_duration (float) – The duration of a single step, in seconds.
- log – A callable that accepts a
dict-like object as an argument to log to a file, orNone, if no logging - to take place. (is) –
-
failure()¶ Called when the controller fails.
-
load()¶ Called when the controller is loaded.
-
log_step_info()¶ Log information about the current step.
-
run(n=None)¶ Runs the controller, starting it if necessary, for one or many steps, or without stopping.
Parameters: n – If None, run forever, at least until stopped. If 0, start the controller, if it has not yet been started. Otherwise, forn > 0, run for that many steps.
-
shutdown()¶ Called when the controller is shut down.
-
stop()¶ Called when the controller is stopped.
-