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 secondary friction coefficient parameter #1424

Merged
merged 11 commits into from
Nov 21, 2019

Conversation

scpeters
Copy link
Collaborator

@scpeters scpeters commented Nov 11, 2019

Currently the ContactConstraint uses a friction pyramid with 2 directions, and it uses the same friction coefficient in each direction. We have found it useful in gazebo to be able to specify different values in each direction (anisotropic wheel friction for example). As such, I've added mSecondaryFrictionCoeff to the ShapeNode DynamicsAspect and updated the ContactConstraint to use this secondary coefficient. @azeey and I have additional code in his fork that adds parameters for specifying the friction directions and slip parameters, which will be addressed in subsequent pull requests.

[edited] To avoid a behavior change, the mFrictionCoeff member variable in the ShapeFrame DynamicsAspect is renamed to mPrimaryFrictionCoeff along with its auto-generated get/set functions. The existing auto-generated getFrictionCoeff and setFrictionCoeff are explicitly implemented such that setFrictionCoeff sets both friction parameters and getFrictionCoeff returns the average (and also returns double instead of const double &). I've added test coverage for these new functions. We have test cases in gazebo demonstrating anisotropic friction in case you'd like to add one here in the future.


Before creating a pull request

  • Document new methods and classes
  • Format new code files using clang-format

Before merging a pull request

  • Set version target by selecting a milestone on the right side
  • Summarize this change in CHANGELOG.md
  • Add unit test(s) for this change

@codecov
Copy link

codecov bot commented Nov 11, 2019

Codecov Report

Merging #1424 into master will decrease coverage by <.01%.
The diff coverage is 70.83%.

@@            Coverage Diff             @@
##           master    #1424      +/-   ##
==========================================
- Coverage   57.98%   57.98%   -0.01%     
==========================================
  Files         412      412              
  Lines       29794    29832      +38     
==========================================
+ Hits        17277    17299      +22     
- Misses      12517    12533      +16
Impacted Files Coverage Δ
dart/constraint/ContactConstraint.hpp 100% <ø> (ø) ⬆️
dart/dynamics/detail/ShapeFrameAspect.hpp 88.88% <ø> (ø) ⬆️
dart/dynamics/ShapeFrame.hpp 81.81% <100%> (ø) ⬆️
dart/constraint/ContactConstraint.cpp 69.31% <64.7%> (-2.67%) ⬇️
dart/dynamics/ShapeFrame.cpp 71.15% <84.61%> (+1.58%) ⬆️
dart/dynamics/Skeleton.cpp 66.16% <0%> (-0.17%) ⬇️
dart/dynamics/EulerJoint.cpp 73% <0%> (+3.68%) ⬆️

@scpeters scpeters changed the title WIP: Add secondary friction coefficient parameter Add secondary friction coefficient parameter Nov 12, 2019
@scpeters scpeters added this to the DART 6.10.0 milestone Nov 12, 2019
@scpeters
Copy link
Collaborator Author

I've removed the WIP from the title since I think this is now ready for review.

@scpeters
Copy link
Collaborator Author

I have a proposed fix for the osx CI in #1426

Copy link
Member

@mxgrey mxgrey left a comment

Choose a reason for hiding this comment

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

I just have a few small tweak requests, but otherwise I'm totally fine with these changes.

@jslee02 Do you have any problem with having the secondary friction parameter added?

const double frictionCoeff = 1.0, const double restitutionCoeff = 0.0);
const double primaryFrictionCoeff = 1.0,
const double restitutionCoeff = 0.0,
const double secondaryFrictionCoeff = 1.0);
Copy link
Member

Choose a reason for hiding this comment

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

Instead of adding another function argument with a default of 1.0, I recommend overloading like this:

/// The frictionCoeff argument will be used for both primary and secondary friction
DynamicsAspectProperties(
    const double frictionCoeff = 1.0,
    const double restitutionCoeff = 0.0);

DynamicsAspectProperties(
    const double primaryFrictionCoeff,
    const double secondaryFrictionCoeff,
    const double restitutionCoeff);

I think this should be more intuitive and also should also maintain backwards compatibility.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@@ -114,14 +114,21 @@ ContactConstraint::ContactConstraint(
//----------------------------------------------
// TODO(JS): Assume the frictional coefficient can be changed during
// simulation steps.
// Update mFrictionalCoff
// Update mFrictionCoeff
const double frictionCoeffA = computeFrictionCoefficient(shapeNodeA);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const double frictionCoeffA = computeFrictionCoefficient(shapeNodeA);
const double primaryFrictionCoeffA = computeFrictionCoefficient(shapeNodeA);

Nitpick: I know it'll make for a bigger diff, but I think I'd recommend adding primary to these variable names for better symmetry.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated variable names in 2a0934f, and added the computePrimaryFrictionCoefficient function in 760cf3b

mxgrey
mxgrey previously approved these changes Nov 18, 2019
Copy link
Member

@jslee02 jslee02 left a comment

Choose a reason for hiding this comment

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

Two comments on style and backward compatibility. Otherwise, looks great to me!

dart/dynamics/ShapeFrame.hpp Outdated Show resolved Hide resolved
/// Coefficient of friction
double mFrictionCoeff;
/// Primary coefficient of friction
double mPrimaryFrictionCoeff;
Copy link
Member

Choose a reason for hiding this comment

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

This breaks backward compatibility since we're changing the name of the public member variable. Could we keep the variable name and add custom functions (i.e., set/getPrimaryFrictionCoeff) to DynamicAspect instead of DART_COMMON_SET_GET_ASPECT_PROPERTY(double, PrimaryFrictionCoeff)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

jslee02
jslee02 previously approved these changes Nov 20, 2019
@jslee02 jslee02 merged commit c64a78c into dartsim:master Nov 21, 2019
@scpeters scpeters deleted the secondary_friction branch November 22, 2019 01:30
mdecourse added a commit to mdecourse/dart that referenced this pull request Nov 22, 2019
Add secondary friction coefficient parameter (dartsim#1424)
@azeey azeey mentioned this pull request Sep 21, 2020
5 tasks
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.

3 participants