Skip to content

Clean up gradient based traversability estimation#149

Merged
MultyXu merged 7 commits into
developfrom
clean_up/gradient_map
Jun 26, 2026
Merged

Clean up gradient based traversability estimation#149
MultyXu merged 7 commits into
developfrom
clean_up/gradient_map

Conversation

@MultyXu

@MultyXu MultyXu commented Jun 23, 2026

Copy link
Copy Markdown

Clean up the gradient-based traversability function. Mostly factor out functions to be general helper functions.

@nathanhhughes nathanhhughes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for putting this together! This is almost there, but we should actually clean up how the configs work / it would be good to confirm or rule out a bug in spatial_hash

Comment on lines +78 to +81
//! Thresholds for classifyTraversabilityVoxel(), set by derived class constructors.
float min_confidence_ = 1.0f;
float min_traversability_ = 1.0f;
bool pessimistic_ = true;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The base TraversabilityEstimator can have a config with these that the other estimators inherit from (that would be my preference)

Comment on lines +86 to +90
// Build a 2D height map from a TSDF layer by scanning each vertical column of
// voxels for the highest surface voxel within the robot's vertical scan window.
// Uses block/local index access directly to avoid the signed/unsigned division
// bug in spatial_hash::blockIndexFromGlobalIndex that corrupts getVoxelPtr
// lookups for negative world coordinates.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It would be good to verify that this is actually a bug. I ran an issue with this in a different implementation but was not able to replicate it with spatial_hash (so I think blockIndexFromGlobalIndex is actually correct)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

(we talked about this earlier and we can punt on this for this PR)

Comment thread src/places/traversability_estimator.cpp Outdated
}
return height_map;
}
// Where to put these helper functions?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is correct, you can drop this comment

Comment thread src/places/traversability_estimator.cpp Outdated
Comment on lines +85 to +199
: config(config::checkValid(config)) {}
: config(config::checkValid(config)) {
min_confidence_ = config.min_confidence;
min_traversability_ = config.min_traversability;
pessimistic_ = config.pessimistic;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Related to my earlier comment, I'd use the base-class constructor to pass this config directly

Comment on lines -240 to +339
: config(config::checkValid(config)) {}
: config(config::checkValid(config)) {
min_confidence_ = config.min_confidence;
min_traversability_ = config.min_traversability;
pessimistic_ = config.pessimistic;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ditto on passing the config to the base class

@MultyXu

MultyXu commented Jun 24, 2026

Copy link
Copy Markdown
Author

@nathanhhughes Thanks for the feedback. In addition, to cleaning up this PR, I feel like it's better to put the helper functions in some util files becuase they share the same logic to construct height map and gradient maps. Should I move the functions under the 2d_dplaces folder in the same directory?

@nathanhhughes

Copy link
Copy Markdown
Collaborator

I'd actually put them in a traversability directory (and maybe move the rest of the code there as well), the 2D place directory is for the mesh places

@MultyXu MultyXu changed the title optionally add height information to traversability voxel for visuali… Clean up gradient based traversability estimation Jun 25, 2026

@nathanhhughes nathanhhughes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, thanks for cleaning this up! No rush but you're good to merge whenever now that the configs are updated

Comment on lines +86 to +87
protected:
explicit TraversabilityEstimator(const Config& config) : config(config) {}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's okay for this to not be protected, it's clear that you can't directly instantiate this because of the pure abstract method (protected constructors are useful for CRTP and singletons but not here)

Comment on lines +86 to +90
// Build a 2D height map from a TSDF layer by scanning each vertical column of
// voxels for the highest surface voxel within the robot's vertical scan window.
// Uses block/local index access directly to avoid the signed/unsigned division
// bug in spatial_hash::blockIndexFromGlobalIndex that corrupts getVoxelPtr
// lookups for negative world coordinates.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

(we talked about this earlier and we can punt on this for this PR)

@MultyXu

MultyXu commented Jun 25, 2026

Copy link
Copy Markdown
Author

Now this should be read with this PR, I've merged the functions in both places and use a dedicated sink. But I'm not quite sure if the sink is in the correct place since currently it is very specific to GradientTraversabilityPlaces.

@nathanhhughes

Copy link
Copy Markdown
Collaborator

@MultyXu commented in the other PR, but where you have the sink works for me

@MultyXu MultyXu merged commit bb5ae85 into develop Jun 26, 2026
2 checks passed
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