MoveTo
September 1, 2023 ยท View on GitHub
from tdw.replicant.actions.move_to import MoveTo
Turn the Replicant to a target position or object and then walk to it.
While walking, the Replicant will continuously play a walk cycle animation until the action ends.
The action can end for several reasons depending on the collision detection rules (see self.collision_detection.
- If the Replicant walks the target distance (i.e. it reaches its target), the action succeeds.
- If
self.collision_detection.previous_was_same == True, and the previous action wasMoveByorMoveTo, and it was in the same direction (forwards/backwards), and the previous action ended in failure, this action ends immediately. - If
self.collision_detection.avoid_obstacles == Trueand the Replicant encounters a wall or object in its path:- If the object is in
self.collision_detection.exclude_objects, the Replicant ignores it. - Otherwise, the action ends in failure.
- If the object is in
- If the Replicant collides with an object or a wall and
self.collision_detection.objects == Trueand/orself.collision_detection.walls == Truerespectively:- If the object is in
self.collision_detection.exclude_objects, the Replicant ignores it. - Otherwise, the action ends in failure.
- If the object is in
Fields
-
targetThe target. If int: An object ID. If dict: A position as an x, y, z dictionary. If numpy array: A position as an [x, y, z] numpy array. -
collision_detectionTheCollisionDetectionrules. -
reset_armsIf True, reset the arms to their neutral positions while beginning the walk cycle. -
reset_arms_durationThe speed at which the arms are reset in seconds. -
scale_reset_arms_durationIf True,reset_arms_durationwill be multiplied byframerate / 60), ensuring smoother motions at faster-than-life simulation speeds. -
arrived_atIf at any point during the action the difference between the target distance and distance traversed is less than this, then the action is successful. -
bounds_positionIftargetis an integer object ID, move towards this bounds point of the object. Options:"center","top","bottom","left","right","front","back". -
animationThe name of the walk animation. -
libraryThe name of the walk animation's library. -
collision_avoidance_distanceIfcollision_detection.avoid == True, an overlap will be cast at this distance from the Wheelchair Replicant to detect obstacles. -
collision_avoidance_half_extentsIfcollision_detection.avoid == True, an overlap will be cast with these half extents to detect obstacles. -
collision_avoidance_yThe y coordinate of the collision detection overlap shape. -
statusThe current status of the action. By default, this isongoing(the action isn't done). -
initializedIf True, the action has initialized. If False, the action will try to sendget_initialization_commands(resp)on this frame. -
doneIf True, this action is done and won't send any more commands.
Functions
__init__
MoveTo(target, collision_detection, previous, reset_arms, reset_arms_duration, arrived_at, bounds_position, collision_avoidance_distance, collision_avoidance_half_extents, collision_avoidance_y)
MoveTo(target, collision_detection, previous, reset_arms, reset_arms_duration, arrived_at, bounds_position, collision_avoidance_distance, collision_avoidance_half_extents, collision_avoidance_y, animation="walking_2", library="humanoid_animations.json")
| Parameter | Type | Default | Description |
|---|---|---|---|
| target | TARGET | The target. If int: An object ID. If dict: A position as an x, y, z dictionary. If numpy array: A position as an [x, y, z] numpy array. | |
| collision_detection | CollisionDetection | The CollisionDetection rules. | |
| previous | Optional[Action] | The previous action, if any. | |
| reset_arms | bool | If True, reset the arms to their neutral positions while beginning the walk cycle. | |
| reset_arms_duration | float | The speed at which the arms are reset in seconds. | |
| arrived_at | float | If at any point during the action the difference between the target distance and distance traversed is less than this, then the action is successful. | |
| bounds_position | str | If target is an integer object ID, move towards this bounds point of the object. Options: "center", "top", "bottom", "left", "right", "front", "back". | |
| collision_avoidance_distance | float | If collision_detection.avoid == True, an overlap will be cast at this distance from the Wheelchair Replicant to detect obstacles. | |
| collision_avoidance_half_extents | Dict[str, float] | If collision_detection.avoid == True, an overlap will be cast with these half extents to detect obstacles. | |
| collision_avoidance_y | float | The y coordinate of the collision detection overlap shape. | |
| animation | str | "walking_2" | The name of the walk animation. |
| library | str | "humanoid_animations.json" | The name of the walk animation's library. |
get_initialization_commands
self.get_initialization_commands(resp, static, dynamic, image_frequency)
| Parameter | Type | Default | Description |
|---|---|---|---|
| resp | List[bytes] | The response from the build. | |
| static | ReplicantStatic | The ReplicantStatic data that doesn't change after the Replicant is initialized. | |
| dynamic | ReplicantDynamic | The ReplicantDynamic data that changes per communicate() call. | |
| image_frequency | ImageFrequency | An ImageFrequency value describing how often image data will be captured. |
Returns: A list of commands to initialize this action.
get_ongoing_commands
self.get_ongoing_commands(resp, static, dynamic)
Evaluate an action per-frame to determine whether it's done.
| Parameter | Type | Default | Description |
|---|---|---|---|
| resp | List[bytes] | The response from the build. | |
| static | ReplicantStatic | The ReplicantStatic data that doesn't change after the Replicant is initialized. | |
| dynamic | ReplicantDynamic | The ReplicantDynamic data that changes per communicate() call. |
Returns: A list of commands to send to the build to continue the action.
get_end_commands
self.get_end_commands(resp, static, dynamic, image_frequency)
| Parameter | Type | Default | Description |
|---|---|---|---|
| resp | List[bytes] | The response from the build. | |
| static | ReplicantStatic | The ReplicantStatic data that doesn't change after the Replicant is initialized. | |
| dynamic | ReplicantDynamic | The ReplicantDynamic data that changes per communicate() call. | |
| image_frequency | ImageFrequency | An ImageFrequency value describing how often image data will be captured. |
Returns: A list of commands that must be sent to end any action.