Skip to content

Fix for D435i loosing RGB-depth extrinsic calibration after firmware update - #3976

Merged
dorodnic merged 4 commits into
realsenseai:developmentfrom
aangerma:development
May 16, 2019
Merged

Fix for D435i loosing RGB-depth extrinsic calibration after firmware update#3976
dorodnic merged 4 commits into
realsenseai:developmentfrom
aangerma:development

Conversation

@aangerma

@aangerma aangerma commented May 14, 2019

Copy link
Copy Markdown
Contributor

Fix FW calibration tables location that potentially disable alignment/texture mapping use-cases with D435i model.
The affected FW versions generate the RGB calibration table in the memory reserved for another SKU.
This PR provides a rectification method that restores the RGB calibration data on the affected units using either factory or improperly-located data sets.
This method is invoked and applied automatically on the device’s start and does not require user actions.
Addresses #3474, #3788, #3201
Tracked on: DSO-12623

@ev-mp ev-mp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, pls review the changes.
Imo the D435 class shall be checked as well.

Comment thread src/ds5/ds5-factory.cpp
Comment thread src/ds5/ds5-factory.cpp Outdated
{
for (auto j = 0; j < 3; i++)
{
if (rect_rot_mat(i, j) != 0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls replace != as above

Comment thread src/ds5/ds5-factory.cpp
float3 trans_vector = table->translation_rect;
float3x3 rect_rot_mat = table->rotation_matrix_rect;

for (auto i = 0; i < 3; i++)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls add a description of the heuristic

Comment thread src/ds5/ds5-factory.cpp Outdated
environment::get_instance().get_extrinsics_graph().register_extrinsics(*_color_stream, *_depth_stream, _color_extrinsic);
}

bool try_restore_color_stream_extrinsic_from_asr_area(const int address)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove asr from the signature and rename into ..restore_from_address(..
Make the address uint to avoid negatives

Comment thread src/ds5/ds5-factory.cpp Outdated
}
}

void restore_color_stream_extrinsic(std::vector<byte> calib)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make the param const&

Comment thread src/ds5/ds5-factory.cpp Outdated

if (!try_restore_color_stream_extrinsic_from_gold_sector())
{
LOG_WARNING("The calibration on original 'gold' table is not valid");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls change the wording to
"RGB extrinsic recovery - Gold calibration is invalid, restore from an alternative sector"

Comment thread src/ds5/ds5-factory.cpp Outdated

if (!try_restore_color_stream_extrinsic_from_asr_area(gold_address))
{
LOG_WARNING("The calibration on 'gold' table is not valid");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please adjust the log messages for consistency

Comment thread src/ds5/ds5-factory.cpp Outdated

if (!try_restore_color_stream_extrinsic_from_asr_area(dynamic_address))
{
LOG_WARNING("The calibration on 'dynamic' table is not valid");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a warning that the recovery routine failed.
Also need to update the extrinsic graph so that color-depth will be removed (rather than zeroed)

Comment thread src/ds5/ds5-factory.cpp
auto calib = ds5_device::_hw_monitor->send(cmd);
if (validate_color_stream_extrinsic(calib))
{
restore_color_stream_extrinsic(calib);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the return value check and propagate it back to the caller

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix

Comment thread src/ds5/ds5-factory.cpp Outdated

void try_restore_color_stream_extrinsic()
{
const int gold_address = 0x17c49c;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls add a global try/catch to protect against FW API changes

@ev-mp ev-mp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

@dorodnic dorodnic added the d435i label May 14, 2019
@dorodnic dorodnic changed the title Fix to bug on RGB extrinsic on D435i. Work-around for D435i loosing RGB-depth calibration after firmware update May 14, 2019

@ev-mp ev-mp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor notes

Comment thread src/ds5/ds5-factory.cpp Outdated
{
try
{
// check that data is valid

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check that that data is valid verify extrinsic calibration table structure

Comment thread src/ds5/ds5-factory.cpp Outdated
for (auto i = 0; i < 3; i++)
{
if (trans_vector[i] != 0)
if (std::fabs(trans_vector[i] - 0) > std::numeric_limits<double>::epsilon())

@ev-mp ev-mp May 15, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop the ..-0) -
Types are not consistent - must compare to < float >

Comment thread src/ds5/ds5-factory.cpp Outdated
restore_color_stream_extrinsic(calib);
return true;
}
LOG_WARNING("Restore from address" << address << " faild");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Restore from address" Restoring RGB Extrinsic
typo - failed

Comment thread src/ds5/ds5-factory.cpp Outdated
restore_color_stream_extrinsic(calib);
return true;
}
LOG_WARNING("Restore from gold_sector faild");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Comment thread src/ds5/ds5-factory.cpp Outdated
try
{
LOG_WARNING("The calibration on original 'gold' table is not valid");
LOG_INFO("invalid extrinsic was identified, recovery routine was invoked");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls raise to LOG_WARNING
also add RGB before extrinsic

Comment thread src/ds5/ds5-factory.cpp Outdated
}
catch (...)
{
LOG_WARNING("Recovery routine failed");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RGB Extrinsic recovery routine failed

Comment thread src/ds5/ds5-factory.cpp
}
}

LOG_DEBUG("Suceeded to restore color stream extrinsic");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raise the level to LOG_INFO
RGB extrinsic restored

@aangerma aangerma changed the title Work-around for D435i loosing RGB-depth calibration after firmware update Fix for D435i loosing RGB-depth extrinsic calibration after firmware update May 15, 2019
Comment thread src/ds5/ds5-factory.cpp Outdated
//write the calibration to its correct address
command cmd(ds::fw_cmd::SETINTCALNEW, 0x20, 0x2);
cmd.data = calib;
auto res = ds5_device::_hw_monitor->send(cmd);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why do you need res?

Comment thread src/ds5/ds5-factory.cpp
auto calib = ds5_device::_hw_monitor->send(cmd);
if (validate_color_stream_extrinsic(calib))
{
restore_color_stream_extrinsic(calib);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix

Comment thread src/ds5/ds5-factory.cpp
{
LOG_WARNING("invalid RGB extrinsic was identified, recovery routine was invoked");

const uint32_t gold_address = 0x17c49c;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment explaining what these are

# Conflicts:
#	src/ds5/ds5-private.h
@dorodnic
dorodnic merged commit b71c0a8 into realsenseai:development May 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants