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

[JTC] Implement effort-only command interface #225

Merged
merged 13 commits into from
Apr 8, 2022

Conversation

Ace314159
Copy link
Contributor

This addresses the effort part of #135 and #171. I've tested this on our team's robot and it works identically to the ROS1 version from our testing.

I just realized that the trajectory tolerance parameters fix (the second commit) is also addressed by #224. I can remove the commit if you'd like to merge that first instead.

@Ace314159 Ace314159 force-pushed the jtc-effort branch 2 times, most recently from fef27e6 to 3fbf14d Compare August 23, 2021 03:07
@Ace314159
Copy link
Contributor Author

The test failures seem to be in force_torque_sensor_broadcaster, but I didn't modify that part of the code. Any ideas for what might be happening?

@bmagyar bmagyar requested review from destogl, bmagyar and v-lopez and removed request for destogl August 23, 2021 06:35
@destogl
Copy link
Member

destogl commented Aug 31, 2021

The test failures seem to be in force_torque_sensor_broadcaster, but I didn't modify that part of the code. Any ideas for what might be happening?

Don't worry about that. The tests are flaky.

Could you rebase the code since we changed the formatting?

@Ace314159 Ace314159 force-pushed the jtc-effort branch 3 times, most recently from 0b0f3d0 to b2aa3b9 Compare August 31, 2021 20:20
@Ace314159
Copy link
Contributor Author

@destogl Does it look good now?

Copy link
Member

@bmagyar bmagyar left a comment

Choose a reason for hiding this comment

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

The changes look good in general, thanks for keeping it up to date!
Do you think this should be called effort though? I think that the values you are using are basically acceleration or strongly derived from it. Does it relate to forces in any way? Effort in ros_control was used somewhat as a catch-all for "the third value" next to Position and Velocity

@Ace314159
Copy link
Contributor Author

@bmagyar I'm not too sure either, but I just tried to mimic the behavior of ros_control.

However, I don't think this is acceleration. My team is using the effort value as the power output for the motor, so perhaps a better name might be power?

@Ace314159
Copy link
Contributor Author

@livanov93 Does this look good?

Do you know if the test failures are just caused by flaky tests or if my changes caused it? There seem to be test failures on master as well.

@livanov93
Copy link
Contributor

@livanov93 Does this look good?

Do you know if the test failures are just caused by flaky tests or if my changes caused it? There seem to be test failures on master as well.

I think it is flaky test. The rest looks fine.

@destogl
Copy link
Member

destogl commented Sep 9, 2021

However, I don't think this is acceleration. My team is using the effort value as the power output for the motor, so perhaps a better name might be power?

My two cents about this. I think that you are actually using acceleration, which results in moment/power of the motor. The only thing what is intransparently happening in PID-part is conversion between acceleration and power by gain of the PID.

IMHO, the proper way for this would be to use acceleration interface and convert in robot driver acceleration to power. then if you are using other controllers you don't have to adjust gain of it for your specific robot.

(I am delighted if someone gives me a reason that this "proper" was is not so "proper") :)

@Ace314159
Copy link
Contributor Author

Ace314159 commented Sep 9, 2021

@destogl Perhaps power is not the right term. In the motor code, the type is called percent output. The difference between what we supply to the motor and acceleration is that when we supply a value of 0, the motor completely stops, but an acceleration of 0 would still preserve the velocity. However, I don't think this is velocity either since the value we output doesn't map linearly to position

How would you convert acceleration to power? I was able to find some formulas online, but they required knowing the mass and a time for the system.

Please correct me if I am mistaken. It's been a while since I've taken physics.

@destogl
Copy link
Member

destogl commented Sep 13, 2021

@Ace314159 what I can remember circular acceleration of a motor is proportional to its moment. But this discussion is probably not sensible because what you are saying you have some kind of abstract value. So we can go with the term "EFFORT" in this case. What do you think?

P.S. For personal interest, I am wondering how are you tuning your PID then if you don't have any idea about the physics of the value the motor is accepting.

@Ace314159
Copy link
Contributor Author

@destogl Yeah, I think that sounds good.

We don't really know the physics of what the motor is accepting, but we are assuming/hoping it is consistent (which is probably not true). We can read values like the position and velocity of the motor, and we know that a positive value turns the motor in direction and a negative value turns it in the other direction. Then, we just tuned our PID following the guidelines we found from StackExchange. I'm not sure if a PID is the best way to do what we want, but from our cursory testing it seems to work well enough. Does this answer your question?

@Ace314159
Copy link
Contributor Author

@destogl Is there anything else you'd like me to change to get this merged?

Copy link
Member

@bmagyar bmagyar left a comment

Choose a reason for hiding this comment

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

The PR is good to go!

Two follow-up issues I created for refactoring:
#325
#326

@destogl destogl merged commit 97c9431 into ros-controls:master Apr 8, 2022
@Ace314159
Copy link
Contributor Author

@bmagyar Would it be possible to backport this to foxy? Someone else also requested this and this would be useful for my team as well.

@theunkn0wn1
Copy link

Yeah, a foxy backport would be extremely useful for my team.

@bmagyar bmagyar added backport-foxy backport-humble This label should be used by maintaines only! Label triggers PR backport to ROS2 humble. labels May 3, 2022
mergify bot pushed a commit that referenced this pull request May 3, 2022
* Fix trajectory tolerance parameters
* Implement effort command interface for JTC
* Use auto_declare for pid params
* Set effort to 0 on deactivate

Co-authored-by: Denis Štogl <destogl@users.noreply.github.com>
(cherry picked from commit 97c9431)

# Conflicts:
#	joint_trajectory_controller/src/joint_trajectory_controller.cpp
#	joint_trajectory_controller/test/test_trajectory_controller.cpp
#	joint_trajectory_controller/test/test_trajectory_controller_utils.hpp
mergify bot pushed a commit that referenced this pull request May 3, 2022
* Fix trajectory tolerance parameters
* Implement effort command interface for JTC
* Use auto_declare for pid params
* Set effort to 0 on deactivate

Co-authored-by: Denis Štogl <destogl@users.noreply.github.com>
(cherry picked from commit 97c9431)

# Conflicts:
#	joint_trajectory_controller/src/joint_trajectory_controller.cpp
#	joint_trajectory_controller/test/test_trajectory_controller.cpp
#	joint_trajectory_controller/test/test_trajectory_controller_utils.hpp
@destogl
Copy link
Member

destogl commented May 4, 2022

Sorry guys but that is not possible because of too many changes in the mean time. you can try to resolve conflicting PRs and then we are happy to merge. We don't have resources to do this.

@GeorgeVe
Copy link

GeorgeVe commented May 6, 2022

Hee, I quickly created a WIP backport to foxy for the joint_trajectory_controller with an effort-only command interface. It works for my team in simulation with Gazebo. It is on our forked GitLab repository: (https://gitlab.com/project-march/libraries/control/ros2_controllers/-/tree/mergify/bp/foxy/pr-225/joint_trajectory_controller). Feel free to check it out, but I can't guarantee that it is 100% correct and finished. For example, the feature of 'allow_integration_in_goal_trajectories_' is also added but only partially implemented.

@rohitmenon86
Copy link

Hi, I have created a backport for galactic on my fork here https://github.com/rohitmenon86/ros2_controllers.git for the joint_trajectory_controller ONLY with an effort-only command interface. I am still testing it

@bmagyar
Copy link
Member

bmagyar commented May 23, 2022

PRs are welcome

@AlexKaravaev AlexKaravaev mentioned this pull request May 27, 2022
9 tasks
gwalck pushed a commit to StoglRobotics-forks/ros2_controllers that referenced this pull request Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-humble This label should be used by maintaines only! Label triggers PR backport to ROS2 humble.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants