Skip to content
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

Feature/implement grasp detector in grab #1239

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

P-ict0
Copy link
Contributor

@P-ict0 P-ict0 commented Sep 13, 2022

Merge after #1238

Implementation of active_grasp_detector in grab.py. Also added a retry.

@MatthijsBurgh MatthijsBurgh force-pushed the feature/implement_grasp_detector_in_grab branch from c2741bd to b3ead88 Compare September 13, 2022 20:33
@@ -155,6 +155,12 @@ def handover_detector(self):
self._test_die(hasattr(self._arm, 'handover_detector'), "This arm does not have a handover_detector")
return self._arm.handover_detector

@property
def gripper_position_detector(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does a gripper_position_detector do? We already know where the gripper is with the joint_states/TF.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It reads the joint state of the gripper

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how open the fingers are?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. And upon further inspection we can use the get_joint_states function of the robot object for this but this allows us to already specify which joint corresponds to the fingers. That is something that can potentially be improved. But for now we want to see if this gives us the desired behaviour. Lets not do premature optimization.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a different can of worms and not for this project.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handover_detector can be ignored in this project, but gripper_position_detector should be modelled correctly. It doesn't mean it should be done correctly right now in this PR. But it should be done correctly soon.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#stopdeverloederingvanonzecode

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should create an issue about this. With a deadline this should be fixed.

Copy link
Contributor

@PetervDooren PetervDooren Oct 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created an issue to look into the grasp position detector robot part #1248 . It does not have high priority though. So I don't think we need to add a deadline

@P-ict0 P-ict0 force-pushed the feature/implement_grasp_detector_in_grab branch from db06a2c to 1461fa4 Compare September 27, 2022 19:08
Copy link
Contributor

@PetervDooren PetervDooren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some minor remarks but looks like a promising start

@P-ict0
Copy link
Contributor Author

P-ict0 commented Oct 1, 2022

From testing, seems like an error from the kinect.

  File "example_grasping.py", line 46, in <module>
    grab_state.execute()

  File "/home/rodtu/ros/noetic/system/src/smach/src/smach/state_machine.py", line 381, in execute
    container_outcome = self._update_once()

  File "/home/rodtu/ros/noetic/system/src/smach/src/smach/state_machine.py", line 269, in _update_once
    raise smach.InvalidUserCodeError("Could not execute state '%s' of type '%s': " %
smach.exceptions.InvalidUserCodeError: Could not execute state 'PREPARE_GRASP' of type '<robot_smach_states.manipulation.grab.PrepareEdGrasp object at 0x7f178c0cf8e0>': Traceback (most recent call last):

  File "/home/rodtu/ros/noetic/system/src/smach/src/smach/state_machine.py", line 258, in _update_once
    outcome = self._current_state.execute(

  File "/home/rodtu/ros/noetic/system/src/robot_smach_states/src/robot_smach_states/manipulation/grab.py", line 55, in execute
    segm_res = self.robot.ed.update_kinect("%s" % entity.uuid)

  File "/home/rodtu/ros/noetic/system/src/robot_skills/src/robot_skills/world_model_ed.py", line 420, in update_kinect
    res = self._ed_kinect_update_srv(area_description=area_description,

  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros_service.py", line 442, in __call__
    return self.call(*args, **kwds)

  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros_service.py", line 498, in call
    request = rospy.msg.args_kwds_to_message(self.request_class, args, kwds)

  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/msg.py", line 105, in args_kwds_to_message
    return data_class(**kwds)

  File "/home/rodtu/ros/noetic/system/devel/lib/python3/dist-packages/ed_sensor_integration_msgs/srv/_Update.py", line 47, in __init__super(UpdateRequest, self).__init__(*args, **kwds)

  File "/opt/ros/noetic/lib/python3/dist-packages/genpy/message.py", line 361, in __init__
    raise AttributeError('%s is not an attribute of %s' % (k, self.__class__.__name__))

AttributeError: fit_supporting_entity is not an attribute of UpdateRequest```

@PetervDooren
Copy link
Contributor

@P-ict0 The reason CI was failing was because the tests are done using the Mockbot. so when we add a robot part to our hero python object we should also add it to the mockbot to remain compatible. I fixed this in b277700

PetervDooren
PetervDooren previously approved these changes Oct 1, 2022
Copy link
Contributor

@PetervDooren PetervDooren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things we must watch out for in the future:
retrying grasp might not always be desired but we'll see when that becomes a problem.
Some magic numbers are very hero-specific. but as long as we keep it configurable we should be good.

@@ -14,7 +14,7 @@ class ActiveGraspDetector(smach.State):
REQUIRED_ARM_PROPERTIES = {"required_gripper_types": [GripperTypes.GRASPING], }

def __init__(self, robot: Robot, arm_designator: ArmDesignator, threshold_difference: float = 0.075,
minimum_position: float = -0.82, max_torque: float = 0.15) -> None:
minimum_position: float = -0.75, max_torque: float = 0.15) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are still very much magic numbers. They have the downside that they need to be tuned constantly. But I think that may be for another time

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this an issue. If we need keep changing this, this is something we need to work on with high priority.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created an issue to look into the grasp position detector robot part #1248 . It does not have high priority though. So I don't think we need to add a deadline

@P-ict0
Copy link
Contributor Author

P-ict0 commented Oct 1, 2022

A few things we must watch out for in the future: retrying grasp might not always be desired but we'll see when that becomes a problem. Some magic numbers are very hero-specific. but as long as we keep it configurable we should be good.

Yes, the retry option is defaulted to False for these cases. I think this is the correct way of approaching this.

@MatthijsBurgh MatthijsBurgh self-requested a review October 1, 2022 15:04
@@ -155,6 +155,12 @@ def handover_detector(self):
self._test_die(hasattr(self._arm, 'handover_detector'), "This arm does not have a handover_detector")
return self._arm.handover_detector

@property
def gripper_position_detector(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should create an issue about this. With a deadline this should be fixed.

@@ -14,7 +14,7 @@ class ActiveGraspDetector(smach.State):
REQUIRED_ARM_PROPERTIES = {"required_gripper_types": [GripperTypes.GRASPING], }

def __init__(self, robot: Robot, arm_designator: ArmDesignator, threshold_difference: float = 0.075,
minimum_position: float = -0.82, max_torque: float = 0.15) -> None:
minimum_position: float = -0.75, max_torque: float = 0.15) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this an issue. If we need keep changing this, this is something we need to work on with high priority.

@PetervDooren
Copy link
Contributor

@MatthijsBurgh, your comments have been adressed. can we merge this PR now?

@MatthijsBurgh
Copy link
Member

I have also created #1249. I think this is really important that we keep it structured how robot parts are added.

I sometimes get the feeling we are skipping the complex thoughts on how we keep the code organized for the sake of development. But in the end people are complaining code is messy, not robust, hard to maintain, not modular, etc. That is indeed what you get, when you skip the steps to keep your code organized.

I don't want to put a hold on development. So first get things working, then refactor it, so it is maintainable, etc. But this should be done before merging stuff into master. Because when it is in master, there is no motivation anymore to fix it.

So I am not sure, I accept this code in master yet. Lets have a discussion with everyone tonight how we want to balance between development and good, modular, robust, maintainable, etc. code.

@GustavoDCC
Copy link
Contributor

GustavoDCC commented Oct 4, 2022

From testing, I still have this error after add gripperpositiondetector to mockbot.

Traceback (most recent call last):
  File "/home/gustavo/ros/noetic/system/src/smach/src/smach/state_machine.py", line 258, in _update_once
    outcome = self._current_state.execute(
  File "/home/gustavo/ros/noetic/system/src/robot_smach_states/src/robot_smach_states/manipulation/grab.py", line 55, in execute
    segm_res = self.robot.ed.update_kinect("%s" % entity.uuid)
  File "/home/gustavo/ros/noetic/system/src/robot_skills/src/robot_skills/world_model_ed.py", line 420, in update_kinect
    res = self._ed_kinect_update_srv(area_description=area_description,
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros_service.py", line 442, in __call__
    return self.call(*args, **kwds)
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros_service.py", line 498, in call
    request = rospy.msg.args_kwds_to_message(self.request_class, args, kwds) 
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/msg.py", line 105, in args_kwds_to_message
    return data_class(**kwds)
  File "/home/gustavo/ros/noetic/system/devel/lib/python3/dist-packages/ed_sensor_integration_msgs/srv/_Update.py", line 47, in __init__
    super(UpdateRequest, self).__init__(*args, **kwds)
  File "/opt/ros/noetic/lib/python3/dist-packages/genpy/message.py", line 361, in __init__
    raise AttributeError('%s is not an attribute of %s' % (k, self.__class__.__name__))
AttributeError: fit_supporting_entity is not an attribute of UpdateRequest

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "example_grasping.py", line 46, in <module>
    grab_state.execute()
  File "/home/gustavo/ros/noetic/system/src/smach/src/smach/state_machine.py", line 381, in execute
    container_outcome = self._update_once()
  File "/home/gustavo/ros/noetic/system/src/smach/src/smach/state_machine.py", line 269, in _update_once
    raise smach.InvalidUserCodeError("Could not execute state '%s' of type '%s': " %
smach.exceptions.InvalidUserCodeError: Could not execute state 'PREPARE_GRASP' of type '<robot_smach_states.manipulation.grab.PrepareEdGrasp object at 0x7fad4477eca0>': Traceback (most recent call last):
  File "/home/gustavo/ros/noetic/system/src/smach/src/smach/state_machine.py", line 258, in _update_once
    outcome = self._current_state.execute(
  File "/home/gustavo/ros/noetic/system/src/robot_smach_states/src/robot_smach_states/manipulation/grab.py", line 55, in execute
    segm_res = self.robot.ed.update_kinect("%s" % entity.uuid)
  File "/home/gustavo/ros/noetic/system/src/robot_skills/src/robot_skills/world_model_ed.py", line 420, in update_kinect
    res = self._ed_kinect_update_srv(area_description=area_description,
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros_service.py", line 442, in __call__
    return self.call(*args, **kwds)
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros_service.py", line 498, in call
    request = rospy.msg.args_kwds_to_message(self.request_class, args, kwds)
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/msg.py", line 105, in args_kwds_to_message
    return data_class(**kwds)
  File "/home/gustavo/ros/noetic/system/devel/lib/python3/dist-packages/ed_sensor_integration_msgs/srv/_Update.py", line 47, in __init__
    super(UpdateRequest, self).__init__(*args, **kwds)
  File "/opt/ros/noetic/lib/python3/dist-packages/genpy/message.py", line 361, in __init__
    raise AttributeError('%s is not an attribute of %s' % (k, self.__class__.__name__))
AttributeError: fit_supporting_entity is not an attribute of UpdateRequest

@GustavoDCC GustavoDCC force-pushed the feature/implement_grasp_detector_in_grab branch from b232dd7 to f31614e Compare October 16, 2022 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants