cozmo.behavior

Behaviors represent a task that Cozmo may perform for an indefinite amount of time.

For example, the “LookAroundInPlace” behavior causes Cozmo to start looking around him (without driving), which will cause events such as cozmo.objects.EvtObjectObserved to be generated as he comes across objects.

Behaviors must be explicitly stopped before having the robot do something else (for example, pick up the object he just observed).

Behaviors are started by a call to cozmo.robot.Robot.start_behavior(), which returns a Behavior object. Calling the stop() method on that object terminate the behavior.

The BehaviorTypes class in this module holds a list of all available behaviors.

Classes

Behavior(robot, behavior_type[, is_active]) A Behavior instance describes a behavior the robot is currently performing.
BehaviorTypes Defines all executable robot behaviors.
EvtBehaviorRequested(**kwargs) Triggered when a behavior is requested to start.
EvtBehaviorStarted(**kwargs) Triggered when a behavior starts running on the robot.
EvtBehaviorStopped(**kwargs) Triggered when a behavior stops.
cozmo.behavior.BEHAVIOR_IDLE = 'behavior_idle'

Behavior idle state (not requested to run)

Type:string
cozmo.behavior.BEHAVIOR_REQUESTED = 'behavior_requested'

Behavior requested state (waiting for engine to start it)

Type:string
cozmo.behavior.BEHAVIOR_RUNNING = 'behavior_running'

Behavior running state

Type:string
cozmo.behavior.BEHAVIOR_STOPPED = 'behavior_stopped'

Behavior stopped state

Type:string
class cozmo.behavior.EvtBehaviorRequested(**kwargs)

Triggered when a behavior is requested to start.

behavior = 'The Behavior object'
behavior_type_name = 'The behavior type name - equivalent to behavior.type.name'
class cozmo.behavior.EvtBehaviorStarted(**kwargs)

Triggered when a behavior starts running on the robot.

behavior = 'The Behavior object'
behavior_type_name = 'The behavior type name - equivalent to behavior.type.name'
class cozmo.behavior.EvtBehaviorStopped(**kwargs)

Triggered when a behavior stops.

behavior = 'The behavior type object'
behavior_type_name = 'The behavior type name - equivalent to behavior.type.name'
class cozmo.behavior.Behavior(robot, behavior_type, is_active=False, **kw)

A Behavior instance describes a behavior the robot is currently performing.

Returned by cozmo.robot.Robot.start_behavior().

is_active

True if the behavior is currently active and may run on the robot.

Type:bool
is_running

True if the behavior is currently running on the robot.

Type:bool
stop()

Requests that the robot stop performing the behavior.

Has no effect if the behavior is not presently active.

wait_for_completed(timeout=None)

Waits for the behavior to complete.

Parameters:timeout (int or None) – Maximum time in seconds to wait for the event. Pass None to wait indefinitely.
Raises:asyncio.TimeoutError
wait_for_started(timeout=5)

Waits for the behavior to start.

Parameters:timeout (int or None) – Maximum time in seconds to wait for the event. Pass None to wait indefinitely. If a behavior can run it should usually start within ~0.2 seconds.
Raises:asyncio.TimeoutError
class cozmo.behavior.BehaviorTypes

Defines all executable robot behaviors.

For use with cozmo.robot.Robot.start_behavior().

FindFaces = _BehaviorType(name='FindFaces', id=1)

Turn and move head, but don’t drive, with Cozmo’s head angled upwards where faces are likely to be.

KnockOverCubes = _BehaviorType(name='KnockOverCubes', id=4)

Knock over a stack of cubes.

LookAroundInPlace = _BehaviorType(name='LookAroundInPlace', id=6)

Turn and move head, but don’t drive, to see what is around Cozmo.

PounceOnMotion = _BehaviorType(name='PounceOnMotion', id=7)

Tries to “pounce” (drive forward and lower lift) when it detects nearby motion on the ground plane.

RollBlock = _BehaviorType(name='RollBlock', id=8)

Roll a block, regardless of orientation.

StackBlocks = _BehaviorType(name='StackBlocks', id=9)

Pickup one block, and stack it onto another block.

_EnrollFace = _BehaviorType(name='EnrollFace', id=0)