Is there any way to programatically reset a device that is in a "XLINKSUCCESS" state?
I'm working on a C++ app that is supposed to be connecting to two or more OAK-D-POE cameras. I want to make sure that it is able to reconnect to cameras if there is some kind of error or network disruption.
I have a loop that looks like this which runs every 5 seconds to initialize any uninitialized cameras, though I find that sometimes if a camera connection does get disrupted or the node restarts in an unexpected manner, the cameras are stuck in X_LINK_SUCCESS state, and I am unable to connect to them. Is there any way I can force a reboot of the cameras from before the connection phase? What could possibly be causing them to be stuck in X_LINK_SUCCESS?
Thanks
auto deviceInfoVec = dai::Device::getAllConnectedDevices();
...
void connectToNewDevices(const std::vector<dai::DeviceInfo> &deviceInfoVec)
{
for (auto &dev : deviceInfoVec)
{
if (dev.state == X_LINK_UNBOOTED || dev.state == X_LINK_BOOTLOADER)
{
// Check if this device is in our configuration
for (auto &config : cam_configs_)
{
if ((dev.protocol == XLinkProtocol_t::X_LINK_TCP_IP && dev.name == config.ip) ||
(dev.protocol == XLinkProtocol_t::X_LINK_USB_VSC && config.ip.empty()))
{
std::string cam_name = config.name;
if (cams_.find(cam_name) == cams_.end()) // Check if camera object doesn't exist
{
ROS_INFO_STREAM("Found new device: " << cam_name);
try
{
auto cam = std::make_unique<Camera>(*nh_, cam_name, config.device, config.profile, config.ip);
if (!cam->connect(dev))
{
ROS_ERROR_STREAM("Couldn't connect to camera: " << dev.name);
}
else
{
cams_[cam_name] = std::move(cam);
}
}
catch (const std::exception &e)
{
ROS_ERROR_STREAM("Could not create camera: " << cam_name << ". " << e.what());
}
}
}
}
}
}
}