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

Add speed limiter class #194

Merged
merged 9 commits into from
Mar 22, 2021
Merged

Add speed limiter class #194

merged 9 commits into from
Mar 22, 2021

Conversation

chapulina
Copy link
Contributor

🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸

🎉 New feature

Summary

We've been using the SpeedLimiter class ported from ros_control on Ignition Gazebo's diff drive controller for a while. Now another controller is being added and wants to use the class too (Ackermann on gazebosim/gz-sim#618), so it's good to move it to a common place where it can be reused by various controllers instead of copied. Ignition Math feels like a good place to put this.

The class had originally been copied from ros_control without much testing. While porting it to ign-math, I added tests and noticed that the jerk limit calculation was mistaken and is being fixed on ros-controls/ros_controllers#388. I believe the version on this PR should be correct.

Some other changes:

  • Made limits +1inf by default
  • Using chrono for time

Test it

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge

🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸

Signed-off-by: Louise Poubel <[email protected]>
Signed-off-by: Louise Poubel <[email protected]>
@chapulina chapulina requested a review from scpeters as a code owner March 4, 2021 02:11
@github-actions github-actions bot added 🏢 edifice Ignition Edifice 🏰 citadel Ignition Citadel 📜 blueprint Ignition Blueprint 🔮 dome Ignition Dome labels Mar 4, 2021
@codecov
Copy link

codecov bot commented Mar 4, 2021

Codecov Report

Merging #194 (7a97a73) into ign-math6 (b84710d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           ign-math6     #194   +/-   ##
==========================================
  Coverage      99.20%   99.21%           
==========================================
  Files             63       65    +2     
  Lines           6019     6087   +68     
==========================================
+ Hits            5971     6039   +68     
  Misses            48       48           
Impacted Files Coverage Δ
include/ignition/math/SpeedLimiter.hh 100.00% <100.00%> (ø)
src/SpeedLimiter.cc 100.00% <100.00%> (ø)

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 b84710d...7a97a73. Read the comment docs.

@chapulina
Copy link
Contributor Author

@scpeters , I refactored the API, implementation and naming conventions. I think the class is easier to use and the math is more straight forward now. Let me know what you think.

@chapulina chapulina added the beta Targeting beta release of upcoming collection label Mar 17, 2021
@chapulina chapulina self-assigned this Mar 19, 2021
@chapulina chapulina requested a review from scpeters March 19, 2021 02:17
Copy link
Member

@scpeters scpeters 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 delay in getting back to this. thanks for addressing my earlier comments; I have a few more now


_v = _v0 + dv;
}
const double accDesired = (_vel - _prevVel) / dtSec;
Copy link
Member

Choose a reason for hiding this comment

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

I think the code is clearer to read this way, but I believe it may have been written the other way to avoid a division operation and divide by 0 concerns

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I agree that this may have been the motivation. One lesson I took from the fact that the math had been wrong on the ros_control implementation all this time is the value of readability. I'm leaning towards leaving the math straightforward so it's easier to debug in the future. I added tests for the dt == 0 case, so I think we're covered.

Signed-off-by: Louise Poubel <[email protected]>
@chapulina chapulina requested a review from scpeters March 19, 2021 17:41
@chapulina chapulina merged commit 1610d5a into ign-math6 Mar 22, 2021
@chapulina chapulina deleted the chapulina/6/speed_limiter branch March 22, 2021 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Targeting beta release of upcoming collection 📜 blueprint Ignition Blueprint 🏰 citadel Ignition Citadel 🔮 dome Ignition Dome 🏢 edifice Ignition Edifice
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants