Skip to content

Commit 281ebe4

Browse files
Use fixed thresholds for Trinary yaml (#5278) (#5286)
(cherry picked from commit 829e683) Signed-off-by: Adi Vardi <[email protected]> Co-authored-by: Adi Vardi <[email protected]>
1 parent 28a560a commit 281ebe4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

nav2_map_server/src/map_io.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,18 @@ void tryWriteMapToFile(
601601
e << YAML::Key << "origin" << YAML::Flow << YAML::BeginSeq << map.info.origin.position.x <<
602602
map.info.origin.position.y << yaw << YAML::EndSeq;
603603
e << YAML::Key << "negate" << YAML::Value << 0;
604-
e << YAML::Key << "occupied_thresh" << YAML::Value << save_parameters.occupied_thresh;
605-
e << YAML::Key << "free_thresh" << YAML::Value << save_parameters.free_thresh;
604+
605+
if (save_parameters.mode == MapMode::Trinary) {
606+
// For Trinary mode, the thresholds depend on the pixel values in the saved map,
607+
// not on the thresholds used to threshold the map.
608+
// As these values are fixed above, the thresholds must also be fixed to separate the
609+
// pixel values into occupied, free and unknown.
610+
e << YAML::Key << "occupied_thresh" << YAML::Value << 0.65;
611+
e << YAML::Key << "free_thresh" << YAML::Value << 0.196;
612+
} else {
613+
e << YAML::Key << "occupied_thresh" << YAML::Value << save_parameters.occupied_thresh;
614+
e << YAML::Key << "free_thresh" << YAML::Value << save_parameters.free_thresh;
615+
}
606616

607617
if (!e.good()) {
608618
RCLCPP_ERROR_STREAM(

0 commit comments

Comments
 (0)