17 #undef _UNICODE // JLBC, for xmlParser 28 VelodyneCalibration::PerLaserCalib::PerLaserCalib()
29 : azimuthCorrection(.0),
30 verticalCorrection(.0),
31 distanceCorrection(.0),
32 verticalOffsetCorrection(.0),
33 horizontalOffsetCorrection(.0),
34 sinVertCorrection(.0),
35 cosVertCorrection(1.0),
36 sinVertOffsetCorrection(.0),
37 cosVertOffsetCorrection(1.0)
48 throw std::runtime_error(
"Cannot find XML node: 'boost_serialization'");
52 throw std::runtime_error(
"Cannot find XML node: 'DB'");
56 throw std::runtime_error(
"Cannot find XML node: 'enabled_'");
62 if (node_enabled_count.
isEmpty())
63 throw std::runtime_error(
"Cannot find XML node: 'enabled_::count'");
64 const int nEnabled = atoi(node_enabled_count.
getText());
65 if (nEnabled <= 0 || nEnabled > 10000)
66 throw std::runtime_error(
67 "Senseless value found reading 'enabled_::count'");
70 for (
int i = 0; i < nEnabled; i++)
74 throw std::runtime_error(
75 "Cannot find the expected number of XML nodes: " 77 const int enable_val = atoi(node_enabled_ith.
getText());
78 if (enable_val) ++enabledCount;
86 throw std::runtime_error(
"Cannot find XML node: 'points_'");
91 if (node_points_item.
isEmpty())
break;
95 throw std::runtime_error(
96 "Cannot find XML node: 'points_::item::px'");
100 throw std::runtime_error(
101 "Cannot find XML node: 'points_::item::px::id_'");
102 const int id = atoi(node_px_id.
getText());
104 if (
id >= enabledCount)
continue;
111 throw std::runtime_error(
112 "Cannot find XML node: " 113 "'points_::item::px::rotCorrection_'");
119 throw std::runtime_error(
120 "Cannot find XML node: " 121 "'points_::item::px::vertCorrection_'");
127 throw std::runtime_error(
128 "Cannot find XML node: " 129 "'points_::item::px::distCorrection_'");
135 throw std::runtime_error(
136 "Cannot find XML node: " 137 "'points_::item::px::vertOffsetCorrection_'");
143 throw std::runtime_error(
144 "Cannot find XML node: " 145 "'points_::item::px::horizOffsetCorrection_'");
173 cerr <<
"[VelodyneCalibration::loadFromXMLText] Error parsing XML " 184 cerr <<
"[VelodyneCalibration::loadFromXMLFile] Exception:" << endl
194 const std::string& velodyne_calibration_xml_filename)
200 velodyne_calibration_xml_filename.c_str(),
nullptr, &results);
204 cerr <<
"[VelodyneCalibration::loadFromXMLFile] Error loading XML " 214 cerr <<
"[VelodyneCalibration::loadFromXMLFile] Exception:" << endl
237 if (lidar_model ==
"VLP16")
239 else if (lidar_model ==
"HDL32")
245 if (!xml_contents.empty())
247 if (!result.loadFromXMLText(xml_contents))
248 std::cerr <<
"[VelodyneCalibration::LoadDefaultCalibration] Error " 249 "parsing default XML calibration file for model '" 250 << lidar_model <<
"'\n";
Velodyne calibration data, for usage in mrpt::obs::CObservationVelodyneScan.
const char * velodyne_default_calib_HDL32
bool loadFromXMLFile(const std::string &velodyne_calibration_xml_filename)
Loads calibration from file, in the format supplied by the manufacturer.
double verticalOffsetCorrection
bool loadFromXMLText(const std::string &xml_file_contents)
Loads calibration from a string containing an entire XML calibration file.
double DEG2RAD(const double x)
Degrees to radians.
Main Class representing a XML node.
VelodyneCalibration()
Default ctor (leaves all empty)
static XMLNode parseString(XMLCSTR lpXMLString, XMLCSTR tag=nullptr, XMLResults *pResults=nullptr)
Parse an XML string and return the root of a XMLNode tree representing the string.
void clear()
Clear all previous contents.
char isEmpty() const
is this node Empty?
const Scalar * const_iterator
bool internal_loadFromXMLNode(void *node)
static XMLCSTR getError(XMLError error)
this gives you a
XMLCSTR getText(int i=0) const
return ith text field
std::vector< PerLaserCalib > laser_corrections
This namespace contains representation of robot actions and observations.
GLsizei const GLchar ** string
std::map< std::string, VelodyneCalibration > cache_default_calibs
static XMLNode parseFile(XMLCSTR filename, XMLCSTR tag=nullptr, XMLResults *pResults=nullptr)
Parse an XML file and return the root of a XMLNode tree representing the file.
#define ASSERT_ABOVEEQ_(__A, __B)
double sinVertOffsetCorrection
bool empty() const
Returns true if no calibration has been loaded yet.
double distanceCorrection
double verticalCorrection
double horizontalOffsetCorrection
double cosVertOffsetCorrection
const char * velodyne_default_calib_VLP16
static const VelodyneCalibration & LoadDefaultCalibration(const std::string &lidar_model)
Loads default calibration files for common LIDAR models.
Structure used to obtain error details if the parse fails.
XMLNode getChildNode(int i=0) const
return ith child node