Skip to content

PID effort control of joints (+mimic) #122

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
wants to merge 25 commits into
base: humble
Choose a base branch
from

Conversation

livanov93
Copy link
Contributor

@livanov93 livanov93 commented Feb 22, 2023

Depends on #121

Description

PR introduces mapping all types of command interfaces (position, velocity, effort) to ForceJointCmd component.:

  1. For regular joints it does that in the following manner:
  1. For mimic joints it does that in the following manner:
  • Using the MimicJointSystem that can be found here which is pure ignition/gz system that is disconnected from ROS ecosystem.

    • it has PID controller which is trying to satisfy desired mimic behavior defined by multiplier and offset. It maps position error to force output which is applied to the joint.
    • PID parameters can't be changed in runtime, they must be specified within sdf tags
  • Using the same approach as for regular joints within ign_ros2_control::IgnitionSystemInterface here

    • cascade control is also an option for mimic joints

@livanov93 livanov93 force-pushed the pid-with-force-output branch from 55f6364 to 0104d7a Compare February 23, 2023 23:29
@livanov93 livanov93 force-pushed the pid-with-force-output branch from 5e6d70c to cb75106 Compare February 24, 2023 11:48
@livanov93 livanov93 force-pushed the pid-with-force-output branch from de3e194 to ea36469 Compare March 16, 2023 20:29
Copy link
Contributor

@AndyZe AndyZe left a comment

Choose a reason for hiding this comment

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

I've been hearing good things from testing. For example, this can actually handle contact with the environment. That's a big win 👍

@AndyZe
Copy link
Contributor

AndyZe commented Mar 20, 2023

Can you rename the PR, "PID effort control of a mimic joint" or something like that?

@livanov93 livanov93 changed the title Pid with force output PID effort control of joints (+mimic) Mar 21, 2023
@AndyZe
Copy link
Contributor

AndyZe commented Mar 24, 2023

@livanov93 it would help reviewers a lot in the future if you put a nice, long description in the PR. Especially on a 1,000+ line PR like this. Why did you make the design decisions you have made? Why did you choose to have 2 modes, ABS and PID? Then your reviewers won't have to ask ;)

@@ -25,6 +25,10 @@
#include "rclcpp_lifecycle/state.hpp"
#include "rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp"

#include "ign_ros2_control_parameters.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO still (nitpick)

@livanov93
Copy link
Contributor Author

@livanov93 it would help reviewers a lot in the future if you put a nice, long description in the PR. Especially on a 1,000+ line PR like this. Why did you make the design decisions you have made? Why did you choose to have 2 modes, ABS and PID? Then your reviewers won't have to ask ;)

I was writing it at the moment you wrote this. See here.

@livanov93 livanov93 requested review from AndyZe and kylc and removed request for kylc March 27, 2023 08:37
@livanov93 livanov93 force-pushed the pid-with-force-output branch from cf8b3b5 to b00a6bf Compare March 27, 2023 09:37
@livanov93 livanov93 force-pushed the pid-with-force-output branch from b00a6bf to a100537 Compare March 27, 2023 09:53
@livanov93 livanov93 force-pushed the pid-with-force-output branch from 06c7536 to 496dde5 Compare March 27, 2023 10:48
@livanov93 livanov93 requested a review from kylc March 27, 2023 10:53
Copy link

@kylc kylc left a comment

Choose a reason for hiding this comment

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

@livanov93 Thank you for addressing my feedback. This looks good to me!

Copy link
Contributor

@AndyZe AndyZe left a comment

Choose a reason for hiding this comment

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

I won't block this any more. I think it's leaps and bounds ahead of what we had before.

@danzimmerman
Copy link

danzimmerman commented Mar 28, 2023

I've been hearing good things from testing. For example, this can actually handle contact with the environment. That's a big win 👍

@AndyZe @livanov93 This seems like a great change.

I'm curious what you're seeing re: joint position accuracy. Sounds from some other issues (#113, for example) there are/were kinematic accuracy issues and sag with the prior position controllers anyway.

I'd imagine the cascaded controller coming in here could be better at achieving low joint position error than the effort_controllers/JointTrajectoryController was for ROS 1 UR simulation in Gazebo Classic. I observed pretty large errors there, while the regular position controller (which I think just drives ODE joint motors) was dead on, but of course couldn't touch anything rigid:

ros-industrial/universal_robot#521 (comment)

It'll be really nice to have a simulated robot that can make contact with a rigid environment. I was getting back to working on some ideas about elastic mounting, etc. in Gazebo Classic but maybe I should shift focus and try this out in new Gazebo first.

@livanov93
Copy link
Contributor Author

@ahcorde friendly ping for a review.

Copy link
Collaborator

@ahcorde ahcorde 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 response I was out some weeks, I made a initial pass and I will test it right today

@@ -39,10 +44,30 @@ elseif("$ENV{IGNITION_VERSION}" STREQUAL "fortress")
set(IGN_GAZEBO_VER ${ignition-gazebo6_VERSION_MAJOR})
message(STATUS "Compiling against Ignition Fortress")

find_package(ignition-cmake2 REQUIRED)
Copy link
Collaborator

Choose a reason for hiding this comment

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

duplicated code in the if and else

Comment on lines +37 to +38
#include "ignition/gazebo/components/Name.hh"
#include "ignition/gazebo/components/JointType.hh"
Copy link
Collaborator

Choose a reason for hiding this comment

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

alphabetize

Comment on lines +127 to +129
ignerr << "MimicJointSystem Failed to initialize because [" <<
this->dataPtr->model.Name(_ecm)
<< "] (Entity=" << _entity << ")] is not a model.. ";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ignerr << "MimicJointSystem Failed to initialize because [" <<
this->dataPtr->model.Name(_ecm)
<< "] (Entity=" << _entity << ")] is not a model.. ";
ignerr << "MimicJointSystem Failed to initialize because ["
<< this->dataPtr->model.Name(_ecm)
<< "] (Entity=" << _entity << ")] is not a model.. ";

Comment on lines +233 to +235
ignwarn << "Detected jump back in time [" << std::chrono::duration_cast <
std::chrono::seconds > (_info.dt).count()
<< "s]. System may not work properly." << std::endl;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ignwarn << "Detected jump back in time [" << std::chrono::duration_cast <
std::chrono::seconds > (_info.dt).count()
<< "s]. System may not work properly." << std::endl;
ignwarn << "Detected jump back in time ["
<< std::chrono::duration_cast <std::chrono::seconds > (_info.dt).count()
<< "s]. System may not work properly." << std::endl;

@@ -16,6 +16,8 @@

#include <ignition/msgs/imu.pb.h>

#include <iostream>

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change

Comment on lines +35 to +39
#include <ignition/gazebo/components/JointVelocityReset.hh>

#include <ignition/gazebo/components/JointAxis.hh>
#include <ignition/gazebo/components/JointType.hh>
#include <ignition/gazebo/components/Joint.hh>
Copy link
Collaborator

Choose a reason for hiding this comment

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

alphabetize

Suggested change
#include <ignition/gazebo/components/JointVelocityReset.hh>
#include <ignition/gazebo/components/JointAxis.hh>
#include <ignition/gazebo/components/JointType.hh>
#include <ignition/gazebo/components/Joint.hh>
#include <ignition/gazebo/components/JointVelocityReset.hh>
#include <ignition/gazebo/components/JointAxis.hh>
#include <ignition/gazebo/components/JointType.hh>
#include <ignition/gazebo/components/Joint.hh>

@@ -417,15 +623,9 @@ void IgnitionSystem::registerSensors(
}

static const std::map<std::string, size_t> interface_name_map = {
{"orientation.x", 0},
Copy link
Collaborator

Choose a reason for hiding this comment

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

to reduce the changes, can you restore these changes? Same with other similar changes

{
RCLCPP_WARN(this->nh_->get_logger(), "On init...");

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change

Copy link
Collaborator

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

add gripper_controllers to ign_ros2_control package.xml

Copy link
Collaborator

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

add gripper_controllers to ign_ros2_control package.xml

Copy link
Contributor

This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete.

@github-actions github-actions bot added the stale label Mar 31, 2025
this->dataPtr->joints_[i].sim_joint);
*jointVelCmd = ignition::gazebo::components::JointVelocityCmd(
{this->dataPtr->joints_[i].joint_velocity_cmd});
*forceCmd = ignition::gazebo::components::JointForceCmd({target_force});
Copy link

Choose a reason for hiding this comment

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

What's the rationale behind to wrap a velocity signal in JointForceCmd ? I looked at the code for JointForceCmd, it doesn't seem to do any translation from velocity to force.

Copy link

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@Juliaj be aware, this was for gazebo classic and could be different in modern gazebo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants