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

Fix for different ceres isinf() API #3471

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions nav2_constrained_smoother/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ find_package(Ceres REQUIRED COMPONENTS SuiteSparse)

set(CMAKE_CXX_STANDARD 17)

if(${CERES_VERSION} VERSION_LESS_EQUAL 2.0.0)
add_definitions(-DUSE_OLD_CERES_API)
endif()

nav2_package()

set(library_name nav2_constrained_smoother)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class SmootherCostFunction
Eigen::Matrix<T, 2, 1> center = arcCenter(
pt_prev, pt, pt_next,
next_to_last_length_ratio_ < 0);
if (ceres::isinf(center[0])) {
if (CERES_ISINF(center[0])) {
return;
}
T turning_rad = (pt - center).norm();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@

#define EPSILON 0.0001

/**
* Compatibility with different ceres::isinf() and ceres::IsInfinite() API
* used in Ceres Solver 2.1.0+ and 2.0.0- versions respectively
*/
#if defined(USE_OLD_CERES_API)
#define CERES_ISINF(x) ceres::IsInfinite(x)
#else
#define CERES_ISINF(x) ceres::isinf(x)
#endif

namespace nav2_constrained_smoother
{

Expand Down Expand Up @@ -86,7 +96,7 @@ inline Eigen::Matrix<T, 2, 1> tangentDir(
bool is_cusp)
{
Eigen::Matrix<T, 2, 1> center = arcCenter(pt_prev, pt, pt_next, is_cusp);
if (ceres::isinf(center[0])) { // straight line
if (CERES_ISINF(center[0])) { // straight line
Eigen::Matrix<T, 2, 1> d1 = pt - pt_prev;
Eigen::Matrix<T, 2, 1> d2 = pt_next - pt;

Expand Down