Skip to content

Detect the new products in the SDK and Viewer: D435f, D435if, D455f, D456 - #11399

Merged
Nir-Az merged 5 commits into
realsenseai:developmentfrom
Tamir91:detect_new_products
Feb 16, 2023
Merged

Detect the new products in the SDK and Viewer: D435f, D435if, D455f, D456#11399
Nir-Az merged 5 commits into
realsenseai:developmentfrom
Tamir91:detect_new_products

Conversation

@Tamir91

@Tamir91 Tamir91 commented Feb 5, 2023

Copy link
Copy Markdown
Contributor

Tracked on [LRS-657]

@Tamir91
Tamir91 requested a review from Nir-Az February 7, 2023 14:53
Comment thread src/ds/ds-private.h Outdated
fisheye_sensor_hb = 113,
imu_acc_chip_id = 124,
ip65_sealed_offset = 161,
filter_sensor_offset = 164,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe it is not the correct name "filter_sensor_offset"? Actually, a filter is not a sensor.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I agree, please align to your previous name: ir_filter_exist

@Tamir91 Tamir91 Feb 8, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry, what do you mean by previous name? Do you mean the variable ir_filter_mask?
In the struct, we have offsets of a memory.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Like discussed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread src/ds/ds5/ds5-device.cpp Outdated
}

auto const CUR_GVD_VERSION = gvd_buff[gvd_version_offset];
auto const MIN_GVD_VERSION = 0x4;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lets create a function for that, maybe inside ds5-private.h

This function will check once that MIN_GVD_VERSION <= CUR_GVD_VERSION
You also need to add comments for it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please inside the function add comments specificaly say how we change the name e.g. from D435i to D435IF
So when we search the code in the future for D435IF we will find it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Lets create a function for that, maybe inside ds5-private.h

This function will check once that MIN_GVD_VERSION <= CUR_GVD_VERSION You also need to add comments for it.

Due to multiple definitions, the project failed on the build with my function in *.h file.
What about creating a function in ds5-device.cpp?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Resolved together

@Nir-Az

Nir-Az commented Feb 8, 2023

Copy link
Copy Markdown
Collaborator

We need to search all of the old device names, see if someone is the code used the specific camera name to add some logic.
If so we need to add the new name as well
C++ and python wrapper

Comment thread src/ds/ds5/ds5-device.cpp Outdated
val_in_range(_pid, {RS435_RGB_PID, RS435I_PID, RS455_PID}) &&
(_device_capabilities & ir_filter_mask) == ir_filter_mask)
{
device_name += "F";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please search a way to replace it with a regex substitute, maybe it will look better :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A regex use was added.
But I can find optimal logic for changing the name.
How much include <regex> increase our .cpp file?

@Tamir91

Tamir91 commented Feb 9, 2023

Copy link
Copy Markdown
Contributor Author

We need to search all of the old device names, see if someone is the code used the specific camera name to add some logic. If so we need to add the new name as well C++ and python wrapper

Meanwhile, I didn't find any used device by name only using a device by a pid.
I will look for it later.

@Nir-Az

Nir-Az commented Feb 9, 2023

Copy link
Copy Markdown
Collaborator

Please rebase and solve conflicts

This branch has conflicts that must be resolved

@Nir-Az

Nir-Az commented Feb 9, 2023

Copy link
Copy Markdown
Collaborator

I don't see the new changes, please push

Comment thread src/ds/ds5/ds5-device.cpp Outdated
(_device_capabilities & ip65_mask) == ip65_mask)
{
device_name = device_name.substr(0, device_name.size() - 1);
device_name += "6";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The "F" is OK since it's the last character,
Here we replace so I wish for something more elegant..
Look at std::string function or std::regex variations
And like I said we are missing comments, hard to understand what is done here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added some comments and left commented lines of code with the purpose to understand what looks good for us.

@Tamir91
Tamir91 force-pushed the detect_new_products branch from 3c9f58a to 1f7fb3c Compare February 12, 2023 07:01
Comment thread src/ds/d400/d400-device.cpp Outdated
switch (cap)
{
case ds::d400_caps::CAP_IR_FILTER:
if (is_capability_supports(cap, cur_gvd_version))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No need to check it inside every case,
Lets take it out and only call update_device_name if it's true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The code is optimized.

Comment thread src/ds/d400/d400-device.cpp Outdated
if (is_capability_supports(cap, cur_gvd_version))
{
// device_name[device_name.size() - 1] = '6'; // Changing last digit name to "6" if device has IP65 standart.
std::regex vowel_re("D455");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What does vowel_re means?
Maybe better to use a more meaningful name

@Tamir91 Tamir91 Feb 12, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The variable was renamed to old_name

@Tamir91
Tamir91 marked this pull request as draft February 12, 2023 07:19
Comment thread src/ds/d400/d400-device.cpp Outdated
std::regex vowel_re("D455");
std::regex_replace(device_name, device_name.begin(), device_name.end(), vowel_re, "D456");
}
break;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please add a default case (always)
Here you can throw and say the required capability is not supported for name update (with adding the cap value)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The default case was added.
I implemented throw in the default case but can't find it in IDE after throwing an exception.
As a result, the viewer continues work after throwing an exception and NOT showing the device name.
Please advise, if we can leave it as is or improve it.

@Tamir91
Tamir91 marked this pull request as ready for review February 12, 2023 11:23
@Tamir91
Tamir91 force-pushed the detect_new_products branch from 3b3e0ef to 1f79659 Compare February 12, 2023 12:45
Comment thread src/ds/d400/d400-device.cpp Outdated
break;

default:
auto wrong_cap = ds::d400_capabilities_names.find(cap);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No need for all of this:

default:
    throw invalid_value_exception("capability '" + cap + "' is not supported for device name update");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

cap variable is not a string, so I can't connect it to another string.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

try this:

default:
    throw invalid_value_exception("capability '" + d400_capabilities_names.at( cap ) + "' is not supported for device name update");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, thank you! I will move forward with your suggestion!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will do next:
ds::d400_capabilities_names.find(cap)->second
Because d400_capabilities_names is a map.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ds::d400_capabilities_names.find(cap)->second this use can raise a null reference and crash the SW.
map api has .at() which will throw if the input is not inside the map, which is good for us.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right. The first time, IDE showed me a syntax error there.
Now it's OK, something flaky.

Comment thread src/ds/d400/d400-device.cpp Outdated
break;

case ds::d400_caps::CAP_IP65:
device_name = std::regex_replace(device_name, old_name_reg, "D456"); // Change device name from D455 to D456.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Notice you have alignment issues on several lines here.
Please use 'clang-format', (if you don't know how ask..)

@Tamir91 Tamir91 Feb 12, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

May you send me a link to read about clang-format?
Because I found something but I think that is not was you meant.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sent

Comment thread src/ds/d400/d400-device.cpp Outdated
break;

case ds::d400_caps::CAP_IP65:
device_name = std::regex_replace(device_name, old_name_reg, "D456"); // Change device name from D455 to D456.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we remove line 1109 and place here:

device_name = std::regex_replace(device_name, std::regex("D455"), "D456"); // Change device name from D455 to D456.

?
The parameter at line 1109 is only relevant on this case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are absolutely right. I tried your solution and VS marked it like an error, so full of pain I moved it out of "switch".
But now it worked. It happens the second time. Maybe delay in IDE.
Changed according to your suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants