Skip to content

Fix config resolution issue on initial T265 plug in - #4506

Closed
pietroglyph wants to merge 2 commits into
realsenseai:developmentfrom
pietroglyph:development
Closed

pietroglyph wants to merge 2 commits into
realsenseai:developmentfrom
pietroglyph:development

Conversation

@pietroglyph

Copy link
Copy Markdown

If you plug in your T265 camera and run the following code you will get a "No device connected" exception:

#include <librealsense2/rs.hpp>

int main()
{
    auto pipeline = rs2::pipeline();
    auto config = rs2::config();
    config.enable_stream(RS2_STREAM_POSE, RS2_FORMAT_6DOF);
    config.resolve(pipeline); // "No device connected exception" gets thrown from here
}

The program will work fine on all subsequent runs until you disconnect and reconnect the T265 camera. If you attempt to add code to retry the config.resolve step you will still encounter this failure.

This bug was consistently reproducible on librealsense v2.24.0 on my system (Linux 5.1.16-200.fc29.x86_64) and another more exotic (and unsupported) armv7 system I am cross compiling to.

After some light debugging it became clear that you could resolve your config on the initial plug in of the T265 if you had already started streaming from a rs2::pipeline. Further inspection of the librealsense source made it clear that rs2::pipeline::start and rs2::config::resolve were calling the internal librealsense::pipeline::config::resolve method in all the same ways, except that rs2::pipeline::start (i.e. one that worked) called resolve with a 5 second timeout and would retry 3 times.

That meant that the most minimal fix was copying the retry code to rs2_config_resolve. That is what is included in this PR.

Another less minimal fix that I would be happy to submit instead would be to factor all the retrying code into librealsense::pipeline::config::resolve, and always use a timeout of 5 seconds. This may be better because a) it reduces code duplication, and b) it means that you can no longer call librealsense::pipeline::config::resolve in a buggy way. You can preview this change here.

Let me know if you have any questions or comments, and please review the two possible fixes and indicate which you would prefer I submit. (Note that all of the options to fix this that I've presented still don't fix the root of this issue; it may be more appropriate to fix this at a lower level instead of propagating the retry hack included in this PR.)

Thanks!

@ev-mp

ev-mp commented Jul 29, 2019

Copy link
Copy Markdown
Contributor

@pietroglyph , thanks for the proposal but there is already a work undertaken by @orshefi #4302 that should address the root cause of non-deterministic T265 connections.
That work will better serve in the long run than the proposed work-around

@radfordi

Copy link
Copy Markdown
Contributor

Why doesn't the result of resolve get re-used by start, instead of trying to resolve again?

@ev-mp

ev-mp commented Sep 2, 2019

Copy link
Copy Markdown
Contributor

Why doesn't the result of resolve get re-used by start, instead of trying to resolve again?

The resolve method tests whether a device that will suffice the required streams is available but does not acquire an exclusive lock for it.
Potentially, after calling resolve some other user code/thread may start streaming with that device, so passing the results obtained by resolve to the pipe's initialization might not be safe.

@radfordi

Copy link
Copy Markdown
Contributor

This should be fixed by #5213.

@radfordi radfordi closed this Jan 21, 2020
@zbynekwinkler

Copy link
Copy Markdown
$ rs-enumerate-devices --version

rs-enumerate-devices  version: 2.32.1

$ rs-enumerate-devices -d
Device info: 
    Name                          : 	Intel RealSense T265
    Serial Number                 : 	0000929122110084
    Firmware Version              : 	0.2.0.926
    Physical Port                 : 	2-1-17
    Product Id                    : 	0B37
    Usb Type Descriptor           : 	3.1
    Product Line                  : 	T200

Default streams:
RealSense error calling rs2_config_resolve(config:0x56340e8e1040, pipe:0x56340e8e64a0):
    No device connected

AFAIU #5213 is part of 2.32.1 release but the problem with resolve is still present.
https://github.com/IntelRealSense/librealsense/blob/83f952a4bd6b70d72459f66c7f67ddaba9d337a0/tools/enumerate-devices/rs-enumerate-devices.cpp#L268-L272

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.

4 participants