Skip to content

JTC: maintain current configuration as hold position #531

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

Conversation

peterdavidfagan
Copy link
Member

This pr adds logic to ensure that the current robot configuration is used as a goal when the JTC hasn't already been passed a goal: frankaemika/franka_ros2#10 (comment).

In particular this pr adds changes made by @marcbone in frankaemika/franka_ros2@8671588#diff-14bf2d9185d549c84286510ef2771e8dd01c2e6d8e05b8dae3fbeb52313c401b.

@destogl I can update the master branch too and perform a backport if needed.

@@ -350,6 +350,12 @@ controller_interface::return_type JointTrajectoryController::update(
}
}
}
else
{
// TODO(peterdavidfagan) temporary solution to keep the initial position
Copy link

@marcbone marcbone Feb 22, 2023

Choose a reason for hiding this comment

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

There is nothing more permanent than a temporary solution ;P
I put the comment there as I was unsure what kind of implications this has for other use-cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am happy to continue working on this pr based on feedback from ros-controls developers and my evolving understanding of the scripts.

Copy link
Member

@destogl destogl left a comment

Choose a reason for hiding this comment

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

This doesn't feel like the right solution for the issue. First my understanding and then the proposed solution.

Issue

When JTC is started, there is no input message, i.e., no command to the robot. This makes issues in effort controlled robots because the gravity is not compensated. Is this correct?

Solution

In on_activate method, we have to make sure that initial values are set properly for the robot. In most use-cases is that the states are set as new command for a robot. I believe this should be sufficient. If you are using the robot with effort command interface, then we have to think what initial values are sensible.

{
// TODO(peterdavidfagan) temporary solution to keep the initial position
// before the first trajectory goal arrives
set_hold_position();
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't feel right to be here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the feedback @destogl I will review the current set of commits based on the above information. It may be tomorrow before I can make updates due to an item I am finishing this evening.

@marcbone
Copy link

When JTC is started, there is no input message, i.e., no command to the robot. This makes issues in effort controlled robots because the gravity is not compensated. Is this correct?

Almost. No input message results in sending zero torques to the robot. Gravity is compensated, so the robot does not move away in an ideal scenario. However, you can just push the robot around as the PID controller is not running. Also, if you have a weight attached to the EE, the robot will move down.
And this is exactly what I want to avoid.

Here is the scenario:

  • The user has opened the brakes of our robot using our proprietary web interface. Now our internal controllers kick in to keep the robot at its current position.
  • User grasps an object with the gripper.
  • Then the user starts our MoveIt launch file that uses the JTC with the effort interface. If we now only do gravity compensation (zero torques) the robot would move away, while the user is actually just trying to plan a motion over MoveIt. He would not expect the robot to move during that phase. Thats why I definitely need the PID controller of the JTC to be active right from the start.

@destogl
Copy link
Member

destogl commented Feb 23, 2023

OK, so if I understand correctly, initial position setup should be set to the current position so that PID kicks in and robot is kept in place. Is this correct?

@c-rizz
Copy link

c-rizz commented Feb 24, 2023

Hi, at this point just posting this as a reference as it may still be useful. I was thinking of making a pull request out of my solution of issue #514 (comment) from a few weeks ago. But I noticed there is now this other pull request that seems to tackle the same problem. My solution was actually very similar, I think the only difference is that I used the actual current joint state instead of the last commanded state. Also, I set the new trajectory from the update method as it seemed safer from a synchronization perspective.

msg.header.stamp = rclcpp::Time(0);
msg.joint_names = params_.joints;
trajectory_msgs::msg::JointTrajectoryPoint point;
for (const auto & joint_position : last_commanded_state_.positions)
Copy link
Contributor

Choose a reason for hiding this comment

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

OK, it looks like last_commanded_state_ is always initialized first at L790 👍

@@ -350,6 +350,12 @@ controller_interface::return_type JointTrajectoryController::update(
}
}
}
else
Copy link
Contributor

Choose a reason for hiding this comment

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

I would move this else before the if since it's just a few lines. Best to get it out of the way quickly for readability, rather than requiring a couple hundred lines of scrolling.

@bmagyar
Copy link
Member

bmagyar commented Mar 6, 2023

I know you probably need this in humble but we operate with a backports-only policy. First we need a PR into the master branch then we can backport.

@christophfroehlich
Copy link
Contributor

Hi, at this point just posting this as a reference as it may still be useful. I was thinking of making a pull request out of my solution of issue #514 (comment) from a few weeks ago. But I noticed there is now this other pull request that seems to tackle the same problem. My solution was actually very similar, I think the only difference is that I used the actual current joint state instead of the last commanded state. Also, I set the new trajectory from the update method as it seemed safer from a synchronization perspective.

I was looking (and overseeing this PR first) for a solution for handling the canceling of goals. Having that in mind I vote for the solution of @c-rizz taking the current joint_state instead of the last command. Think of some manual abort because something did not go as planned (e.g, grasping using generous trajectory tolerances), then you don't want the robot still trying to reach the last commanded position.

I created already a PR from @c-rizz to the master branch with #558, what do the others think? @peterdavidfagan @AndyZe @destogl ?

@peterdavidfagan
Copy link
Member Author

peterdavidfagan commented Apr 27, 2023

Apologies for being inactive on this pr for a quite a while. As a result of #558 being merged I am going to close this pr.

Thanks @christophfroehlich for posting this pr.

@christophfroehlich
Copy link
Contributor

Ok, I reopened the other PR. Could you have a look and review it please?

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.

7 participants