Skip to content

Commit

Permalink
added TRIGGERED and BAD_CONDITIONS calibration status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel committed Jul 29, 2020
1 parent 3742978 commit d67412a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 34 deletions.
26 changes: 17 additions & 9 deletions common/cah-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define GLFW_INCLUDE_NONE
#include "fw-update-helper.h"
#include "model-views.h"
#include "types.h"

using namespace rs2;

Expand Down Expand Up @@ -46,10 +47,10 @@ bool cah_model::prompt_trigger_popup(ux_window& window, std::string& error_messa
auto fw_upgrade_needed = is_upgradeable(_dev_model.dev.get_info(rs2_camera_info::RS2_CAMERA_INFO_FIRMWARE_VERSION), min_fw_version);
bool is_depth_streaming = std::any_of(_dev_model.subdevices.begin(), _dev_model.subdevices.end(), [](const std::shared_ptr<subdevice_model>& sm) { return sm->streaming && sm->s->as<depth_sensor>(); });
bool is_color_streaming = std::any_of(_dev_model.subdevices.begin(), _dev_model.subdevices.end(), [](const std::shared_ptr<subdevice_model>& sm) { return sm->streaming && sm->s->as<color_sensor>(); });
bool auto_cah_is_working =
(RS2_CALIBRATION_SUCCESSFUL != global_calib_status) &&
(RS2_CALIBRATION_FAILED != global_calib_status) &&
(RS2_CALIBRATION_NOT_NEEDED != global_calib_status);
bool auto_cah_is_working = RS2_CALIBRATION_SUCCESSFUL != global_calib_status
&& RS2_CALIBRATION_FAILED != global_calib_status
&& RS2_CALIBRATION_NOT_NEEDED != global_calib_status
&& RS2_CALIBRATION_BAD_CONDITIONS != global_calib_status;

std::string message_text = "Camera Accuracy Health will ensure you get the highest accuracy from your camera.\n\n"
"This process may take several minutes and requires special setup to get good results.\n"
Expand Down Expand Up @@ -97,8 +98,8 @@ bool cah_model::prompt_trigger_popup(ux_window& window, std::string& error_messa
{
sd->s->set_option(RS2_OPTION_TRIGGER_CAMERA_ACCURACY_HEALTH, static_cast<float>(RS2_CAH_TRIGGER_NOW));
}
catch (std::exception const & e)
{
catch( std::exception const & e )
{
error_message = to_string() << "Trigger calibration failure:\n" << e.what();
_process_started = false;
global_calib_status = RS2_CALIBRATION_FAILED;
Expand All @@ -108,7 +109,7 @@ bool cah_model::prompt_trigger_popup(ux_window& window, std::string& error_messa
_state = model_state_type::PROCESS_MODAL;
// We switch to process state without a guarantee that the process really started,
// Set a timeout to make sure if it is not started we will allow closing the window.
_process_timeout.start(std::chrono::seconds(30));
_process_timeout.start( std::chrono::seconds( 30 ) );

}
}
Expand All @@ -125,16 +126,23 @@ bool cah_model::prompt_trigger_popup(ux_window& window, std::string& error_messa
if (!_process_started)
{
// Indication of calibration process start
_process_started = (global_calib_status == RS2_CALIBRATION_SPECIAL_FRAME || global_calib_status == RS2_CALIBRATION_STARTED);
_process_started = global_calib_status == RS2_CALIBRATION_TRIGGERED
|| global_calib_status == RS2_CALIBRATION_SPECIAL_FRAME
|| global_calib_status == RS2_CALIBRATION_STARTED;
}

bool process_finished(global_calib_status == RS2_CALIBRATION_SUCCESSFUL || global_calib_status == RS2_CALIBRATION_FAILED || global_calib_status == RS2_CALIBRATION_NOT_NEEDED);
bool process_finished = global_calib_status == RS2_CALIBRATION_SUCCESSFUL
|| global_calib_status == RS2_CALIBRATION_FAILED
|| global_calib_status == RS2_CALIBRATION_NOT_NEEDED
|| global_calib_status == RS2_CALIBRATION_BAD_CONDITIONS;

static std::map<rs2_calibration_status, std::string> status_map{
{RS2_CALIBRATION_TRIGGERED , "In Progress" },
{RS2_CALIBRATION_SPECIAL_FRAME , "In Progress" },
{RS2_CALIBRATION_STARTED , "In Progress" },
{RS2_CALIBRATION_NOT_NEEDED , "Ended" },
{RS2_CALIBRATION_SUCCESSFUL , "Ended Successfully" },
{RS2_CALIBRATION_BAD_CONDITIONS , "Invalid Conditions" },
{RS2_CALIBRATION_RETRY , "In Progress" },
{RS2_CALIBRATION_FAILED , "Ended With Failure" },
{RS2_CALIBRATION_SCENE_INVALID , "In Progress" },
Expand Down
26 changes: 14 additions & 12 deletions include/librealsense2/h/rs_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,18 +329,20 @@ const char* rs2_calibration_type_to_string( rs2_calibration_type );
typedef enum rs2_calibration_status
{
// Anything >= 0 is not an issue
RS2_CALIBRATION_SPECIAL_FRAME = 0, // Special frame received; expect a frame-drop!
RS2_CALIBRATION_STARTED = 1, // Have all frames in hand; starting processing
RS2_CALIBRATION_NOT_NEEDED = 2, // Finished; existing calibration within tolerances; nothing done!
RS2_CALIBRATION_SUCCESSFUL = 3, // Finished; have new calibration in-hand

RS2_CALIBRATION_RETRY = -1, // Initiating retry (asked for a new special frame)
RS2_CALIBRATION_FAILED = -2,
RS2_CALIBRATION_SCENE_INVALID = -3, // Scene was not good enough for calibration; will retry
RS2_CALIBRATION_BAD_RESULT = -4, // Calibration finished, but results aren't good; will retry

RS2_CALIBRATION_STATUS_FIRST = -4,
RS2_CALIBRATION_STATUS_LAST = 3,
RS2_CALIBRATION_TRIGGERED = 0, // AC triggered and is active; conditions are valid
RS2_CALIBRATION_SPECIAL_FRAME = 1, // Special frame received; expect a frame-drop!
RS2_CALIBRATION_STARTED = 2, // Have all frames in hand; starting processing
RS2_CALIBRATION_NOT_NEEDED = 3, // Finished; existing calibration within tolerances; nothing done!
RS2_CALIBRATION_SUCCESSFUL = 4, // Finished; have new calibration in-hand

RS2_CALIBRATION_RETRY = -1, // Initiating retry (asked for a new special frame)
RS2_CALIBRATION_FAILED = -2, // Unexpected: exception, device removed, stream stopped, etc.
RS2_CALIBRATION_SCENE_INVALID = -3, // Scene was not good enough for calibration; will retry
RS2_CALIBRATION_BAD_RESULT = -4, // Calibration finished, but results aren't good; will retry
RS2_CALIBRATION_BAD_CONDITIONS = -5, // Trigger was attempted but conditions (temp/APD) were invalid (still inactive)

RS2_CALIBRATION_STATUS_FIRST = -5,
RS2_CALIBRATION_STATUS_LAST = 4,
RS2_CALIBRATION_STATUS_COUNT = RS2_CALIBRATION_STATUS_LAST - RS2_CALIBRATION_STATUS_FIRST + 1,
} rs2_calibration_status;
const char* rs2_calibration_status_to_string( rs2_calibration_status );
Expand Down
17 changes: 13 additions & 4 deletions src/l500/ac-trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ namespace ivcam2 {

is_depth_streaming = ac->_dev.get_depth_sensor().is_streaming();

if(is_depth_streaming)
if( is_depth_streaming )
{
AC_LOG( DEBUG, "Triggering manual calibration..." );
ac->trigger_calibration( calibration_type::MANUAL );
Expand Down Expand Up @@ -697,14 +697,23 @@ namespace ivcam2 {
_calibration_type = type;
AC_LOG( DEBUG, "Calibration type is " << (type == calibration_type::MANUAL ? "MANUAL" : "AUTO") );

check_conditions();
// Above throws invalid_value_exception, which we want: if calibration is triggered under
// bad conditions, we want the user to get this!
try
{
check_conditions();
}
catch( invalid_value_exception const & )
{
call_back( RS2_CALIBRATION_BAD_CONDITIONS );
// Above throws invalid_value_exception, which we want: if calibration is triggered
// under bad conditions, we want the user to get this!
throw;
}

_n_retries = 0;
_n_cycles = 1; // now active
get_ac_logger().open_active();
AC_LOG( INFO, "Camera Accuracy Health check is now active" );
call_back( RS2_CALIBRATION_TRIGGERED );
_next_trigger.reset(); // don't need a trigger any more
_temp_check.reset(); // nor a temperature check
start_color_sensor_if_needed();
Expand Down
20 changes: 11 additions & 9 deletions src/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,17 @@ namespace librealsense
#define CASE(X) STRCASE(CALIBRATION, X)
switch( value )
{
CASE( SPECIAL_FRAME )
CASE( STARTED )
CASE( NOT_NEEDED )
CASE( SUCCESSFUL )

CASE( FAILED )
CASE( SCENE_INVALID )
CASE( BAD_RESULT )
CASE( RETRY )
CASE( TRIGGERED )
CASE( SPECIAL_FRAME )
CASE( STARTED )
CASE( NOT_NEEDED )
CASE( SUCCESSFUL )

CASE( BAD_CONDITIONS )
CASE( FAILED )
CASE( SCENE_INVALID )
CASE( BAD_RESULT )
CASE( RETRY )
default: assert( !is_valid( value ) ); return UNKNOWN_VALUE;
}
#undef CASE
Expand Down

0 comments on commit d67412a

Please sign in to comment.