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

documenting instructions for the pick-and-place task #238

Merged
merged 7 commits into from
Jul 6, 2024

Conversation

FabianSchuetze
Copy link
Contributor

This PR attempts to embellish the pick-place demo by adding comments to several sections of the task construction.

I have been trying to understand the pick-place demo in the last few days and had benefited from a bit more verbose description. In particular, I did not comprehend how the grasp_frame_transform, specified in the panda config file, influence the outcome. I asked the same question on ros anwers but failed to garner an answer. @felixvd encouraged me via Discord to try to understand it myself and submit a PR with code comments.

I do not know if my comments are helpful or whether the PR has the appropriate structure. If there is anything you think I can improve, I'd happily do that.

@codecov
Copy link

codecov bot commented Feb 23, 2021

Codecov Report

Merging #238 (c9f3c9f) into master (a6fa452) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #238   +/-   ##
=======================================
  Coverage   33.86%   33.86%           
=======================================
  Files          93       93           
  Lines        5491     5491           
=======================================
  Hits         1859     1859           
  Misses       3632     3632           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a6fa452...aeb8aa4. Read the comment docs.

Copy link

@felixvd felixvd left a comment

Choose a reason for hiding this comment

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

Sorry for the late review, and thanks for the PR. I think this demo deserves detailed comments, so I hope this doesn't come across the wrong way, but I would actually appreciate if you could make this text shorter and more concise. The comments are verbose in a way that often makes them confusing instead of clarifying.

Consider this sentence: "The GenerateGraspPose circles in AngleDelta increments along the object creating one target pose in each instance."

Is "instance" a class instance, or a stage instance, or just a word that could be eliminated? When you read "The GenerateGraspPose circles", is "circles" a verb or noun? It could be either, and the reader can't be sure until almost the end of the sentence. The reference "the GenerateGraspPose" without the word "stage" reads strangely, almost like writing "the cancer" instead of "the cancer patient".

Consider this alternative: "The GenerateGraspPose stage adds grasp pose candidates in angle increments around the z-axis."

I've had this review half-done in my tabs for a while, so I'd rather submit this potentially unhelpful comment before this gets stale. To reiterate, this doesn't need to win a literary nobel prize and it already makes the demo better, but I think it's unnecessarily confusing in many parts. Would be glad if you could try improving on some of those points and update the PR.

// "high level" movements: Checking if the object to be picked is already attached to the robot arm, opening the robot's
// hand, moving the robot to the pre-grasp position, grasping the object, moving the robot to a pre-place position,
// placing the object, and finally, moving the robot to a standstill position. These six sequences are listed on the
// least indented column of the "Motion Planning Tasks" widget in Rviz. These sequences are not planned or executed but
Copy link

Choose a reason for hiding this comment

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

"least indented" --> "top-level", although since technically that's not true either I'd skip it altogether. "These sequences are shown in the widget..."

// hand, moving the robot to the pre-grasp position, grasping the object, moving the robot to a pre-place position,
// placing the object, and finally, moving the robot to a standstill position. These six sequences are listed on the
// least indented column of the "Motion Planning Tasks" widget in Rviz. These sequences are not planned or executed but
// defined as part of moveit's task constructor object below. The stages are be described in more detail below.
Copy link

Choose a reason for hiding this comment

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

I'd call it a Task object.

@@ -117,6 +126,7 @@ void PickPlaceTask::init() {
* Current State *
* *
***************************************************/
// Before beginning with the operation, one needs to verify if the object is not already attached to the robot.
Copy link

Choose a reason for hiding this comment

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

  1. I would try to keep it shorter, in general. E.g. "We verify that the object is not already attached to the robot."
  2. Does every task need to start with a state? Would help to say something about that here instead (otherwise there are 2 (3) comments within 10 lines about the verification).

@@ -153,6 +163,9 @@ void PickPlaceTask::init() {
* Move to Pick *
* *
***************************************************/
// This is the second major phase of picking the object. This phase moves to the start of the picking location. The
Copy link

Choose a reason for hiding this comment

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

Would keep it shorter here, too. E.g. "Moves to a pre-grasp pose from where the gripper approaches the object. Generated by a stage::Connect object which does not plan a movement, but connects two stages that do."

Also, remove the comment in the next line

auto stage = std::make_unique<stages::MoveRelative>("approach object", cartesian_planner);
// This movement approaches the object and stops right before it through a MoveRelative stage. The stage
// resembles the Connect because it does not define an end or starting point but move across space as defined
// as a geometryMsgs. In contrast to the Connect stage, however, the planner does not have any flexibility in
Copy link

Choose a reason for hiding this comment

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

geometry_msgs::Pose?

// This movement approaches the object and stops right before it through a MoveRelative stage. The stage
// resembles the Connect because it does not define an end or starting point but move across space as defined
// as a geometryMsgs. In contrast to the Connect stage, however, the planner does not have any flexibility in
// the cartesian structure of the movement as this is precisely defined.
Copy link

Choose a reason for hiding this comment

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

I'm not sure what you mean by "cartesian structure of the movement"

@@ -176,7 +193,11 @@ void PickPlaceTask::init() {
---- * Approach Object *
***************************************************/
{
auto stage = std::make_unique<stages::MoveRelative>("approach object", cartesian_planner);
// This movement approaches the object and stops right before it through a MoveRelative stage. The stage
Copy link

Choose a reason for hiding this comment

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

Misses a comment that this stage is inserted into the grasp/PickObject SerialContainer.

stage->setMonitoredStage(current_state_ptr); // Hook into current state

// Compute IK
// The object grasp is defined by combining two stages, a GenerateGraspPose and a ComputeIK pose. The
Copy link

Choose a reason for hiding this comment

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

"latches onto the object" implies a connection that I don't really see. "connects" seems to make more sense.

"The generateGraspPose" should be "The generateGraspPose stage" or "...container". The phrase "a ComputeIK pose" seems to be used to mean "a ComputeIKpose stage". This is confusing.

GenerateGraspPose is written both with and without capital first letter.

@FabianSchuetze
Copy link
Contributor Author

Thank you so much, @felixvd for your detailed and very thoughtful comments to the PR. Your suggestions help me to improve the PR an I will update the it accordingly!

@FabianSchuetze
Copy link
Contributor Author

Thank you again for your detailed and kind comments! I benefited a lot from them and hope the changed PR reflects this. I shortened the explanations and believe the text is more precise and succinct. I am curious to hear what you think of it and appreciate any feedback. Furthermore, should we maybe integrate these comments in a full tutorial for the moveit website as the current MTC tutorial is a bit short?

Copy link

@felixvd felixvd left a comment

Choose a reason for hiding this comment

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

Thanks, it's a lot better. I made some suggestions, but I'm good with this overall.

void PickPlaceTask::init() {
ROS_INFO_NAMED(LOGNAME, "Initializing task pipeline");
const std::string object = object_name_;

// Reset ROS introspection before constructing the new object
// TODO(henningkayser): verify this is a bug, fix if possible
// Movements are collected inside a Task object.
Copy link

Choose a reason for hiding this comment

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

A bit confusing with the previous two lines. Make this a line-end comment (put it at the end of the next line with two separating spaces).

@@ -82,20 +82,22 @@ void PickPlaceTask::loadParameters() {
rosparam_shortcuts::shutdownIfError(LOGNAME, errors);
}

// The init function declares all movements for the pick-and-place task. These movements are described below.
Copy link

Choose a reason for hiding this comment

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

Suggested change
// The init function declares all movements for the pick-and-place task. These movements are described below.
// The init function declares all movements for the pick-and-place task.

task_.reset();
task_.reset(new moveit::task_constructor::Task());

Task& t = *task_;
t.stages()->setName(task_name_);
t.loadRobotModel();

// Sampling planner
// Different planners plan robot movement: a cartesian , pipeline, or joint interpolation planner.
Copy link

Choose a reason for hiding this comment

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

Suggested change
// Different planners plan robot movement: a cartesian , pipeline, or joint interpolation planner.
// Different planners are available to plan robot motions, e.g. cartesian, pipeline, or joint interpolation.

Copy link

Choose a reason for hiding this comment

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

Since you can choose any planner. These are just examples.

auto stage = std::make_unique<stages::GenerateGraspPose>("generate grasp pose");
stage->properties().configureInitFrom(Stage::PARENT);
stage->properties().set("marker_ns", "grasp_pose");
stage->setPreGraspPose(hand_open_pose_);
stage->setObject(object);
stage->setAngleDelta(M_PI / 12);
stage->setAngleDelta(M_PI / 4);
Copy link

Choose a reason for hiding this comment

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

Why did this value change?

If it was up to me, I would change this to M_TAU/24 as per this PR of mine, but let's not open that discussion.

stage->setMonitoredStage(current_state_ptr); // Hook into current state

// Compute IK
// Compute joint parameters for a target frame of the end effector. Each target frame equals a grasp pose
// from the previous stage times the inverse of the user-defined grasp_frame_tansform.
Copy link

Choose a reason for hiding this comment

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

What is the grasp_frame_transform? Why times the inverse?

@@ -217,6 +225,7 @@ void PickPlaceTask::init() {
---- * Allow Collision (hand object) *
***************************************************/
{
// Modify the planning scene (does not alter the robot's position) to permit picking up the object.
Copy link

Choose a reason for hiding this comment

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

Suggested change
// Modify the planning scene (does not alter the robot's position) to permit picking up the object.
// Modify the planning scene (does not alter the robot's position) to allow collision between hand and object. Otherwise, the robot would not be able to move after picking the object.

Comment on lines 249 to 250
// Attaching the object to the hand and lifting the object while guaranteeing that it does not touch the
// ground happens in the next four stages.
Copy link

Choose a reason for hiding this comment

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

Suggested change
// Attaching the object to the hand and lifting the object while guaranteeing that it does not touch the
// ground happens in the next four stages.
// The next four stages attach the object to the hand and lift it while ensuring that it does not touch the ground.

@@ -153,7 +156,8 @@ void PickPlaceTask::init() {
* Move to Pick *
* *
***************************************************/
{ // Move-to pre-grasp
// Move to a pre-grasp pose. The Connect stage does not declare any movements but connects two stages that do.
Copy link

Choose a reason for hiding this comment

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

Suggested change
// Move to a pre-grasp pose. The Connect stage does not declare any movements but connects two stages that do.
// Move to the pre-grasp pose. The Connect stage connects two other stages with a motion.

Not perfectly happy with this, but it sounded too much like there's no robot motion going on in this stage

@@ -290,6 +301,7 @@ void PickPlaceTask::init() {
* *
*****************************************************/
{
// Fourth, define the `move to place` (as the `move to pick`) stage as a Connect object.
Copy link

Choose a reason for hiding this comment

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

Suggested change
// Fourth, define the `move to place` (as the `move to pick`) stage as a Connect object.
// Fourth, define the `move to place` stage as a Connect stage connecting the end of the pick to the start of the place phase (like the `move to pick` stage further up)

@felixvd
Copy link

felixvd commented Mar 3, 2021

Oh, and yes, an actual MTC tutorial page based on this example is certainly welcome. AFAIK there's no reason that it doesn't exist yet, except that no one has the time to write it. It would probably fit best on the current page.

@FabianSchuetze
Copy link
Contributor Author

Thank you very much indeed, Felix, for your comments and your help. Your assistance made the PR much better and working on it very enjoyable. I will try to find a new moveit issue to work on (a good first issue) and hope to contribute!

@cpetersmeier
Copy link
Contributor

Hello to all, I am working on the moveit_task_constructor tutorial. I enjoy the additions that this PR contributes to the demo code and would love to integrate them into the tutorial!

I think moving / duplicating the demo into the moveit_tutorials package was already touched on here. Would you suggest to pick the text / code bits manually from the demo files in this repository?

@FabianSchuetze
Copy link
Contributor Author

Hi @cpetersmeier - it is great to hear you are working on a tutorial for the MTC! I do not understand what you mean by saying:

Would you suggest to pick the text / code bits manually from the demo files in this repository?

However, if I were you, I would try to write a tutorial and select all the parts that you need for it as you see it fit. Please ping me if you have a PR ready - I am excited to read it!

@cpetersmeier
Copy link
Contributor

Dear @FabianSchuetze , @felixvd ,

I have created a first draft of an improved Moveit Task Constructor tutorial here. I would love some feedback from you that I could incorporate in the text!

@codecov-commenter
Copy link

codecov-commenter commented Jul 6, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 45.00000% with 11 lines in your changes missing coverage. Please review.

Project coverage is 57.31%. Comparing base (6b0f2c8) to head (c83c99e).
Report is 26 commits behind head on master.

Files Patch % Lines
demo/src/pick_place_task.cpp 45.00% 11 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #238      +/-   ##
==========================================
- Coverage   58.82%   57.31%   -1.50%     
==========================================
  Files          91      131      +40     
  Lines        8623    10684    +2061     
  Branches        0      954     +954     
==========================================
+ Hits         5072     6123    +1051     
- Misses       3551     4514     +963     
- Partials        0       47      +47     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rhaschke rhaschke merged commit 702710d into moveit:master Jul 6, 2024
7 checks passed
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.

5 participants