Class BehaviorComponent
Behavior related classes and functions.
Behaviors represent a complex task which requires Vector’s internal logic to determine how long it will take.This may include combinations of animation, path planning or other functionality.
For commands such as GoToPose(Pose, Boolean, Int32), DriveOnCharger() and DockWithCube(LightCube, Nullable<Single>, AlignmentType, Single, Int32), Vector uses path planning, which refers to the problem of navigating the robot from point A to B without collisions. Vector loads known obstacles from his map, creates a path to navigate around those objects, then starts following the path. If a new obstacle is found while following the path, a new plan may be created.
Implements
Inherited Members
Namespace: Anki.Vector
Assembly: Anki.Vector.dll
Syntax
public class BehaviorComponent : Component, INotifyPropertyChanged
Fields
| Improve this Doc View SourceMaxHeadAngle
The maximum head angle in radians
public const float MaxHeadAngle = 45F
Field Type
Single |
MinHeadAngle
The minimum head angle in radians
public const float MinHeadAngle = -22F
Field Type
Single |
Properties
| Improve this Doc View SourceIsBusy
Gets a value indicating whether Vector is busy performing a behavior.
public bool IsBusy { get; }
Property Type
Boolean |
MotionProfile
Gets the motion profile that tells Vector how to drive when receiving navigation and movement actions such as GoToPose(Pose, Boolean, Int32) and DockWithCube(LightCube, Nullable<Single>, AlignmentType, Single, Int32).
public MotionProfile MotionProfile { get; }
Property Type
MotionProfile |
Methods
| Improve this Doc View SourceAppIntent(String, String)
Submit an intent for Vector to carry out.
public Task<StatusCode> AppIntent(string intent, string param = "")
Parameters
Type | Name | Description |
---|---|---|
String | intent | The intent for Vector carry out. |
String | param | Any extra parameters. |
Returns
Type | Description |
---|---|
Task<StatusCode> | A task that represents the asynchronous operation. |
Remarks
Since AppIntents are run by Vector's AI; this method will automatically release control.
Cancel()
Cancel the currently active behavior
public Task<StatusCode> Cancel()
Returns
Type | Description |
---|---|
Task<StatusCode> | A task that represents the asynchronous operation. |
DockWithCube(LightCube, Nullable<Single>, AlignmentType, Single, Int32)
Tells Vector to dock with a light cube, optionally using a given approach angle and distance.
While docking with the cube, Vector will use path planning.
public Task<ActionResult> DockWithCube(LightCube lightCube, float? approachAngle = default(float? ), AlignmentType alignment = AlignmentType.LiftPlate, float distanceFromMarker = 0F, int numRetries = 0)
Parameters
Type | Name | Description |
---|---|---|
LightCube | lightCube | The light cube. |
Nullable<Single> | approachAngle | The approach angle in radians. |
AlignmentType | alignment | Which part of the robot to align with the object. |
Single | distanceFromMarker | The distance from marker in mm (0 to dock). |
Int32 | numRetries | Number of times to re-attempt action in case of a failure. |
Returns
Type | Description |
---|---|
Task<ActionResult> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
Requires behavior control; see RequestControl(Int32).
DriveOffCharger()
Drive Vector off the charger
public Task<BehaviorResult> DriveOffCharger()
Returns
Type | Description |
---|---|
Task<BehaviorResult> | A task that represents the asynchronous operation. |
Remarks
Requires behavior control; see RequestControl(Int32).
DriveOnCharger()
Drive Vector onto the charger
Vector will attempt to find the charger and, if successful, he will back onto it and start charging. Vector’s charger has a visual marker so that the robot can locate it for self-docking.
public Task<BehaviorResult> DriveOnCharger()
Returns
Type | Description |
---|---|
Task<BehaviorResult> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
Requires behavior control; see RequestControl(Int32).
DriveStraight(Single, Single, Boolean, Int32)
Tells Vector to drive in a straight line. Vector will drive for the specified distance(forwards or backwards). Vector must be off of the charger for this movement action.
public Task<ActionResult> DriveStraight(float distanceMm, float speedMmps, bool shouldPlayAnimation = true, int numRetries = 0)
Parameters
Type | Name | Description |
---|---|---|
Single | distanceMm | The distance in mm. (positive for forwards, negative for backwards) |
Single | speedMmps | The speed mm/s. |
Boolean | shouldPlayAnimation | Whether to play idle animations whilst driving |
Int32 | numRetries | Number of times to re-attempt action in case of a failure |
Returns
Type | Description |
---|---|
Task<ActionResult> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
Requires behavior control; see RequestControl(Int32).
Exceptions
Type | Condition |
---|---|
NotSupportedException | The action result is not supported |
FindCube()
Requests that Vector finds his cube.
public Task<StatusCode> FindCube()
Returns
Type | Description |
---|---|
Task<StatusCode> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
This method will automatically release control.
FindFaces()
Look around for faces
Turn in place and move head to look for faces.
public Task<BehaviorResult> FindFaces()
Returns
Type | Description |
---|---|
Task<BehaviorResult> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
Requires behavior control; see RequestControl(Int32).
GoToCube(Single, Int32)
Tells Vector to drive to his Cube.
public Task<ActionResult> GoToCube(float distanceFromCube, int numRetries = 0)
Parameters
Type | Name | Description |
---|---|---|
Single | distanceFromCube | The distance from the cube to stop in mm. This is the distance between the origins. For instance, the distance from the robot's origin (between Vector's two front wheels) to the cube's origin (at the center of the cube) is ~40mm. |
Int32 | numRetries | Number of times to reattempt action in case of a failure. |
Returns
Type | Description |
---|---|
Task<ActionResult> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
Requires behavior control; see RequestControl(Int32).
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Light Cube must have been seen by Vector to run this command. |
GoToPose(Pose, Boolean, Int32)
Tells Vector to drive to the specified pose and orientation.
In navigating to the requested pose, Vector will use path planning.
public Task<ActionResult> GoToPose(Pose pose, bool relativeToRobot = false, int retries = 0)
Parameters
Type | Name | Description |
---|---|---|
Pose | pose | The pose. |
Boolean | relativeToRobot | Whether the given pose is relative to the robot's pose. |
Int32 | retries | The retries. |
Returns
Type | Description |
---|---|
Task<ActionResult> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
Requires behavior control; see RequestControl(Int32).
ListenForBeat()
Request that Vector listens for a beat.
public Task<StatusCode> ListenForBeat()
Returns
Type | Description |
---|---|
Task<StatusCode> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
This method will automatically release control.
ListenForQuestion()
Requests that Vector listen for a knowledge question and provide response.
public Task<StatusCode> ListenForQuestion()
Returns
Type | Description |
---|---|
Task<StatusCode> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
This method will automatically release control.
LookAroundInPlace()
Look around in place
Turn in place and move head to see what's around Vector.
public Task<BehaviorResult> LookAroundInPlace()
Returns
Type | Description |
---|---|
Task<BehaviorResult> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
Requires behavior control; see RequestControl(Int32).
PickupObject(LightCube, Boolean, Int32)
Instruct the robot to pick up his LightCube.
While picking up the cube, Vector will use path planning.
Note that actions that use the wheels cannot be performed at the same time, otherwise you may see a TRACKS_LOCKED error.
public Task<ActionResult> PickupObject(LightCube lightCube, bool usePreDockPose = true, int numRetries = 0)
Parameters
Type | Name | Description |
---|---|---|
LightCube | lightCube | The light cube. |
Boolean | usePreDockPose | Whether or not to try to immediately pick up an object or first position the robot next to the object. |
Int32 | numRetries | Number of times to reattempt action in case of a failure. |
Returns
Type | Description |
---|---|
Task<ActionResult> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
Requires behavior control; see RequestControl(Int32).
Exceptions
Type | Condition |
---|---|
ArgumentException | Light cube object must be provided. - lightCube |
PlaceObjectOnGroundHere(Int32)
Ask Vector to place the object he is carrying on the ground at the current location.
public Task<ActionResult> PlaceObjectOnGroundHere(int numRetries = 0)
Parameters
Type | Name | Description |
---|---|---|
Int32 | numRetries | Number of times to reattempt action in case of a failure. |
Returns
Type | Description |
---|---|
Task<ActionResult> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
Requires behavior control; see RequestControl(Int32).
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Light Cube must have been seen by Vector to run this command. |
PopAWheelie(Nullable<Single>, Int32)
Tells Vector to "pop a wheelie" using his light cube.
public Task<ActionResult> PopAWheelie(float? approachAngle = default(float? ), int numRetries = 0)
Parameters
Type | Name | Description |
---|---|---|
Nullable<Single> | approachAngle | The angle to approach the cube from in radians. For example, 180 degrees will cause Vector to drive past the cube and approach it from behind. |
Int32 | numRetries | Number of times to reattempt action in case of a failure. |
Returns
Type | Description |
---|---|
Task<ActionResult> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
Requires behavior control; see RequestControl(Int32).
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Light Cube must have been seen by Vector to run this command. |
RollCube(Nullable<Single>, Int32)
Tells Vector to roll a specified cube object.
public Task<ActionResult> RollCube(float? approachAngle = default(float? ), int numRetries = 0)
Parameters
Type | Name | Description |
---|---|---|
Nullable<Single> | approachAngle | The angle to approach the cube from in radians. For example, 180 degrees will cause Vector to drive past the cube and approach it from behind. |
Int32 | numRetries | Number of times to reattempt action in case of a failure. |
Returns
Type | Description |
---|---|
Task<ActionResult> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
Requires behavior control; see RequestControl(Int32).
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Light Cube must have been seen by Vector to run this command. |
RollVisibleCube()
Roll a cube that is currently known to the robot.
This behavior will move into position as necessary based on relative distance and orientation. Vector needs to see the block for this to succeed.
public Task<BehaviorResult> RollVisibleCube()
Returns
Type | Description |
---|---|
Task<BehaviorResult> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
Requires behavior control; see RequestControl(Int32).
SayName()
Request that Vector looks for a face and say the associated name.
public Task<StatusCode> SayName()
Returns
Type | Description |
---|---|
Task<StatusCode> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
This method will automatically release control.
SayText(String, Boolean, Single, Single)
Make Vector speak text.
public Task<StatusCode> SayText(string text, bool useVectorVoice = true, float duration = 1F, float pitch = 0F)
Parameters
Type | Name | Description |
---|---|---|
String | text | The words for Vector to say. |
Boolean | useVectorVoice | Whether to use Vector’s robot voice (otherwise, he uses a generic human male voice). |
Single | duration | Adjust the relative duration of the generated text to speech audio; 0.05 (fast) to 20.0 (slow). |
Single | pitch | Adjust the relative pitch of the generated text to speech audio; -1.0 (low) to +1.0 (high) |
Returns
Type | Description |
---|---|
Task<StatusCode> | A task that represents the asynchronous operation. |
Remarks
Requires behavior control; see RequestControl(Int32).
SetEyeColor(Single, Single)
Set Vector’s eye color.
public Task<StatusCode> SetEyeColor(float hue, float saturation)
Parameters
Type | Name | Description |
---|---|---|
Single | hue | The hue. |
Single | saturation | The saturation. |
Returns
Type | Description |
---|---|
Task<StatusCode> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
SetHeadAngle(Single, Single, Single, Single, Int32)
Tell Vector's head to move to a given angle.
public Task<ActionResult> SetHeadAngle(float angle, float acceleration = 10F, float maxSpeed = 10F, float duration = 0F, int numRetries = 0)
Parameters
Type | Name | Description |
---|---|---|
Single | angle | Desired angle for Vector’s head. Clamped to MinHeadAngle and MaxHeadAngle. |
Single | acceleration | Acceleration of Vector’s head in radians per second squared. |
Single | maxSpeed | Maximum speed of Vector’s head in radians per second. |
Single | duration | Time for Vector’s head to move in seconds. A value of zero will make Vector try to do it as quickly as possible. |
Int32 | numRetries | Number of times to re-attempt the action in case of a failure. |
Returns
Type | Description |
---|---|
Task<ActionResult> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
Requires behavior control; see RequestControl(Int32).
SetLiftHeight(Single, Single, Single, Single, Int32)
Tell Vector’s lift to move to a given height.
public Task<ActionResult> SetLiftHeight(float height, float acceleration = 10F, float maxSpeed = 10F, float duration = 0F, int numRetries = 0)
Parameters
Type | Name | Description |
---|---|---|
Single | height | Desired height for Vector’s lift clamped to 0.0 (bottom) to 1.0 (top). |
Single | acceleration | Acceleration of Vector’s lift in radians per second squared. |
Single | maxSpeed | Maximum speed of Vector’s lift in radians per second. |
Single | duration | Time for Vector’s lift to move in seconds. A value of zero will make Vector try to do it as quickly as possible. |
Int32 | numRetries | Number of times to re-attempt the action in case of a failure. |
Returns
Type | Description |
---|---|
Task<ActionResult> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
Requires behavior control; see RequestControl(Int32).
Sleep()
Requests that Vector goes to sleep
public Task<StatusCode> Sleep()
Returns
Type | Description |
---|---|
Task<StatusCode> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
This method will automatically release control.
StartExploring()
Request that Vector start's exploring. Vector reacts but doesn't seem to actually start exploring with this method.
public Task<StatusCode> StartExploring()
Returns
Type | Description |
---|---|
Task<StatusCode> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
This method will automatically release control.
TurnInPlace(Single, Single, Single, Single, Boolean, Int32)
Turn the robot around its current position.
Vector must be off of the charger for this movement action.
public Task<ActionResult> TurnInPlace(float angle, float speed = 0F, float acceleration = 0F, float angleTolerance = 0F, bool isAbsolute = false, int numRetries = 0)
Parameters
Type | Name | Description |
---|---|---|
Single | angle | The angle to turn. Positive values turn to the left, negative values to the right. |
Single | speed | Angular turn speed (per second). |
Single | acceleration | Acceleration of angular turn (per second squared). |
Single | angleTolerance | angular tolerance to consider the action complete (this is clamped to a minimum of 2 degrees internally). |
Boolean | isAbsolute | True to turn to a specific angle, False to turn relative to the current pose. |
Int32 | numRetries | Number of times to re-attempt the turn in case of a failure. |
Returns
Type | Description |
---|---|
Task<ActionResult> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
Requires behavior control; see RequestControl(Int32).
TurnTowardsFace(Face, Int32)
Tells Vector to turn towards this face.
public Task<ActionResult> TurnTowardsFace(Face face, int numRetries = 0)
Parameters
Type | Name | Description |
---|---|---|
Face | face | The face Vector will turn towards. |
Int32 | numRetries | Number of times to reattempt the action in case of a failure. |
Returns
Type | Description |
---|---|
Task<ActionResult> | A task that represents the asynchronous operation; the task result contains the result from the robot. |
Remarks
Requires behavior control; see RequestControl(Int32).