Items with no label
3335 Discussions

D435 streams work once, then crash

VShen3
Beginner
7,359 Views

I have a D435 camera running the newest firmware.

Upon plugging it in, the camera works with any application (including all the examples, my own code, or the realsense viewer). However, if I stop the stream and start it again, it doesn't work for anything. Realsense-viewer gives me a "Frames not Recieved" error, and the only way I can fix it is by manually doing a hardware reset on the realsense-viewer, or unplugging/plugging it back in. I am NOT using ROS, so the ROS wrapper fixes do not help. (Note: I do not know how to do a hardware reset in C++, so if someone could tell me that would also be very helpful)

So far I've tried:

  • an externally powered USB 3.0 hub to connects the realsense to the computer.
  • installing far more powerful memory chips
  • I've tried every single USB 3.0 hub on my computer (which probably isn't the problem anyways, since the streams always work the first time after I replug it in)
  • waiting a while, then trying to use the camera again (still doesn't work)

Any clue what the issue might be? It makes it really tedious to run my script since I keep having to unplug the camera. Please let me know if you need any other information, and thanks in advance!

0 Kudos
8 Replies
MartyG
Honored Contributor III
4,026 Views

As you suggested, a hardware reset instruction placed at the start of a script can fix the problem of a camera needing reset via USB unplug-replug. The instruction for this hardware_reset()

Example:

rs2::device dev = device_you_are_using();

dev.hardware_reset(); //Will disconnect the camera and reconnect it.

//NOTE: All camera settings will be restored to default after this call (same as unplug->plug)

//Don't use device after this line

https://github.com/IntelRealSense/librealsense/issues/1086 Frames didn't arrive error - after improper shutdown · Issue # 1086 · IntelRealSense/librealsense · GitHub

0 Kudos
VShen3
Beginner
4,026 Views

It isn't recognizing the command "device_you_are_using();" ("not declared in this scope"). Am I supposed to be importing something other than the standard ?

0 Kudos
MartyG
Honored Contributor III
4,026 Views

I think the person suggesting that code was just suggesting people put their own device ID in.

Further down that page is an alternative version that looks for any connected camera.

rs2::context ctx;

rs2::device dev = get_device_from_context(ctx);

dev.hardware_reset();

rs2::device_hub hub(ctx);

dev = hub.wait_for_device(); //Note that device hub will get any device, if you have more than 1 connected it could return the other device

0 Kudos
VShen3
Beginner
4,026 Views

Similiary, "get_device_from_context" returns a "not declared in this scope" error. Am I still not importing something that I should be?

Thank you for all your help!

0 Kudos
MartyG
Honored Contributor III
4,026 Views

The documentation on the hardware_reset() function is very slim. I would suggest pasting the line below into your script somewhere, and if that doesn't work then to open a new Issue on the Librealsense GitHub to ask the Intel programming experts there how to implement it.

void rs2::device::hardware_reset ( )

0 Kudos
idata
Employee
4,026 Views

What is your computer platform and operating system?

0 Kudos
WTatt
New Contributor I
4,026 Views

Below is some sample code we used when we were testing and debugging this same issue.

If explains how the realsense context works - and how to iterate over all the current devices.

It also shows a mechanism for resetting a found intel device - and a mechanism to wait for the hardware to finishing resetting before continuing

Cheers

 

Westa

/////////////////////////////////////////////////////////////////////////////////////////////////////

// define a realsense context

std::cout << "Initialising realsense context" << std::endl;

rs2::context rs2Ctx;

rs2::device rs2Dev;

resettingIntelRealsense = 0;

resetCompleteIntelRealsense = 0;

int gotDev = 0;

// Define a callback mechanism - to detect when the sensor has been reset

rs2Ctx.set_devices_changed_callback([&](rs2::event_information& info)

{

// loop thru all new devices - that is one that has been reset effectively

for (auto&& dev : info.get_new_devices())

{

std::string devName = "";

std::string devSerialNumber = "";

std::string devFirmware = "";

std::string devProdId = "";

devProdId = dev.get_info(RS2_CAMERA_INFO_PRODUCT_ID);

devSerialNumber = dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER);

devName = dev.get_info(RS2_CAMERA_INFO_NAME);

if (devName == "Intel RealSense D415")

{

devFirmware = dev.get_info(RS2_CAMERA_INFO_FIRMWARE_VERSION);

}

if (devName == "Intel RealSense D435")

{

devFirmware = dev.get_info(RS2_CAMERA_INFO_FIRMWARE_VERSION);

}

std::cout << "RESET Dev: " << devName << " Ser: " << devSerialNumber << " Firmware: " << devFirmware << " ProdID " << devProdId << std::endl;

resetCompleteIntelRealsense = 1;

}

});

// interate thru the intel device context looking for intel sensors

// note that other devices like webcams can appear here too depending on their device type

for (auto&& dev : rs2Ctx.query_devices()) // Query the list of connected RealSense devices

{

std::string devName = "";

std::string devSerialNumber = "";

std::string devFirmware = "";

std::string devProdId = "";

devProdId = dev.get_info(RS2_CAMERA_INFO_PRODUCT_ID);

devSerialNumber = dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER);

devName = dev.get_info(RS2_CAMERA_INFO_NAME);

if (gotDev == 0 && (devName == "Intel RealSense D415" || devName == "Intel RealSense D435"))

{

devFirmware = dev.get_info(RS2_CAMERA_INFO_FIRMWARE_VERSION);

// assume there is only one intel camera for now

// save the device for future use

rs2Dev = dev;

gotDev = 1;

}

std::cout << "System Dev: " << devName << " Ser: " << devSerialNumber << " Firmware: " << devFirmware << " ProdID " << devProdId << std::endl;

}

////////////////////////////////////////////////////////////////

// if we have found a realsense sensor - force initialise it if required

if (gotDev == 1)

{

// reset the hardware device found during initial iteration thru context

rs2Dev.hardware_reset();

// wait for hardware to reset reset

resetCompleteIntelRealsense = 0;

int rs2WaitForReset = 1;

// pause until device is reset - not elegant but will do for testing

while (resetCompleteIntelRealsense == 0 && rs2WaitForReset < 9999999999)

{

rs2WaitForReset++;

}

}

if (gotDev == 0)

{

std::cout << "No Intel Realsense devices detected" << std::endl;

}

0 Kudos
mbar
Beginner
4,026 Views

did you menage to solve this problem?

im having the same problem

and i'm not sure where should i put this part of code. on which file? where?

0 Kudos
Reply