Skip to content

Commit

Permalink
Move rounding of the output to the viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
Nir-Az committed Oct 25, 2020
1 parent 75856b6 commit 1d71c47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 6 additions & 2 deletions common/model-views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2904,11 +2904,15 @@ namespace rs2
show_max_range = true;
auto mur_sensor = ds.as<max_usable_range_sensor>();
auto max_usable_range = mur_sensor.get_max_usable_depth_range();
const float MIN_RANGE = 3.0f;
const float MAX_RANGE = 9.0f;
// display maximu, usable range in range 3-9 [m] at 1 [m] resolution (rounded)
auto max_usable_range_rounded = round(std::min(std::max(max_usable_range, MIN_RANGE), MAX_RANGE));

if (viewer.metric_system)
ss << std::dec << "\nMax usable range: " << std::setprecision(1) << max_usable_range << " meters";
ss << std::dec << "\nMax usable range: " << std::setprecision(1) << max_usable_range_rounded << " meters";
else
ss << std::dec << "\nMax usable range: " << std::setprecision(1) << max_usable_range / FEET_TO_METER << " feet";
ss << std::dec << "\nMax usable range: " << std::setprecision(1) << max_usable_range_rounded / FEET_TO_METER << " feet";
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/algo/max-usable-range/l500/max-usable-range.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@
const float PROCESSING_GAIN = 1.75f;
const float THERMAL = 74.5f;
const float INDOOR_MAX_RANGE = 9.0f;
const float MIN_RANGE = 3.0f;

// Based off of code in RS5-8358
float librealsense::algo::max_usable_range::l500::max_usable_range(float nest)
{
const float normalized_nest = nest / 16.0f;

auto temp_range = INDOOR_MAX_RANGE;
auto expected_max_range = INDOOR_MAX_RANGE;

if (normalized_nest > THERMAL)
{
temp_range = 31000.0f * pow(normalized_nest, -2.0f) * PROCESSING_GAIN;
expected_max_range = 31000.0f * pow(normalized_nest, -2.0f) * PROCESSING_GAIN;
}

// expected_max_range should be in range 3-9 [m] at 1 [m] resolution (rounded)
auto expected_max_range = round(std::min(std::max(temp_range, MIN_RANGE), INDOOR_MAX_RANGE));

return expected_max_range;
}

0 comments on commit 1d71c47

Please sign in to comment.