Skip to content

Commit

Permalink
Fix Tare calibration flow on DDS
Browse files Browse the repository at this point in the history
  • Loading branch information
OhadMeir committed Sep 29, 2024
1 parent baa0dfa commit a207041
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/ds/d500/d500-auto-calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,29 +650,30 @@ namespace librealsense

std::shared_ptr< option > d500_auto_calibrated::change_preset()
{
preset old_preset_values{};
rs2_rs400_visual_preset old_preset = { RS2_RS400_VISUAL_PRESET_DEFAULT };

if( ! _depth_sensor )
throw not_implemented_exception( " Depth sensor must be supplied to d500_auto_calibrated" );
throw not_implemented_exception( "Depth sensor must be supplied to d500_auto_calibrated" );

if( _depth_sensor->supports_option( RS2_OPTION_VISUAL_PRESET ) )
{
auto & opt = _depth_sensor->get_option( RS2_OPTION_VISUAL_PRESET );
old_preset = static_cast< rs2_rs400_visual_preset >( opt.query() );
//if( old_preset == RS2_RS400_VISUAL_PRESET_CUSTOM )
// old_preset_values = advanced_mode->get_all();
opt.set( RS2_RS400_VISUAL_PRESET_HIGH_ACCURACY );
auto old_preset = opt.get_value();
switch( opt.get_value_type() )
{
case RS2_OPTION_TYPE_FLOAT: // USB visual preset type is float
if( old_preset == RS2_RS400_VISUAL_PRESET_CUSTOM )
throw not_implemented_exception( "Calibration with custom visual preset is not supported" );
opt.set_value( RS2_RS400_VISUAL_PRESET_HIGH_ACCURACY );
break;
case RS2_OPTION_TYPE_STRING: // DDS visual preset type is a string
opt.set_value( std::string( "High Accuracy") );
break;
default:
throw invalid_value_exception( "Unsupported option type" );
}

std::shared_ptr< option > recover_option( &opt, [old_preset, old_preset_values]( option * opt )
std::shared_ptr< option > recover_option( &opt, [old_preset]( option * opt )
{
if( old_preset == RS2_RS400_VISUAL_PRESET_CUSTOM )
{
opt->set( RS2_RS400_VISUAL_PRESET_CUSTOM );
//adv->set_all( old_preset_values );
}
else
opt->set( static_cast< float >( old_preset ) );
opt->set_value( old_preset );
});

return recover_option;
Expand Down

0 comments on commit a207041

Please sign in to comment.