Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Age update implemented for projection #7661

Merged
merged 25 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions include/librealsense2/h/rs_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,26 @@ typedef struct rs2_intrinsics
/** \brief Video DSM (Digital Sync Module) parameters for calibration (same layout as in FW ac_depth_params)
This is the block in MC that converts angles to dimensionless integers reported to MA (using "DSM coefficients").
*/
typedef struct rs2_dsm_params
{
unsigned long long timestamp; /**< system_clock::time_point::time_since_epoch().count() */
unsigned short version; /**< MAJOR<<12 | MINOR<<4 | PATCH */
unsigned char model; /**< rs2_dsm_correction_model */
unsigned char flags[5]; /**< TBD, now 0s */
float h_scale; /**< the scale factor to horizontal DSM scale thermal results */
float v_scale; /**< the scale factor to vertical DSM scale thermal results */
float h_offset; /**< the offset to horizontal DSM offset thermal results */
float v_offset; /**< the offset to vertical DSM offset thermal results */
float rtd_offset; /**< the offset to the Round-Trip-Distance delay thermal results */
unsigned char temp_x2; /**< the temperature recorded times 2 (ldd for depth; hum for rgb) */
unsigned char reserved[11];
} rs2_dsm_params;
#pragma pack( push, 1 )
typedef struct rs2_dsm_params
{
unsigned long long timestamp; /**< system_clock::time_point::time_since_epoch().count() */
unsigned short version; /**< MAJOR<<12 | MINOR<<4 | PATCH */
unsigned char model; /**< rs2_dsm_correction_model */
unsigned char flags[5]; /**< TBD, now 0s */
float h_scale; /**< the scale factor to horizontal DSM scale thermal results */
float v_scale; /**< the scale factor to vertical DSM scale thermal results */
float h_offset; /**< the offset to horizontal DSM offset thermal results */
float v_offset; /**< the offset to vertical DSM offset thermal results */
float rtd_offset; /**< the offset to the Round-Trip-Distance delay thermal results */
unsigned char temp_x2; /**< the temperature recorded times 2 (ldd for depth; hum for rgb) */
float mc_h_scale; /**< the scale factor to horizontal LOS coefficients in MC */
float mc_v_scale; /**< the scale factor to vertical LOS coefficients in MC */
unsigned char weeks_since_calibration; /**< time (in weeks) since factory calibration */
unsigned char ac_weeks_since_calibaration; /**< time (in weeks) between factory calibration and last AC event */
unsigned char reserved[1];
} rs2_dsm_params;
#pragma pack( pop )

typedef enum rs2_dsm_correction_model
{
Expand Down
1 change: 1 addition & 0 deletions src/algo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
include(${CMAKE_CURRENT_LIST_DIR}/depth-to-rgb-calibration/CMakeLists.txt)
include(${CMAKE_CURRENT_LIST_DIR}/thermal-loop/CMakeLists.txt)
include(${CMAKE_CURRENT_LIST_DIR}/max-usable-range/CMakeLists.txt)
include(${CMAKE_CURRENT_LIST_DIR}/camera-age/CMakeLists.txt)
7 changes: 7 additions & 0 deletions src/algo/camera-age/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2020 Intel Corporation. All Rights Reserved.
target_sources(${LRS_TARGET}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/l500/camera-age.h"
"${CMAKE_CURRENT_LIST_DIR}/l500/camera-age.cpp"
)
79 changes: 79 additions & 0 deletions src/algo/camera-age/l500/camera-age.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//// License: Apache 2.0. See LICENSE file in root directory.
//// Copyright(c) 2020 Intel Corporation. All Rights Reserved.

#include "camera-age.h"
#include <string>


namespace librealsense {
namespace algo {
namespace camera_age {
namespace l500 {

work_week::work_week( std::time_t & t )
{
auto time = std::localtime( t );
int year = time->tm_year + 1900; // The tm_year field contains the number of years
// since 1900, we add 1900 to get current year
int ww = time->tm_yday / 7; // The tm_yday field contains the number of days sine 1st
// of January, we divide by 7 to get current work week
ww++; // We add 1 because work weeks start at 1 and not 0 (ex. 1st of January will return
// ww 0, but it ww 1)
return work_week( year, ww );
}

unsigned work_week::get_year() const
{
return man_year;
}

unsigned work_week::get_work_week() const
{
return man_ww;
}

unsigned work_week::operator-( const work_week & ww ) const
{
return ( ( this->get_year() - ww.get_year() ) * 52 ) // There are 52 weeks in a year
MMirbach marked this conversation as resolved.
Show resolved Hide resolved
+ ( this->get_work_week() - ww.get_work_week() );
}
// The Serial Number format is PYWWXXXX:
// P � Site Name(ex.�F� for Fabrinet)
// Y � Year(ex.�9� for 2019, "0" for 2020, , "1" for 2021 ..etc)
// WW � Work Week
// XXXX � Sequential number
work_week get_manufature_work_week( const std::string & serial )
{
if( serial.size() != 8 )
throw invalid_value_exception( "invalid serial number: " + serial + " is of invalid size" );
MMirbach marked this conversation as resolved.
Show resolved Hide resolved
unsigned Y = serial[1] - '0'; // Converts char to int, '0'-> 0, '1'-> 1, ...
unsigned man_year = 0;
// using Y from serial number to get manufactoring year
if( Y == 9 )
man_year = 2019;
else if( Y >= 0 && Y <= 8 )
MMirbach marked this conversation as resolved.
Show resolved Hide resolved
man_year = 2020 + Y;
else
throw invalid_value_exception( "invalid serial number: " + serial + " has invalid year" );
// using WW from serial number to get manufactoring work week
unsigned WW_tens = serial[2] - '0';
unsigned WW_singles = serial[3] - '0';
if( WW_tens > 9 || WW_tens < 0 || WW_singles > 9 || WW_singles < 0 )
MMirbach marked this conversation as resolved.
Show resolved Hide resolved
throw invalid_value_exception( "invalid serial number: " + serial
+ " has invalid work week" );
unsigned man_ww = ( (WW_tens)*10 ) + WW_singles;
return work_week( man_year, man_ww );
}

unsigned get_work_weeks_since( const work_week & start )
{
auto t = ( std::time( nullptr ) );
work_week now( t );
unsigned age = now - start;
return age;
}

} // namespace l500
} // namespace camera_age
} // namespace algo
} // namespace librealsense
41 changes: 41 additions & 0 deletions src/algo/camera-age/l500/camera-age.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2020 Intel Corporation. All Rights Reserved.

#pragma once

#include <string>
#include <ctime>


namespace librealsense {
namespace algo {
namespace camera_age {
namespace l500 {

class work_week
maloel marked this conversation as resolved.
Show resolved Hide resolved
{
unsigned man_year;
MMirbach marked this conversation as resolved.
Show resolved Hide resolved
unsigned man_ww;

public:
work_week( unsigned man_year, unsigned man_ww )
: man_year( man_year )
, man_ww( man_ww )
{
}
work_week(std::time_t& time);

MMirbach marked this conversation as resolved.
Show resolved Hide resolved
unsigned get_year() const;
unsigned get_work_week() const;
unsigned operator-( const work_week & ww ) const;
};

work_week get_manufature_work_week( const std::string & serial );

// Returns the number of work weeks since given time
unsigned get_work_weeks_since( const work_week & start );

} // namespace l500
} // namespace camera_age
} // namespace algo
} // namespace librealsense
54 changes: 41 additions & 13 deletions src/l500/l500-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "ac-trigger.h"
#include "algo/depth-to-rgb-calibration/debug.h"
#include "../common/utilities/time/periodic_timer.h"
#include "algo/camera-age/l500/camera-age.h"



Expand Down Expand Up @@ -126,6 +127,24 @@ namespace librealsense
register_info(RS2_CAMERA_INFO_PRODUCT_LINE, "L500");
register_info(RS2_CAMERA_INFO_CAMERA_LOCKED, _is_locked ? "YES" : "NO");

// If FW supportes the SET_AGE command, we update the age of the device in weeks to aid projection of aging
if( ( _fw_version >= firmware_version( "1.5.1.4" ) ) )
{
try
{
auto manufacture
= librealsense::algo::camera_age::l500::get_manufature_time( optic_serial );
uint8_t age
= librealsense::algo::camera_age::l500::get_work_weeks_since( manufacture );
command cmd( fw_cmd::SET_AGE, age );
_hw_monitor->send( cmd );
}
catch( ... )
{
LOG_ERROR( "Failed to set units age" );
}
}

configure_depth_options();
}

Expand Down Expand Up @@ -220,19 +239,28 @@ namespace librealsense
_autocal->register_callback(
[&]( rs2_calibration_status status )
{
if( status == RS2_CALIBRATION_SUCCESSFUL )
{
// We override the DSM params first, because it can throw if the parameters
// are exceeding spec! This may throw!!
get_depth_sensor().override_dsm_params( _autocal->get_dsm_params() );

auto & color_sensor = *get_color_sensor();
color_sensor.override_intrinsics( _autocal->get_raw_intrinsics() );
color_sensor.override_extrinsics( _autocal->get_extrinsics() );
color_sensor.set_k_thermal_intrinsics(_autocal->get_thermal_intrinsics());
}
notify_of_calibration_change( status );
} );
if( status == RS2_CALIBRATION_SUCCESSFUL )
MMirbach marked this conversation as resolved.
Show resolved Hide resolved
{
// We override the DSM params first, because it can throw if the parameters
MMirbach marked this conversation as resolved.
Show resolved Hide resolved
// are exceeding spec! This may throw!!
rs2_dsm_params new_dsm_params = _autocal->get_dsm_params();
// We update the age of the device in weeks and the time between factory
// calibration and last AC to aid projection
auto manufacture = librealsense::algo::camera_age::l500::get_manufature_time(
get_info( RS2_CAMERA_INFO_SERIAL_NUMBER ) );
uint8_t age
= librealsense::algo::camera_age::l500::get_work_weeks_since( manufacture );
new_dsm_params.weeks_since_calibration = age;
new_dsm_params.ac_weeks_since_calibaration = age;

get_depth_sensor().override_dsm_params( new_dsm_params );
auto & color_sensor = *get_color_sensor();
color_sensor.override_intrinsics( _autocal->get_raw_intrinsics() );
color_sensor.override_extrinsics( _autocal->get_extrinsics() );
color_sensor.set_k_thermal_intrinsics( _autocal->get_thermal_intrinsics() );
}
notify_of_calibration_change( status );
} );

depth_sensor.register_option(
RS2_OPTION_TRIGGER_CAMERA_ACCURACY_HEALTH,
Expand Down
3 changes: 2 additions & 1 deletion src/l500/l500-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ namespace librealsense
RGB_INTRINSIC_GET = 0x81,
RGB_EXTRINSIC_GET = 0x82,
FALL_DETECT_ENABLE = 0x9D, // Enable (by default) free-fall sensor shutoff (0=disable; 1=enable)
GET_SPECIAL_FRAME = 0xA0 // Request auto-calibration (0) special frames (#)
GET_SPECIAL_FRAME = 0xA0, // Request auto-calibration (0) special frames (#)
SET_AGE = 0x5B // Sets the age of the unit in weeks
};

#pragma pack(push, 1)
Expand Down