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

PID effort control of joints (+mimic) #122

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

ign_ros2_control/src/MimicJointSystem.cc Show resolved Hide resolved
ign_ros2_control/src/MimicJointSystem.cc Outdated Show resolved Hide resolved
ign_ros2_control/src/MimicJointSystem.cc Show resolved Hide resolved
ign_ros2_control/src/MimicJointSystem.cc Show resolved Hide resolved
ign_ros2_control/src/MimicJointSystem.cc Outdated Show resolved Hide resolved
ign_ros2_control/src/ign_system.cpp Outdated Show resolved Hide resolved
ign_ros2_control/src/ign_system.cpp Show resolved Hide resolved
ign_ros2_control/src/ign_system.cpp Outdated Show resolved Hide resolved
ign_ros2_control/src/ign_system.cpp Show resolved Hide resolved
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 👍

ign_ros2_control/CMakeLists.txt Outdated Show resolved Hide resolved
ign_ros2_control/CMakeLists.txt Show resolved Hide resolved
ign_ros2_control/CMakeLists.txt Outdated Show resolved Hide resolved
ign_ros2_control/src/MimicJointSystem.cc Show resolved Hide resolved
ign_ros2_control/include/ign_ros2_control/ign_system.hpp Outdated Show resolved Hide resolved
@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
@livanov93
Copy link
Contributor Author

@AndyZe @kylc Please take a look into changes I implemented and comments I had on your questions/suggestions.
Thanks!

@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)

ign_ros2_control/src/MimicJointSystem.cc Outdated Show resolved Hide resolved
ign_ros2_control/src/MimicJointSystem.cc Outdated Show resolved Hide resolved
ign_ros2_control/src/MimicJointSystem.cc Show resolved Hide resolved
ign_ros2_control/src/MimicJointSystem.cc Outdated Show resolved Hide resolved
ign_ros2_control/src/MimicJointSystem.cc Outdated Show resolved Hide resolved
ign_ros2_control/src/MimicJointSystem.cc Outdated Show resolved Hide resolved
ign_ros2_control/src/MimicJointSystem.cc Show resolved Hide resolved
@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
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.

ign_ros2_control/src/MimicJointSystem.cc Outdated Show resolved Hide resolved
@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

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