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

publishing nan velocity due to infinite inverse radius assignment #158

Open
talhaaliarslan opened this issue May 26, 2023 · 2 comments
Open

Comments

@talhaaliarslan
Copy link

Came across this corner case where angular field in the command velocity is set to nan which may cause erratic movements on a robot if not handled on the receiving side. The nan value is coming from feedforward_ang_ component of the controller, which uses inverse turning radius as:

turning_radius_inv_vector_[find_result.last_visited_pose_index] * control_effort_long_;

The part where inverse turn radii are computed have a return value of infinity when delta is below an epsilon specified which includes a zero value too :

std::vector<double> inverse_turning_radiuses(const std::vector<tf2::Transform> & deltas)
{
auto result = std::vector<double>{};
result.reserve(deltas.size() + 1);
std::transform(
deltas.cbegin(), deltas.cend(), std::back_inserter(result), [](const tf2::Transform & d) {
const auto & origin = d.getOrigin();
const auto dpX = origin.x();
const auto dpY = origin.y();
const auto dpXY2 = std::pow(dpX, 2) + std::pow(dpY, 2);
if (dpXY2 < FLT_EPSILON) {
return std::numeric_limits<double>::infinity();
}
return (2 * dpY) / dpXY2;
});

This is causing an instance of nan command velocity (angular) in the controller which stays permanent even if inverse radii return back to finite values.

@Timple
Copy link
Member

Timple commented May 26, 2023

Ah, good catch!

Did you have fix for this already in mind? Otherwise we can look into it after next week.

@DemyKremers
Copy link

Hey @Timple , Talha and I fixed (and tested) this by replacing line 57 in calculations.cpp:
return std::numeric_limits<double>::infinity();

by:
return std::numeric_limits<double>::max();

Hope this helps.

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

No branches or pull requests

3 participants