Grasp
December 21, 2023 ยท View on GitHub
from tdw.replicant.actions.grasp import Grasp
Grasp a target object.
The action fails if the hand is already holding an object. Otherwise, the action succeeds.
When an object is grasped, it is made kinematic. Any objects contained by the object are parented to it and also made kinematic. For more information regarding containment in TDW, read this.
Fields
-
targetThe target object ID. -
armTheArmvalue for the hand that will grasp the target object. -
angleContinuously (percommunicate()call, including after this action ends), rotate the grasped object by this many degrees. If None, the grasped object will maintain its initial rotation. -
axisContinuously (percommunicate()call, including after this action ends), rotate the grasped object around this axis. Options:"pitch","yaw","roll". If None, the grasped object will maintain its initial rotation. -
relative_to_handIf True, the object rotates relative to the hand holding it. If False, the object rotates relative to the Replicant. Ignored ifangleoraxisis None. -
offsetOffset the object's position from the Replicant's hand by this distance. -
kinematic_objectsThe IDs of each kinematic object. -
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__
Grasp(target, arm, dynamic, angle, axis, relative_to_hand, offset, kinematic_objects)
| Parameter | Type | Default | Description |
|---|---|---|---|
| target | int | The target object ID. | |
| arm | Arm | The Arm value for the hand that will grasp the target object. | |
| dynamic | ReplicantDynamic | The ReplicantDynamic data that changes per communicate() call. | |
| angle | Optional[float] | Continuously (per communicate() call, including after this action ends), rotate the the grasped object by this many degrees relative to the hand. If None, the grasped object will maintain its initial rotation. | |
| axis | Optional[str] | Continuously (per communicate() call, including after this action ends) rotate the grasped object around this axis relative to the hand. Options: "pitch", "yaw", "roll". If None, the grasped object will maintain its initial rotation. | |
| relative_to_hand | bool | If True, the object rotates relative to the hand holding it. If False, the object rotates relative to the Replicant. Ignored if angle or axis is None. | |
| offset | float | Offset the object's position from the Replicant's hand by this distance. | |
| kinematic_objects | List[int] | The IDs of each kinematic object. |
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.