-
Notifications
You must be signed in to change notification settings - Fork 12
Test/grasp heights #1013
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
jlunenburg
wants to merge
10
commits into
master
Choose a base branch
from
test/grasp-heights
base: master
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
Test/grasp heights #1013
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8deacea
example: grasping height test
jlunenburg 952fcfe
refactor(benchmarks)Moved all grasp benchmarks together in examples
jlunenburg 0645e51
fix(smach)Grasp point determination also works without convex hull
jlunenburg 3b6ee2d
test(smach)Improved info print and preempting of grasp height testscript
jlunenburg 7702914
doc(smach)Added docstring to grasping height test
jlunenburg 9e12e56
fix(smach)Grasppointdetermination: added check on frame ids
jlunenburg 575f91f
Revert "fix(smach)Grasp point determination also works without convex…
09de516
example(smach)Patch 'get_grasp_pose' from grasping height test script
e46ac0b
example(smach)Fixed import in test grasp heights
4c6f072
Merge remote-tracking branch 'origin/master' into test/grasp-heights
LarsJanssenTUe 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
119 changes: 119 additions & 0 deletions
119
robot_smach_states/examples/manipulation/grasp_benchmark/grasping_height_test.py
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,119 @@ | ||
| #! /usr/bin/env python | ||
|
|
||
| """ | ||
| This script has the robot navigate to the couch table. Next, on a number of different heights, a (virtual) entity is | ||
| added to the world model, the robot tries to grasp it and subsequently it is removed again. At the end, the results | ||
| (height, outcome, duration) at each height are printed. | ||
|
|
||
| Since the position of the entity (X_ENTITY, Y_ENTITY) and the id of the supporting entity (SUPPORTING_ENTITY_ID) are | ||
| heavily dependent, these are not parametrized. You can provide a different robot though. | ||
| """ | ||
|
|
||
| # System | ||
| from collections import namedtuple | ||
| from functools import partial | ||
|
|
||
| # ROS | ||
| import PyKDL as kdl | ||
| import rospy | ||
|
|
||
| # TU/e Robotics | ||
| from robot_smach_states.manipulation import Grab | ||
| from robot_smach_states.navigation import NavigateToSymbolic | ||
| from robot_smach_states.util.designators import EntityByIdDesignator, UnoccupiedArmDesignator | ||
|
|
||
| # Robot Skills | ||
| from robot_skills import arms | ||
| from robot_skills.get_robot import get_robot_from_argv | ||
| from robot_skills.robot import Robot | ||
| from robot_skills.util.entity import Entity | ||
| from robot_skills.util.kdl_conversions import FrameStamped | ||
|
|
||
| DZ = 0.1 | ||
| Z_MAX = 1.2 | ||
|
|
||
| X_ENTITY = 3.2 | ||
| Y_ENTITY = 1. | ||
|
|
||
| SUPPORTING_ENTITY_ID = "couch_table" | ||
|
|
||
| Result = namedtuple("Result", ["height", "result", "duration"]) | ||
|
|
||
|
|
||
| # noinspection PyUnusedLocal | ||
| def get_grasp_pose(_robot, entity, _arm): | ||
| # type: (Robot, Entity, arms.PublicArm) -> FrameStamped | ||
| """ | ||
| Overrides the 'get_grasp_pose' method of the GraspPointDetermination class so that a grasp pose can be determined if | ||
| an entity does not have a convex hull. | ||
|
|
||
| :param _robot: (Robot) api object | ||
| :param entity: entity to grasp | ||
| :param _arm: arm to use | ||
| :return: FrameStamped with grasp pose in map frame | ||
| """ | ||
| robot_pose_map = _robot.base.get_location() # type: FrameStamped | ||
| assert entity_pose.frame_id == robot_pose_map.frame_id, "It is assumed that the entity frame id and the " \ | ||
| "world frame id are equal (typically 'map')" | ||
| return FrameStamped(kdl.Frame(robot_pose_map.frame.M, entity.pose.frame.p), entity.frame_id) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
| rospy.init_node("test_grasping") | ||
|
|
||
| robot = get_robot_from_argv(1) | ||
|
|
||
| # Navigate to the couch table | ||
| nav_designator = EntityByIdDesignator(robot=robot, id=SUPPORTING_ENTITY_ID) | ||
| nav_state = NavigateToSymbolic(robot, {nav_designator: "in_front_of"}, nav_designator) | ||
| nav_state.execute() | ||
|
|
||
| # Setup the test | ||
| z_values = [DZ] | ||
| while z_values[-1] < Z_MAX: | ||
| z_values.append(z_values[-1] + DZ) | ||
|
|
||
| results = [] | ||
| for test_nr, z in enumerate(z_values): | ||
|
|
||
| print("\nTest nr {} of {} at height {}".format(test_nr + 1, len(z_values), z)) | ||
|
|
||
| # Add an entity to ed | ||
| grasp_entity_id = "test_entity" | ||
| entity_pose = FrameStamped(kdl.Frame(kdl.Vector(X_ENTITY, Y_ENTITY, z)), "map") | ||
| robot.ed.update_entity(id=grasp_entity_id, frame_stamped=entity_pose) | ||
jlunenburg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Try to grasp the entity | ||
| item_designator = EntityByIdDesignator(robot=robot, id=grasp_entity_id) | ||
| t_start = rospy.Time.now() | ||
| grasp_state = Grab( | ||
| robot, | ||
| item_designator, | ||
| UnoccupiedArmDesignator(robot, { | ||
| "required_goals": ["reset", "carrying_pose"], | ||
| "required_trajectories": ["prepare_grasp"], | ||
| "required_gripper_types": [arms.GripperTypes.GRASPING] | ||
| })) | ||
|
|
||
| # Override the 'get_grasp_pose' method | ||
| # noinspection PyProtectedMember | ||
| grasp_state["GRAB"]._gpd.get_grasp_pose = partial(get_grasp_pose, robot) | ||
|
|
||
| grasp_result = grasp_state.execute() | ||
| grasp_duration = (rospy.Time.now() - t_start).to_sec() | ||
| results.append(Result(z, grasp_result, grasp_duration)) | ||
|
|
||
| # Lose the entity | ||
| # noinspection PyProtectedMember | ||
| arm = robot._arms.values()[0] # type: arms.PublicArm | ||
| arm.send_gripper_goal(state=arms.GripperState.OPEN) | ||
|
|
||
| if rospy.is_shutdown(): | ||
| break | ||
|
|
||
| # Print the results | ||
| print("\n ---------- \n") | ||
| for result in results: | ||
| print("Height: {} --> {} (duration: {})".format(result.height, result.result, result.duration)) | ||
| print("\n ---------- \n") | ||
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.
Uh oh!
There was an error while loading. Please reload this page.