-
Notifications
You must be signed in to change notification settings - Fork 12
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
suction cup interface for HERO #1114
Open
shanki98
wants to merge
4
commits into
master
Choose a base branch
from
feature/suction_cup
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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,69 @@ | ||
#ROS | ||
import rospy | ||
from actionlib import GoalStatus | ||
|
||
#General | ||
import PyKDL as kdl | ||
|
||
# TUe Robotics | ||
from robot_skills.arm.gripper import Gripper | ||
# Toyota | ||
from tmc_suction.msg import SuctionControlAction, SuctionControlGoal | ||
|
||
|
||
class SuctionGripper(Gripper): | ||
""" | ||
A Suction gripper that has a vacuum suction cup to grasp objects | ||
""" | ||
def __init__(self, robot_name, tf_buffer, gripper_name): | ||
""" | ||
constructor | ||
:param robot_name: robot_name | ||
:param tf_buffer: tf2_ros.Buffer | ||
:param gripper_name: string to identify the gripper | ||
""" | ||
super(SuctionGripper, self).__init__(robot_name=robot_name, tf_listener=tf_buffer) | ||
self.gripper_name = gripper_name | ||
offset = self.load_param('skills/' + self.gripper_name + '/grasp_offset/') | ||
self.offset = kdl.Frame(kdl.Rotation.RPY(offset["roll"], offset["pitch"], offset["yaw"]),kdl.Vector(offset["x"], offset["y"], offset["z"])) | ||
|
||
# Init gripper actionlib for SuctionGripper | ||
self._ac_suction = self.create_simple_action_client("/" + robot_name + "/suction_control", SuctionControlAction) | ||
|
||
# Waits until the action server has started up and started | ||
# listening for goals | ||
self._ac_suction.wait_for_server() | ||
|
||
def send_gripper_goal(self, sucking, timeout=0.0): | ||
""" | ||
Send a GripperCommand to the gripper and wait for finishing | ||
:param sucking: turn suction on or off | ||
:type sucking: bool | ||
:param timeout: timeout in seconds; timeout of 0.0 is not allowed | ||
:type timeout: float | ||
:return: True of False | ||
:rtype: bool | ||
""" | ||
|
||
if not isinstance(sucking, bool): | ||
rospy.logerr('State should be true or false, now it is {0}'.format(sucking)) | ||
return False | ||
|
||
goal = SuctionControlGoal() | ||
|
||
goal.suction_on.data = sucking | ||
|
||
self._ac_suction.send_goal(goal) | ||
|
||
if timeout != 0.0: | ||
self._ac_suction.wait_for_result(rospy.Duration(timeout)) | ||
goal_status = self._ac_suction.get_state() | ||
goal_status_bool = goal_status == GoalStatus.SUCCEEDED | ||
else: | ||
rospy.logerr("A timeout value of 0.0 is given, which is not allowed!") | ||
goal_status = self._ac_suction.get_state() | ||
while goal_status == GoalStatus.PENDING: | ||
goal_status = self._ac_suction.get_state() | ||
goal_status_bool = goal_status == GoalStatus.SUCCEEDED | ||
|
||
return goal_status_bool |
This file contains 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 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
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.
After discussion with @MatthijsBurgh it was decided to change the behaviour. A timeout of 0 should be the default, in this case the system should wait until the action server is done and check the obtained status. Otherwise, after the timeout, the status of the action server should be checked, if the server is done the result should be used, otherwise the goal should be canceled.