-
Notifications
You must be signed in to change notification settings - Fork 0
add a wiping skill #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chsahit
wants to merge
6
commits into
main
Choose a base branch
from
wiping_skill
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8aed6b6
add a wiping skill
chsahit 16b9e59
added wipe skill parameterized by the bounding box coordinates of the…
skymanaditya1 b974e2c
updates to the wipe online tool. Added function call to the exec_plan…
skymanaditya1 725d2aa
making wipe skill more robust + logging things in rerun
skymanaditya1 a789054
added visualization of the corners of the wipe surface, wiping surfac…
skymanaditya1 12729e8
increase percentage bounding box if required
skymanaditya1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| """Interface for spot sweeping skill.""" | ||
|
|
||
| import argparse | ||
| import time | ||
| from typing import Tuple | ||
|
|
||
| import numpy as np | ||
| from bosdyn.client import math_helpers | ||
| from bosdyn.client.sdk import Robot | ||
|
|
||
| from skills.spot_hand_move import ( | ||
| close_gripper, | ||
| move_hand_to_relative_pose, | ||
| move_hand_to_relative_pose_with_velocity, | ||
| open_gripper, | ||
| ) | ||
|
|
||
|
|
||
| def wipe_one_stroke( | ||
| robot: Robot, | ||
| wipe_start_pose: math_helpers.SE3Pose, | ||
| move_dx: float, | ||
| move_dy: float, | ||
| duration: float, | ||
| ) -> None: | ||
| """Wipe a table surface in the xy plane. | ||
|
|
||
| The robot starts at a start pose, and then moves forward and back by | ||
| dx and dy. | ||
| """ | ||
| # Move first in the yz direction (perpendicular to robot body) to avoid | ||
| # knocking the target object over. | ||
| move_hand_to_relative_pose(robot, wipe_start_pose) | ||
| first_move_pose = math_helpers.SE3Pose( | ||
| x=wipe_start_pose.x + move_dx, # sensible default | ||
| y=wipe_start_pose.y + move_dy, | ||
| z=wipe_start_pose.z, | ||
| rot=wipe_start_pose.rot, | ||
| ) | ||
| move_hand_to_relative_pose_with_velocity( | ||
| robot, wipe_start_pose, first_move_pose, duration | ||
| ) | ||
| time.sleep(0.1) | ||
| # Move back to the start pose. | ||
| move_hand_to_relative_pose_with_velocity( | ||
| robot, first_move_pose, wipe_start_pose, duration | ||
| ) | ||
|
|
||
|
|
||
| def wipe_multiple_strokes( | ||
| robot: Robot, | ||
| wipe_start_pose: math_helpers.SE3Pose, | ||
| end_look_pose: math_helpers.SE3Pose, | ||
| stroke_dx: float, | ||
| stroke_dy: float, | ||
| delta_x_y_between_strokes: Tuple[float, float], | ||
| num_strokes: int, | ||
| duration_per_stroke: float, | ||
| num_attempts_per_stroke: int, | ||
| ) -> None: | ||
| """Wipe a table surface in the xy plane. | ||
|
|
||
| The robot starts at a start pose, and then moves forward and back by | ||
| dx and dy. | ||
| """ | ||
| curr_stroke_start_pose = wipe_start_pose | ||
| for i in range(num_strokes): | ||
| for i in range(num_attempts_per_stroke): | ||
| move_hand_to_relative_pose(robot, curr_stroke_start_pose) | ||
| first_move_pose = math_helpers.SE3Pose( | ||
| x=curr_stroke_start_pose.x + stroke_dx, | ||
| y=curr_stroke_start_pose.y + stroke_dy, | ||
| z=curr_stroke_start_pose.z, | ||
| rot=curr_stroke_start_pose.rot, | ||
| ) | ||
| move_hand_to_relative_pose_with_velocity( | ||
| robot, curr_stroke_start_pose, first_move_pose, duration_per_stroke | ||
| ) | ||
| time.sleep(0.1) | ||
| # Move back to the start pose. | ||
| move_hand_to_relative_pose_with_velocity( | ||
| robot, first_move_pose, curr_stroke_start_pose, duration_per_stroke | ||
| ) | ||
| # Move to the next stroke position. | ||
| curr_stroke_start_pose = math_helpers.SE3Pose( | ||
| x=curr_stroke_start_pose.x + delta_x_y_between_strokes[0], | ||
| y=curr_stroke_start_pose.y + delta_x_y_between_strokes[1], | ||
| z=curr_stroke_start_pose.z, | ||
| rot=curr_stroke_start_pose.rot, | ||
| ) | ||
| # Move to the end look pose. | ||
| move_hand_to_relative_pose(robot, end_look_pose) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| # Run this file alone to test manually. | ||
| # Make sure to pass in --spot_robot_ip. | ||
|
|
||
| # the robot opens its gripper and pauses | ||
| # until a brush is put in the gripper, with the bristles facing down and | ||
| # forward. The robot should then brush to the right. | ||
|
|
||
| # pylint: disable=ungrouped-imports | ||
| from bosdyn.client import create_standard_sdk | ||
| from bosdyn.client.lease import LeaseClient | ||
| from bosdyn.client.util import authenticate | ||
|
|
||
| from spot_utils.utils import verify_estop | ||
|
|
||
| def _run_manual_test() -> None: | ||
| # Put inside a function to avoid variable scoping issues. | ||
| parser = argparse.ArgumentParser(description="Parse the robot's hostname.") | ||
| parser.add_argument( | ||
| "--hostname", | ||
| type=str, | ||
| required=True, | ||
| help="The robot's hostname/ip-address (e.g. 192.168.80.3)", | ||
| ) | ||
| args = parser.parse_args() | ||
|
|
||
| # Get constants. | ||
| hostname = args.hostname | ||
|
|
||
| sdk = create_standard_sdk("WipeSkillTestClient") | ||
| robot = sdk.create_robot(hostname) | ||
| authenticate(robot) | ||
| verify_estop(robot) | ||
| lease_client = robot.ensure_client(LeaseClient.default_service_name) | ||
| lease_client.take() | ||
| robot.time_sync.wait_for_sync() | ||
|
|
||
| # Move the hand to the side. | ||
| hand_side_pose = math_helpers.SE3Pose( | ||
| x=0.80, y=0.0, z=0.25, rot=math_helpers.Quat.from_yaw(-np.pi / 2) | ||
| ) | ||
| move_hand_to_relative_pose(robot, hand_side_pose) | ||
| # Ask for the eraser. | ||
| open_gripper(robot) | ||
| msg = "Put the brush in the robot's gripper, then press enter" | ||
| input(msg) | ||
| close_gripper(robot) | ||
|
|
||
| # NOTE: these parameters hardcoded for a particular child_play_table | ||
| # object njk is experimenting with. Please swap out depending on the | ||
| # actual object you have | ||
| start_pose = math_helpers.SE3Pose( | ||
| x=0.85, y=-0.2, z=-0.08, rot=math_helpers.Quat.from_pitch(np.pi / 2) | ||
| ) | ||
| end_pose = math_helpers.SE3Pose( | ||
| x=0.65, y=0.0, z=0.4, rot=math_helpers.Quat.from_pitch(np.pi / 2.5) | ||
| ) | ||
| # Execute the sweep. | ||
| wipe_multiple_strokes( | ||
| robot, start_pose, end_pose, 0.0, 0.4, (0.05, 0.0), 5, 1.0, 1 | ||
| ) | ||
|
|
||
| _run_manual_test() | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: change to "wiping skill."