soar.robot.base¶
Soar BaseRobot class, intended as a parent class for nontrivial/useful robots.
All robots usable in Soar should either subclass from BaseRobot or, if this is not possible, reproduce its behaviors.
-
class
soar.robot.base.
BaseRobot
(polygon, **options)¶ Bases:
soar.sim.world.WorldObject
-
collision
(other, eps=1e-08)¶ Determine whether the robot collides with an object.
Supported objects include other robots, and subclasses of
soar.sim.world.Polygon
andsoar.sim.world.Wall
.Parameters: - other – A supported
WorldObject
subclass with which this object could potentially collide. - eps (float, optional) – The epsilon within which to consider a collision to have occurred, different for each subclass.
Returns: A list of
(x, y)
tuples consisting of all the collision points withother
, orNone
if there weren’t any.Return type: list
- other – A supported
-
delete
(canvas)¶ Delete the robot from a canvas.
Parameters: canvas – An instance of soar.gui.canvas.SoarCanvas
.
-
draw
(canvas)¶ Draw the robot on a canvas.
Canvas items are preserved. If drawn more than once on the same canvas, the item will be moved and not redrawn.
Parameters: canvas – An instance of soar.gui.canvas.SoarCanvas
.
-
move
(pose)¶ Move the robot to the specified
(x, y, theta)
pose.Parameters: pose – An soar.sim.geometry.Pose
or 3-tuple-like object to move the robot to.
-
on_load
()¶ Called when the controller of the robot is loaded.
The behavior of this method should differ depending on the value of
simulated
; if it isFalse
, this method should be used to connect with the real robot. If a connection error occurs, asoar.errors.SoarIOError
should be raised to notify the client that the error was not due to other causes.
-
on_pause
()¶ Called when the controller is paused.
-
on_shutdown
()¶ Called when the controller of the robot is shutdown.
If interacting with a real robot, the connection should be safely closed and reset for any later connections.
-
on_start
()¶ Called when the controller of the robot is started.
This method will always be called by the controller at most once per controller session, before the first step.
-
on_step
(step_duration)¶ Called when the controller of the robot undergoes a single step of a specified duration.
For BaseRobot, this tries to perform an integrated position update based on the forward and rotational velocities. If the robot cannot move to the new position because there is an object in its way, it will be moved to a safe space just before it would have collided.
Subclasses will typically have more complex
on_step()
methods, usually with behavior for stepping non-simulated robots.Parameters: step_duration (float) – The duration of the step, in seconds.
-
on_stop
()¶ Called when the controller of the robot is stopped.
-
pos
¶
-
set_robot_options
(**options)¶ Set one or many keyworded, robot-specific options. Document these options here.
Parameters: **options – BaseRobot
does not support any robot options.
-
to_dict
()¶ Return a dictionary representation of the robot, usable for serialization.
-
type
= 'BaseRobot'¶ A base robot class, intended to be subclassed and overridden.
Any robot usable in SoaR should supplement or re-implement this class’ methods with the desired behavior.
-
type
str – A human readable name for robots of this type.
-
world
¶ The instance of
soar.sim.world.World
(or a subclass) in which the robot resides, orNone
, if the robot is real.
-
simulated
¶ bool – Any BaseRobot subclass should consider the robot to be simulated if this is
True
, and real otherwise. By default, it isFalse
.
-
pose
¶ An instance of
soar.sim.geometry.Pose
representing the robot’s(x, y, theta)
position. In simulation, this is the actual position; on a real robot this may be determined through other means.
-
polygon
¶ A
soar.sim.world.Polygon
that defines the boundaries of the robot and is used for collision.
-
fv
¶ float – The robot’s current translational velocity, in arbitrary units. Positive values indicate movement towards the front of the robot, and negative values indicate movement towards the back.
-
rv
¶ float – The robot’s current rotational velocity, in radians/second. Positive values indicate counterclockwise rotation (when viewed from above), and negative values indicate clockwise rotation.
Parameters: - polygon – A
soar.sim.world.Polygon
that defines the boundaries of the robot and is used for collision. - **options – Arbitrary keyword arguments. This may include Tkinter keywords passed to the
WorldObject
constructor, or robot options supported as arguments toset_robot_options
.
-
-