24 #include <Base/Common/W32Compat.hh>
25 #include <Geometry/Pose.hh>
26 #include <Base/Common/CompareFloatingPoint.hh>
27 #include <Base/Geometry/PoseParametrizationCovariance.hh>
31 #define POSE_STREAM_PRECISION 12
51 for (
unsigned int row = 0; row < 3; row++)
53 for (
unsigned int col = 0; col < 3; col++)
55 ret[row][col] = Cov_[row][col];
65 for (
unsigned int row = 0; row < 4; row++)
67 for (
unsigned int col = 0; col < 4; col++)
69 ret[row][col] = Cov_[row + 3][col + 3];
93 for (
unsigned int i = 0; i < 3; i++)
95 for (
unsigned int j = 0; j < 3; j++)
97 Cov_[i][j] = cov[i][j];
106 for (
unsigned int row = 0; row < 4; row++)
108 for (
unsigned int col = 0; col < 4; col++)
110 Cov_[row + 3][col + 3] = cov[row][col];
127 BIASERR(
"Euclidean Pose Covariance has to be 7x7");
132 BIASERR(
"Not implemented!!");
161 BIASERR(
"Pose Covariance has to be 7x7");
168 bool defaultcov =
false;
170 for (
unsigned int x = 0; x < 7; x++)
172 for (
unsigned int y = 0; y < 7; y++)
174 if (BIAS_ISNAN(Cov_[y][x]) || BIAS_ISINF(Cov_[y][x]))
177 BIASERR(
"Invalid covariance matrix set in pose: " << Cov_);
205 ifstream ifs(inputFile.c_str());
224 ofstream ofs(outputFile.c_str());
239 #ifdef BIAS_HAVE_XML2
244 TopLevelTag =
"Pose";
254 std::ostringstream values;
255 xmlNodePtr childNode = XMLObject.
addChildNode(Node,
"Rotation");
256 values << std::setprecision(POSE_STREAM_PRECISION);
257 for (
unsigned int i = 0; i < 4; i++)
258 values << (
double) Q_.GetData()[i] <<
" ";
259 XMLObject.
addContent(childNode, values.str());
264 std::ostringstream values;
265 xmlNodePtr childNode = XMLObject.
addChildNode(Node,
"Position");
266 values << std::setprecision(POSE_STREAM_PRECISION);
267 for (
unsigned int i = 0; i < 3; i++)
268 values << (
double) C_.GetData()[i] <<
" ";
269 XMLObject.
addContent(childNode, values.str());
275 std::ostringstream values;
276 xmlNodePtr childNode = XMLObject.
addChildNode(Node,
"Covariance");
277 values << std::setprecision(POSE_STREAM_PRECISION);
278 for (
unsigned int i = 0; i < 49; i++)
279 values << (
double) Cov_.GetData()[i] <<
" ";
280 XMLObject.
addContent(childNode, values.str());
293 for (
unsigned int i = 0; i < 3; i++) values >> C_.GetData()[i];
300 for (
unsigned int i = 0; i < 4; i++) values >> Q_.GetData()[i];
307 for (
unsigned int i = 0; i < 49; i++) values >> Cov_.GetData()[i];
326 this->Set(intermediate.
GetQ(), intermediate.
GetC());
virtual int XMLOut(const xmlNodePtr Node, BIAS::XMLIO &XMLObject) const
Specialization of XML write function.
int Set(const PoseParametrization &pose)
Set pose from pose parametrization.
virtual int XMLGetClassName(std::string &TopLevelTag, double &Version) const
Specialization of XML block name function.
void SetCovarianceMatrix(const Matrix< PP_TYPE > &Cov)
Sets covariance matrix from Cov.
bool Save(const std::string &outputFile)
Write pose transformation to a text file using operator <<.
bool Load(const std::string &inputFile)
Load pose transformation from a text file using operator >>.
void SetC(const Vector3< POSE_TYPE > &C, const Matrix3x3< POSE_TYPE > &cov)
Set translation (resp.
Vector3< double > GetZAxis() const
Vector3< double > GetXAxis() const
Slim class bundeling pose parametrization and associated covariance matrix.
void SetQ(const Quaternion< POSE_TYPE > &Q, const Matrix4x4< POSE_TYPE > &cov)
Set rotation (resp.
int SetCovEuclidean(Matrix< POSE_TYPE > Cov)
Set covariance matrix explicitely from an Euclidean covariance matrix, i.e.
std::string getAttributeValueString(const xmlAttrPtr Attribute) const
void addContent(const xmlNodePtr Node, const std::string &Content)
Add content to a node.
Wrapper class for reading and writing XML files based on the XML library libxml2. ...
const Matrix< PP_TYPE > & GetCovarianceMatrix() const
returns the covariance matrix associated with the CQ vector
unsigned int GetRows() const
Pose()
Default constructor creates identity pose transformation.
xmlNodePtr addChildNode(const xmlNodePtr ParentNode, const std::string &NewNodeName)
Add a child node to an incoming node with the given name.
Matrix3x3< POSE_TYPE > GetCovC() const
Return the 3x3 covariance matrix Cov(C) of the translation part C of this pose transformation.
void SetPosition(const Vector3< PP_TYPE > &C)
set position part of vector and zero covariance matrix
int SetCovariance(const Matrix< POSE_TYPE > &c)
Set covariance matrix explicitely from 7x7 matrix Cov([C Q]).
is a 'fixed size' quadratic matrix of dim.
void TransformToNewGlobalBy(const CoordinateTransform3D &trsf)
Transforms the position and orientation stored in this pose into another global coordinate system...
PoseParametrization GetPoseParameters() const
Get pose parametrization representing this pose.
virtual int XMLIn(const xmlNodePtr Node, BIAS::XMLIO &XMLObject)
Specialization of XML read function.
class Vector3 contains a Vector of fixed dim.
Vector3< PP_TYPE > GetPosition() const
returns the position (first 3 entries) part of the pose parametrization vector
xmlAttrPtr getAttributeByName(const xmlNodePtr Node, const std::string &attribute_name)
search for a specific attribute
unsigned int GetCols() const
void SetOrientation(const Quaternion< PP_TYPE > &q)
set orientation part of vector and zero covariance matrix
Vector3< double > GetYAxis() const
Implements a 3D rotation matrix.
class encapsulating the transfromations between different pose parametrizations
is a 'fixed size' quadratic matrix of dim.
Matrix4x4< POSE_TYPE > GetCovQ() const
Return the 4x4 covariance matrix Cov(Q) of the rotational part of this pose transformation described ...
void Transform(const Matrix4x4< double > &transf)
Given a 6D pose (position and euler angles) and its associated covariance, the function transforms th...
class for rotation with axis and angle
Quaternion< PP_TYPE > GetOrientation() const
returns the quaternion (last 4 entries) part of the pose parametrization vector