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

Set present mode using Matlab wrapper #9839

Closed
aramir28 opened this issue Oct 8, 2021 · 9 comments
Closed

Set present mode using Matlab wrapper #9839

aramir28 opened this issue Oct 8, 2021 · 9 comments

Comments

@aramir28
Copy link

aramir28 commented Oct 8, 2021


Required Info
Camera Model L515
Firmware Version 01.05.08.01
Operating System & Version Win (10)
Platform PC
SDK Version 2.47.0 .3309
Language Matlab

Unable to set the visual preset mode using Matlab on an L515 depth camera

While trying to set the general configuration for data acquisition using Matlab, I haven't been able to use the options class correctly.

So far, I've tried the idea from https://support.intelrealsense.com/hc/en-us/community/posts/360038122553-how-do-I-set-rs2-options-in-the-python-examples-

option = realsense.option.visual_preset
preset = realsense.l500_visual_preset.short_range
depth_sensor = depth_sensor.set_option(option, preset)

but this returns the error: _"Unable to resolve the name realsense.l500_visual_preset.short_range."

I also tried the idea in https://github.com/IntelRealSense/librealsense/issues/1011
depth_sensor = profile.get_device();
depth_sensor.set_option(option, preset)
and in this case the error reads "Unrecognized method, property, or field 'set_option' for class 'realsense.device'."

What is the correct way to use the options class while using Matlab?

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Oct 8, 2021

Hi @aramir28 Whilst I do not have a pre-made script for setting this preset in the RealSense MATLAB wrapper, I did handle a case
in #9071 where this preset was being set up for C++. MATLAB wrapper code is almost 1:1 with C++ and so the scripting example provided within that discussion in #9071 (comment) may be more helpful than the Python reference.

An alternative approach would be to configure settings in the RealSense Viewer that are comparable to the Short Range preset and then export the settings in the Viewer as your own custom json file using the json export button on the toolbar near the top of the Viewer's options side-panel. You could then load that custom json file into the MATLAB wrapper using the MATLAB script provided in #5236 - 'json' is another name for a Visual Preset file.

The easiest way to configure the Viewer to match the Short Range preset would be simply to select 'Short Range' from the preset drop-down as the settings in the Viewer will automatically update to those of the Short Range preset. Those settings can then be exported in your own json file.

image

@aramir28
Copy link
Author

aramir28 commented Oct 8, 2021

I have exported the preset and try using the example from #5236 as:

ctx = realsense.context();
devs = ctx.query_devices();
dev = devs{1};
adv = dev.as('advanced_mode');
adv.load_json('ShortRangePreset.json');

and I get the following error: "Error using librealsense_mex null pointer passed for argument "dev"

It seems I have used "adv.load_json(json_string);" incorrectly. What should I change?

Also, Where should I place the .json file? Inside the +realsense folder?

@MartyG-RealSense
Copy link
Collaborator

The MATLAB wrapper's advanced_mode_example.m example script provides an example of setting up Advanced Mode in the wrapper and defining json_string.

https://github.com/IntelRealSense/librealsense/blob/master/wrappers/matlab/advanced_mode_example.m

In regard to the location to place the custom json: I am not certain of this. Putting it in the same folder that your MATLAB program script is in would be a logical location to try though.

@aramir28
Copy link
Author

aramir28 commented Oct 9, 2021

if I use that example script, I get this error

Error using realsense.advanced_mode_example (line 10)
Device doesn't support advanced mode!

Somebody commented in 7182#issuecomment that this camera model does not support Advanced Mode interface. However, It seems that there is a workaround for the python wrapper as shown in 6902

Any suggestion about how to get it to work in MATLAB?

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Oct 9, 2021

I researched the subject extensively but was unfortunately able to find a solution to getting around a lack of Advanced Mode on L515 when using the MATLAB wrapper.

A workaround that I considered may be to replicate some of the main effects of loading the Short Range preset by instead using set_option to configure the values of the Laser Power and Receiver Gain settings of the camera. Two key effects of the Short Range preset is that it sets Laser Power to '93' (default 100) and Receiver Gain to '18' (default 9).

In #3358 (comment) a RealSense team member provides an example of MATLAB code for setting an option value with set_option.

profile = pipe.start();
dev = profile.get_device();
d_sensor = dev.first('depth_sensor');
disp(d_sensor.is('depth_sensor'));
if d_sensor.supports_option(optionemitter_enabled)
d_sensor.set_option(option.emitter_enabled, <_**0 OR 1**_>);
end

Please note that in the line if d_sensor.supports_option(optionemitter_enabled) there is an apparent typo, where optionemitter_enabled should be option.emitter_enabled

The link below has a list of options settings in the MATLAB wrapper that could be substituted into the above code in place of emitter_enabled

https://github.com/IntelRealSense/librealsense/blob/master/wrappers/matlab/option.m

I apologize that on this particular question I could not provide the desired answer.

@aramir28
Copy link
Author

What option correspond to Receiver Gain? I did not find an item with the same name in the link you provided. I only found gain, digital gain, and receiver_sensitivity.

Also, when trying

option = realsense.option.gain();
val = d_sensor.get_option(option)

I get the error

object doesn't support option # 4

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Oct 12, 2021

Do you mean that Receiver Gain is not listed in the option.m list of MATLAB wrapper settings, please? If so, I could not find a Receiver Gain configuration option either. How does the program perform if you only configure Laser Power?

@MartyG-RealSense
Copy link
Collaborator

Hi @aramir28 Do you require further assistance with this case, please? Thanks!

@MartyG-RealSense
Copy link
Collaborator

Case closed due to no further comments received.

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

No branches or pull requests

2 participants