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.
-
target
The target object ID. -
arm
TheArm
value for the hand that will grasp the target object. -
angle
Continuously (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. -
axis
Continuously (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_hand
If True, the object rotates relative to the hand holding it. If False, the object rotates relative to the Replicant. Ignored ifangle
oraxis
is None. -
offset
Offset the object's position from the Replicant's hand by this distance. -
kinematic_objects
The IDs of each kinematic object. -
status
The current status of the action. By default, this isongoing
(the action isn't done). -
initialized
If True, the action has initialized. If False, the action will try to sendget_initialization_commands(resp)
on this frame. -
done
If True, this action is done and won't send any more commands.
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. |
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.
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.
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.