22 #include <ros_uri/ros_uri.hpp> 27 #include <boost/algorithm/string/predicate.hpp> 28 #include <boost/lexical_cast.hpp> 36 namespace fs = boost::filesystem;
40 const fs::path rvizMeshResourcePath,
41 const fs::path normalVectorResourcePath) :
42 mRecognizerPtr(recognizerPtr),
43 mUniqueName(uniqueName),
45 mRvizMeshResourcePath(rvizMeshResourcePath),
46 mNormalVectorResourcePath(normalVectorResourcePath),
52 const fs::path path,
const fs::path rvizMeshResourcePath,
53 const fs::path normalVectorResourcePath,
54 const fs::path deviation_resource_path,
62 rotation_invariance_resource_path(rotation_invariance_resource_path),
110 if (normalVectorFileHandle.is_open())
114 std::size_t startSearchPos = 0;
115 while (std::getline(normalVectorFileHandle, normalVectorString))
117 while (startSearchPos < normalVectorString.size())
119 std::size_t searchPos = normalVectorString.find(
';', startSearchPos);
120 if (searchPos == std::string::npos)
122 searchPos = normalVectorString.size();
126 std::string coordinateString = normalVectorString.substr(startSearchPos,
127 (searchPos - startSearchPos));
129 std::size_t startValueSearchPos = 0;
130 std::vector<double> coordinateStack;
131 while (startValueSearchPos < coordinateString.size())
133 std::size_t valueSearchPos = coordinateString.find(
',', startValueSearchPos);
134 if (valueSearchPos == std::string::npos)
136 valueSearchPos = coordinateString.size();
139 std::string valueString = coordinateString.substr(startValueSearchPos,
140 (valueSearchPos - startValueSearchPos));
143 double coordinateValue = boost::lexical_cast<
double>(valueString);
144 coordinateStack.push_back(coordinateValue);
146 startValueSearchPos = valueSearchPos + 1;
149 if (coordinateStack.size() != 3)
151 ROS_WARN(
"Ignoring a coordinate because there were not exactly three values given.");
156 geometry_msgs::Point normalVector;
157 normalVector.x = coordinateStack [0];
158 normalVector.y = coordinateStack [1];
159 normalVector.z = coordinateStack [2];
162 startSearchPos = searchPos + 1;
168 normalVectorFileHandle.close();
174 else if(fs::exists(this->
getPath()))
179 this->
getPath().
string() +
"/" +
200 if (deviation_file_handle.is_open())
205 unsigned int line_number = 0;
206 while (std::getline(deviation_file_handle, deviation_string))
210 if (boost::starts_with(deviation_string,
"#"))
214 deviations_.push_back(std::stod(deviation_string));
216 catch (
const std::invalid_argument& ia)
219 " in line " << line_number <<
": " << ia.what());
227 <<
"values for the deviation, but 6 are needed");
232 deviation_file_handle.close();
259 if (rotation_invariance_file_handle.is_open())
263 std::getline(rotation_invariance_file_handle, rotation_invariance_string);
267 rotation_invariance_file_handle.close();
fs::path mRvizMeshResourcePath
fs::path mNormalVectorResourcePath
const fs::path getRvizMeshResourcePath()
ROS_DEPRECATED ObjectDatabaseEntry(ObjectDatabaseRecognizer *recognizerPtr, const std::string uniqueName, const fs::path path, const fs::path rvizMeshResourcePath, const fs::path normalVectorResourcePath)
static std::vector< geometry_msgs::Point > getNormalVectors(double angle_x, double angle_y, double angle_z, const std::string &savePath=std::string())
std::vector< double > deviations_
std::vector< geometry_msgs::Point > getNormalVectors()
fs::path getRotationInvarianceResourcePath() const
std::vector< double > getDeviationsFromFile()
ObjectDatabaseRecognizer * getRecognizer()
fs::path getDeviationResourcePath() const
fs::path rotation_invariance_resource_path
::xsd::cxx::tree::string< char, simple_type > string
#define ROS_INFO_STREAM(args)
ObjectDatabaseRecognizer * mRecognizerPtr
const bool getRotationInvarianceFromFile()
#define ROS_ERROR_STREAM(args)
const fs::path getNormalVectorResourcePath()
fs::path deviation_resource_path_
std::vector< geometry_msgs::Point > mNormalVectors
const std::string getUniqueName()