-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Reset camera with unstable USB connection #8393
Comments
Hi @maltetoelle
That RealSense user also added the additional measure of a 5 second sleep period on the script line after initiating the hardware_reset in order to give the reset time to fully complete.
|
thank you very much for your answer!
I did, however, track the problem down further and believe found an option that is working. The problem appears, when I want to access my device_list: try:
dev = dev_list[0]
except RuntimeError:
print("Failed to set power state")
return It that fails, the hardware_reset will also fail. Why is that the case? Why does accessing the device_list (making an rs2::device from an rs2::device_list which was returned from rs2::context.querying_devices()) raise an error when the device was found beforehand? If I do that first I can set a I believe the segmentation fault appears, when I try to start the stream, when it was already running. Is that impossible? |
When I am writing code where there is a risk of an instruction being multi-triggered in a loop, I use the logic-statement approach to set up a system where the code inside an "If" statement is only allowed to activate if all logic conditions of the If statement are met. I create a secondary logic condition such as 'allowreset' and set the If statement up as something like this: If ('x' condition = true && allowreset = true) When allowreset is true, the conditions of the If statement are met and the code within is allowed to activate for the first time. The first line of that code sets allowreset to False. This prevents the If statement from having its conditions met when it loops round to the start of the If instruction to test whether its conditions can be met again, so the code inside the If block cannot multi-trigger. At some point (such as when reset has successfully completed), I set allowreset back to True so that the code inside the If block is able to be run again next time that a reset is required. When the code is activated, it again sets allowreset to False and prevents multi-triggering. Later, allowreset is set back to True. And so the cycle goes on. In regard to rs2::device_hub, I was unable to locate a reference to an equivalent instruction for Python. Occurrence of a Failed to set power state error may sometimes set up a situation where a complete reset of the camera through means other than hardware_reset() that is not dependent on camera detection to activate may be necessary (e.g a USB unplug-replug of the camera or a computer reboot). It is possible for a segmentation fault to occur after the stream has started. Below is an example link to such a case. The amount of time before the fault appears varies though. In past cases of checking if a stream has started, RealSense users have tried to catch an exception in order to detect it. This subject is discussed in regard to Python in the official Python documentation link below. |
Hi @maltetoelle Do you require further assistance with this case, please? Thanks! |
Excuse me for not answering that long, I tried the different approaches but I am still not totally happy with the result. If I get a depth_sensor, color_sensor = dev.query_sensors() which means the application just stops without throwing an error. When using the |
Some multicam programs that make use of a ctx device list set up their code to use the instruction rs2::device dev = list.front(); if no devices are currently detected in the list. Here is an example of such a routine: The script that uses the above code can be found at this link: |
Hi @maltetoelle Do you require further assistance with this case, please? Thanks! |
No, thank you very much! The problem is solved by checking if the list is empty. |
Great news @maltetoelle - thanks for the update! |
Issue Description
I am testing the reconnection capability of my Realsense camera in an environment with an instable USB connection. In order to simulate the connection issues I use two bash scripts/tools:
and usbreset. When using both the stream freezes. I fixed that by using a simple try and except blog for wait_for_frames:
and in the reset function a simple hardware_reset is called:
This works fine for resetting the whole USB controller in a loop and for resetting the camera after one usbreset. However, if the pauses between consecutive usbresets get too short, it fails. I believe this happens when a usbreset is called, while the camera is trying to reset itself with hardware_reset. I tried to tackle that issue first with a
try ... except
around the hardware_reset, but this just gives a segmentation faultIf I do not use the
try ... except
around the hardware_reset I get the following error:I also tried to
set_devices_changed_callback
andset_notifications_callback
but they were only triggered through the hardware_reset. This means, if the hardware_reset fails my program fails but this triggers the notifications callback with the notificationUSB SCP overflow
orUSB CAM overflow
.I do have a few questions now:
USB SCP/CAM overflow
occurs?The text was updated successfully, but these errors were encountered: