cozmo.action¶
Actions encapsulate specific high-level tasks that the Cozmo robot can perform. They have a definite beginning and end.
These tasks include picking up an object, rotating in place, saying text, etc.
Actions are usually triggered by a call to a method on the
cozmo.robot.Robot
class such as turn_in_place()
The call will return an object that subclasses Action
that can be
used to cancel the action, or be observed to wait or be notified when the
action completes (or fails) by calling its
wait_for()
or
add_event_handler()
methods.
Warning
Unless you pass in_parallel=True
when starting the action, no other
action can be active at the same time. Attempting to trigger a non-parallel
action when another action is already in progress will result in a
RobotBusy
exception being raised.
When using in_parallel=True
you may see an action fail with the result
ActionResults.TRACKS_LOCKED
- this indicates that another in-progress
action has already locked that movement track (e.g. two actions cannot
move the head at the same time).
Classes
Action (*, conn, robot, **kw) |
An action holds the state of an in-progress robot action |
ActionResults |
The possible result values for an Action. |
EvtActionCompleted (**kwargs) |
Triggered when a robot action has completed or failed. |
EvtActionStarted (**kwargs) |
Triggered when a robot starts an action. |
-
cozmo.action.
ACTION_IDLE
= 'action_idle'¶ Action idle state
Type: string
-
cozmo.action.
ACTION_RUNNING
= 'action_running'¶ Action running state
Type: string
-
cozmo.action.
ACTION_SUCCEEDED
= 'action_succeeded'¶ Action succeeded state
Type: string
-
cozmo.action.
ACTION_FAILED
= 'action_failed'¶ Action failed state
Type: string
-
cozmo.action.
ACTION_ABORTING
= 'action_aborting'¶ Action failed state
Type: string
-
class
cozmo.action.
EvtActionStarted
(**kwargs)¶ Triggered when a robot starts an action.
-
action
= 'The action that started'¶
-
-
class
cozmo.action.
EvtActionCompleted
(**kwargs)¶ Triggered when a robot action has completed or failed.
-
action
= 'The action that completed'¶
-
failure_code
= 'A failure code such as "cancelled"'¶
-
failure_reason
= 'A human-readable failure reason'¶
-
state
= 'The state of the action; either cozmo.action.ACTION_SUCCEEDED or cozmo.action.ACTION_FAILED'¶
-
-
class
cozmo.action.
Action
(*, conn, robot, **kw)¶ An action holds the state of an in-progress robot action
-
abort
(log_abort_messages=False)¶ Trigger the robot to abort the running action.
Parameters: log_abort_messages (bool) – True to log info on the action that is aborted. Raises: ValueError if the action is not currently being executed.
-
conn
= None¶ The connection on which the action was sent.
Type: CozmoConnection
-
failure_reason
¶ Both values will be None if no failure has occurred.
Type: tuple of (failure_code, failure_reason)
-
on_completed
(handler)¶ Triggers a handler when the action completes.
Parameters: handler (callable) – An event handler which accepts arguments suited to the EvtActionCompleted
event. Seecozmo.event.add_event_handler()
for more information.
-
result
¶ The result of running the action.
Type: An attribute of ActionResults
-
state
¶ The current internal state of the action as a string.
Will match one of the constants:
ACTION_IDLE
ACTION_RUNNING
ACTION_SUCCEEDED
ACTION_FAILED
ACTION_ABORTING
Type: string
-
wait_for_completed
(timeout=None)¶ Waits for the action to complete.
Parameters: timeout (int or None) – Maximum time in seconds to wait for the event. Pass None to wait indefinitely. Returns: The EvtActionCompleted
event instanceRaises: asyncio.TimeoutError
-
-
class
cozmo.action.
ActionResults
¶ The possible result values for an Action.
An Action’s result is set when the action completes.
-
ABORT
= _ActionResult(name='ABORT', id=50331648)¶ Action aborted itself (e.g. had invalid attributes, or a runtime failure).
-
ANIM_ABORTED
= _ActionResult(name='ANIM_ABORTED', id=50331649)¶ Animation Action aborted itself (e.g. there was an error playing the animation).
-
BAD_MARKER
= _ActionResult(name='BAD_MARKER', id=50331650)¶ There was an error related to vision markers.
-
BAD_OBJECT
= _ActionResult(name='BAD_OBJECT', id=50331652)¶ There was a problem with the Object ID provided (e.g. there is no Object with that ID).
-
BAD_POSE
= _ActionResult(name='BAD_POSE', id=50331653)¶ There was a problem with the Pose provided.
-
CANCELLED_WHILE_RUNNING
= _ActionResult(name='CANCELLED_WHILE_RUNNING', id=33554432)¶ Action was cancelled (e.g. via
abort_all_actions()
orAction.abort()
).
-
DID_NOT_REACH_PREACTION_POSE
= _ActionResult(name='DID_NOT_REACH_PREACTION_POSE', id=67108865)¶ Failed to get into position.
-
FAILED_TRAVERSING_PATH
= _ActionResult(name='FAILED_TRAVERSING_PATH', id=67108866)¶ Failed to follow the planned path.
-
FOLLOWING_PATH_BUT_NOT_TRAVERSING
= _ActionResult(name='FOLLOWING_PATH_BUT_NOT_TRAVERSING', id=50331656)¶ There was an error following the planned path.
-
INTERRUPTED
= _ActionResult(name='INTERRUPTED', id=50331657)¶ The action was interrupted by another Action or Behavior.
-
INVALID_OFF_TREADS_STATE
= _ActionResult(name='INVALID_OFF_TREADS_STATE', id=50331658)¶ The robot ended up in an “off treads state” not valid for this action (e.g. the robot was placed on its back while executing a turn)
-
LAST_PICK_AND_PLACE_FAILED
= _ActionResult(name='LAST_PICK_AND_PLACE_FAILED', id=67108867)¶ The previous attempt to pick and place an object failed.
-
MISMATCHED_UP_AXIS
= _ActionResult(name='MISMATCHED_UP_AXIS', id=50331659)¶ The Up Axis of a carried object doesn’t match the desired placement pose.
-
MOTOR_STOPPED_MAKING_PROGRESS
= _ActionResult(name='MOTOR_STOPPED_MAKING_PROGRESS', id=67108868)¶ The required motor isn’t moving so the action cannot complete.
-
NOT_CARRYING_OBJECT_ABORT
= _ActionResult(name='NOT_CARRYING_OBJECT_ABORT', id=50331665)¶ No object is being carried, but the action requires one.
-
NOT_CARRYING_OBJECT_RETRY
= _ActionResult(name='NOT_CARRYING_OBJECT_RETRY', id=67108869)¶ Not carrying an object when it was expected, but may succeed if the action is retried.
-
NOT_ON_CHARGER
= _ActionResult(name='NOT_ON_CHARGER', id=67108870)¶ Cozmo is expected to be on the charger, but is not.
-
NOT_STARTED
= _ActionResult(name='NOT_STARTED', id=33554433)¶ Initial state of an Action to indicate it has not yet started.
-
NO_ANIM_NAME
= _ActionResult(name='NO_ANIM_NAME', id=50331660)¶ No valid Animation name was found.
-
NO_DISTANCE_SET
= _ActionResult(name='NO_DISTANCE_SET', id=50331661)¶ An invalid distance value was given.
-
NO_FACE
= _ActionResult(name='NO_FACE', id=50331662)¶ There was a problem with the Face ID (e.g. Cozmo doesn’t no where it is).
-
NO_GOAL_SET
= _ActionResult(name='NO_GOAL_SET', id=50331663)¶ No goal pose was set.
-
NO_PREACTION_POSES
= _ActionResult(name='NO_PREACTION_POSES', id=50331664)¶ No pre-action poses were found (e.g. could not get into position).
-
NULL_SUBACTION
= _ActionResult(name='NULL_SUBACTION', id=50331666)¶ No sub-action was provided.
-
PATH_PLANNING_FAILED_ABORT
= _ActionResult(name='PATH_PLANNING_FAILED_ABORT', id=50331667)¶ Cozmo was unable to plan a path.
-
PATH_PLANNING_FAILED_RETRY
= _ActionResult(name='PATH_PLANNING_FAILED_RETRY', id=67108871)¶ Cozmo was unable to plan a path, but may succeed if the action is retried.
-
PICKUP_OBJECT_UNEXPECTEDLY_MOVING
= _ActionResult(name='PICKUP_OBJECT_UNEXPECTEDLY_MOVING', id=50331668)¶ The object that Cozmo is attempting to pickup is unexpectedly moving (e.g it is being moved by someone else).
-
PICKUP_OBJECT_UNEXPECTEDLY_NOT_MOVING
= _ActionResult(name='PICKUP_OBJECT_UNEXPECTEDLY_NOT_MOVING', id=50331669)¶ The object that Cozmo thought he was lifting didn’t start moving, so he must have missed.
-
PLACEMENT_GOAL_NOT_FREE
= _ActionResult(name='PLACEMENT_GOAL_NOT_FREE', id=67108872)¶ There is no room to place the object at the desired destination.
-
RETRY
= _ActionResult(name='RETRY', id=67108864)¶ The Action failed, but may succeed if retried.
-
RUNNING
= _ActionResult(name='RUNNING', id=16777216)¶ Action is still running.
-
STILL_CARRYING_OBJECT
= _ActionResult(name='STILL_CARRYING_OBJECT', id=50331671)¶ Cozmo is unexpectedly still carrying an object.
-
STILL_ON_CHARGER
= _ActionResult(name='STILL_ON_CHARGER', id=67108873)¶ Cozmo failed to drive off the charger.
-
SUCCESS
= _ActionResult(name='SUCCESS', id=0)¶ Action completed successfully.
-
TIMEOUT
= _ActionResult(name='TIMEOUT', id=50331672)¶ The Action timed out before completing correctly.
-
TRACKS_LOCKED
= _ActionResult(name='TRACKS_LOCKED', id=50331673)¶ One or more animation tracks (Head, Lift, Body, Face, Backpack Lights, Audio) are already being used by another Action.
-
UNEXPECTED_DOCK_ACTION
= _ActionResult(name='UNEXPECTED_DOCK_ACTION', id=50331674)¶ There was an internal error related to an unexpected type of dock action.
-
UNEXPECTED_PITCH_ANGLE
= _ActionResult(name='UNEXPECTED_PITCH_ANGLE', id=67108874)¶ Cozmo’s pitch is at an unexpected angle for the Action.
-
VISUAL_OBSERVATION_FAILED
= _ActionResult(name='VISUAL_OBSERVATION_FAILED', id=50331677)¶ Cozmo did not see the expected result (e.g. unable to see cubes in their expected position after a related action).
-