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

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

Merged
merged 5 commits into from
Feb 16, 2023

Conversation

Tamir91
Copy link
Contributor

@Tamir91 Tamir91 commented Feb 5, 2023

Tracked on [LRS-657]

@Tamir91 Tamir91 requested a review from Nir-Az February 7, 2023 14:53
camera_fw_version_offset = 12,
is_camera_locked_offset = 25,
module_serial_offset = 48,
module_asic_serial_offset = 64,
fisheye_sensor_lb = 112,
fisheye_sensor_hb = 113,
imu_acc_chip_id = 124,
ip65_sealed_offset = 161,
filter_sensor_offset = 164,
Copy link
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
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

Copy link
Contributor Author

@Tamir91 Tamir91 Feb 8, 2023

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
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
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -692,6 +695,27 @@ namespace librealsense
std::make_shared<thermal_compensation>(_thermal_monitor,thermal_compensation_toggle));
}

auto const CUR_GVD_VERSION = gvd_buff[gvd_version_offset];
auto const MIN_GVD_VERSION = 0x4;
Copy link
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
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
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
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
Copy link
Collaborator

Nir-Az commented Feb 8, 2023

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

val_in_range(_pid, {RS435_RGB_PID, RS435I_PID, RS455_PID}) &&
(_device_capabilities & ir_filter_mask) == ir_filter_mask)
{
device_name += "F";
Copy link
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
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
Copy link
Contributor Author

Tamir91 commented Feb 9, 2023

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
Copy link
Collaborator

Nir-Az commented Feb 9, 2023

Please rebase and solve conflicts

This branch has conflicts that must be resolved

@Nir-Az
Copy link
Collaborator

Nir-Az commented Feb 9, 2023

I don't see the new changes, please push

(_device_capabilities & ip65_mask) == ip65_mask)
{
device_name = device_name.substr(0, device_name.size() - 1);
device_name += "6";
Copy link
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
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
switch (cap)
{
case ds::d400_caps::CAP_IR_FILTER:
if (is_capability_supports(cap, cur_gvd_version))
Copy link
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
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.

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
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

Copy link
Contributor Author

@Tamir91 Tamir91 Feb 12, 2023

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
std::regex vowel_re("D455");
std::regex_replace(device_name, device_name.begin(), device_name.end(), vowel_re, "D456");
}
break;
Copy link
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
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
break;

default:
auto wrong_cap = ds::d400_capabilities_names.find(cap);
Copy link
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
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
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
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
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
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
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.

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
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..)

Copy link
Contributor Author

@Tamir91 Tamir91 Feb 12, 2023

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
Collaborator

Choose a reason for hiding this comment

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

Sent

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
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
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.

@Nir-Az Nir-Az merged commit 14669fd into IntelRealSense:development Feb 16, 2023
@Tamir91 Tamir91 deleted the detect_new_products branch February 26, 2023 09:29
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