19 nxLibInitialize(
true);
21 catch (NxLibException& e)
23 NODELET_ERROR(
"Error while initializing the NxLib. Shutting down.");
28 if (nhLocal.
getParam(
"threads", threads))
30 NxLibItem()[itmParameters][itmThreads] = threads;
33 std::string serial, fileCameraPath, cameraFrame, targetFrame, linkFrame;
36 if (!nhLocal.
getParam(
"serial", serial))
41 if (nhLocal.
getParam(
"serial", intSerial))
43 serial = std::to_string(intSerial);
50 NxLibItem cameraNode = NxLibItem()[itmCameras][itmBySerialNo][serial];
51 if (!cameraNode.exists())
53 NODELET_WARN(
"The serial of the camera has been too long and was interpreted as an 32-bit integer and exceeds " 54 "its length. Please append a \"!\" to the number. E.g. \'_serial:=1234567\' to " 55 "\'_serial:=1234567!\', so it can be interpreted as a numerical string. If you are using a launch " 56 "file, just define the parameter's type as string, e.g.: type=\"string\".");
64 std::size_t found = serial.find(
'!');
65 if (found != std::string::npos)
72 NxLibItem cameras = NxLibItem()[itmCameras][itmBySerialNo];
74 bool foundAppropriateCamera =
false;
75 for (
int i = 0; i < cameras.count(); i++)
77 if (cameras[i][itmType].
exists() && cameras[i][itmType].asString() == valMonocular)
79 foundAppropriateCamera =
true;
80 serial = cameras[i].name();
84 if (!foundAppropriateCamera)
92 nhLocal.
param<std::string>(
"file_camera_path", fileCameraPath,
"");
96 if (fileCameraPath.empty())
98 std::string type = NxLibItem()[itmCameras][itmBySerialNo][serial][itmType].asString();
99 std::string
const neededType = valMonocular;
100 if (type != neededType)
102 NODELET_ERROR(
"The camera to be opened is of the wrong type %s. It should be %s.", type.c_str(),
109 nhLocal.
param(
"fixed", cameraIsFixed,
false);
111 if (!nhLocal.
getParam(
"camera_frame", cameraFrame))
113 cameraFrame = serial +
"_optical_frame";
116 nhLocal.
getParam(
"target_frame", targetFrame);
117 nhLocal.
getParam(
"link_frame", linkFrame);
118 if (!targetFrame.empty() && linkFrame.empty())
120 linkFrame = targetFrame;
122 else if (targetFrame.empty() && linkFrame.empty())
124 targetFrame = cameraFrame;
125 linkFrame = cameraFrame;
128 camera = ::make_unique<MonoCamera>(nh, serial, fileCameraPath, cameraIsFixed, cameraFrame, targetFrame, linkFrame);
136 std::string settingsFile;
137 if (nhLocal.
getParam(
"settings", settingsFile))
140 if (!
camera->loadSettings(settingsFile,
true))
142 NODELET_ERROR(
"Failed to load the camera settings. Shutting down.");
149 camera->initTfPublishTimer();
#define NODELET_ERROR(...)
#define NODELET_WARN(...)
PLUGINLIB_EXPORT_CLASS(BAGReader, nodelet::Nodelet)
ros::NodeHandle & getPrivateNodeHandle() const
std::unique_ptr< MonoCamera > camera
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
ros::NodeHandle & getNodeHandle() const
bool getParam(const std::string &key, std::string &s) const
ROSCPP_DECL bool exists(const std::string &service_name, bool print_failure_reason)
#define NODELET_DEBUG(...)