Skip to content

DistanceConstr - #131

Open
anastasiabolotnikova wants to merge 2 commits into
jrl-umi3218:masterfrom
anastasiabolotnikova:constr/distConstr
Open

DistanceConstr#131
anastasiabolotnikova wants to merge 2 commits into
jrl-umi3218:masterfrom
anastasiabolotnikova:constr/distConstr

Conversation

@anastasiabolotnikova

Copy link
Copy Markdown

Changing CollisionConstr to DistanceConstr.

@mergify

mergify Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@arntanguy arntanguy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just minor comments, on principle I am fine with it, thanks !

Comment thread src/Tasks/QPConstr.h
* \f[ \xi = -\frac{d_i - d_s}{d - d_s}\alpha + \xi_{\text{off}} \f]
*/
class TASKS_DLLAPI CollisionConstr : public ConstraintFunction<Inequality>
class TASKS_DLLAPI DistanceConstr : public ConstraintFunction<Inequality>

@arntanguy arntanguy Jul 24, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can add

using CollisionConstr [[deprecated("Use DistanceConstr instead.")]] = DistanceConstr;

after the class to keep the old name around for backwards compatibility.

Note: with this, this PR can be merged independently of mc_rtc

Comment thread src/QPConstr.cpp
}

if(d.distance < d.di)
if((d.distance < d.di && d.di > d.ds) || (d.distance > d.di && d.di < d.ds))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you document this behavior?

If I understand correctly:

  • if di > ds this is a collision avoidance constraint
  • di < ds this is a max distance constraint that gets activated when we are di distance away from the surface and we cannot go more than ds distance away from it

This is correct here, but if di == ds the constraint makes no sense and we risk dividing by 0.

      double dampers = d.damping * ((d.distance - d.ds) / (d.di - d.ds));

I haven't checked if we have unit tests for that, if we don't it'd be a good idea to add one.

Comment thread src/QPConstr.cpp
// sign will be -1
sign = -1.;
// sign will be -sign
sign = -sign;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So it's a loop on d.bodies.size() which is always 2 I guess? Confusing, but if it ain't broke...

Comment thread src/QPConstr.cpp
const CollData & cd,
const Eigen::Vector3d & normVecDist,
double dist) const
double DistanceConstr::computeDamping(const std::vector<rbd::MultiBody> & mbs,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should maybe ensure that the damping heuristics here behave well for unusual cases, e.g large distances. This has AFAIK only been used in contexts where we wish to avoid collisions on rather small distances, with an interaction distance rather close to the safety distance.

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.

2 participants