Visual Servoing Platform  version 3.6.1 under development (2024-03-29)
vpXmlParserHomogeneousMatrix Class Reference

#include <visp3/core/vpXmlParserHomogeneousMatrix.h>

Public Types

enum  vpXmlCodeSequenceType { SEQUENCE_OK , SEQUENCE_ERROR }
 

Public Member Functions

 vpXmlParserHomogeneousMatrix ()
 
 ~vpXmlParserHomogeneousMatrix ()
 
vpHomogeneousMatrix getHomogeneousMatrix () const
 
std::string getHomogeneousMatrixName () const
 
int parse (vpHomogeneousMatrix &M, const std::string &filename, const std::string &name)
 
int save (const vpHomogeneousMatrix &M, const std::string &filename, const std::string &name)
 
void setHomogeneousMatrixName (const std::string &name)
 

Detailed Description

XML parser to load and save an homogeneous matrix in a file.

Warning
This class is only available if pugixml third-party is successfully built.

To have a complete description of the homogeneous matrix implemented in ViSP, see vpHomogeneousMatrix.

Example of an XML file "homogeneous_matrixes.xml" containing a Pose vector that will be converted in an homogeneous matrix:

<?xml version="1.0"?>
<root>
<homogeneous_transformation>
<!--Name of the homogeneous matrix-->
<name>eMc</name>
<values>
<!--Translation vector with values in meters -->
<tx>1.00</tx>
<ty>1.30</ty>
<tz>3.50</tz>
<!--Rotational vector expressed in angle axis representation with values
in radians --> <theta_ux>0.20</theta_ux> <theta_uy>0.30</theta_uy>
<theta_uz>0.50</theta_uz>
</values>
</homogeneous_transformation>
</root>

Example of loading an existing homogeneous matrix from an XML file.

#include <iostream>
#include <string>
#include <visp3/core/vpXmlParserHomogeneousMatrix.h>
int main(int argc, char* argv[])
{
// Create a XML parser
// Define the name of the matrix to load
std::string name = "eMc";
if (p.parse(eMc,"homogeneous_matrixes.xml", name) != vpXmlParserHomogeneousMatrix::SEQUENCE_OK) {
std::cout << "Cannot found the Homogeneous matrix named " << name << "." << std::endl;
}
else
std::cout << "Homogeneous matrix " << name <<": " << std::endl << eMc << std::endl;
return 0;
}
Implementation of an homogeneous matrix and operations on such kind of matrices.
XML parser to load and save an homogeneous matrix in a file.
int parse(vpHomogeneousMatrix &M, const std::string &filename, const std::string &name)

Example of writing an homogenoeus matrix in a XML file.

Note
Before writing an homogeneous matrix check if there is already in the xml file a matrix with the same name. If you are sure to overwrite it please delete it manually from the file before.
#include <iostream>
#include <string>
#include <visp3/core/vpXmlParserHomogeneousMatrix.h>
int main(int argc, char* argv[])
{
// Create Pose Vector and convert to homogeneous matrix
vpPoseVector r(1.0,1.3,3.5,0.2,0.3,0.5);
// Create a XML parser
// Define the name of the matrix
std::string name_M = "eMe";
// Define name of the file xml to fill
std::string filename = "homogeneous_matrixes.xml";
if (p.save(M, filename, name_M) != vpXmlParserHomogeneousMatrix::SEQUENCE_OK) {
std::cout << "Cannot save the Homogeneous matrix" << std::endl;
}
return 0;
}
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:189
int save(const vpHomogeneousMatrix &M, const std::string &filename, const std::string &name)

Definition at line 148 of file vpXmlParserHomogeneousMatrix.h.

Member Enumeration Documentation

◆ vpXmlCodeSequenceType

Enumerator
SEQUENCE_OK 
SEQUENCE_ERROR 

Definition at line 151 of file vpXmlParserHomogeneousMatrix.h.

Constructor & Destructor Documentation

◆ vpXmlParserHomogeneousMatrix()

vpXmlParserHomogeneousMatrix::vpXmlParserHomogeneousMatrix ( )

Definition at line 511 of file vpXmlParserHomogeneousMatrix.cpp.

◆ ~vpXmlParserHomogeneousMatrix()

vpXmlParserHomogeneousMatrix::~vpXmlParserHomogeneousMatrix ( )

Definition at line 513 of file vpXmlParserHomogeneousMatrix.cpp.

Member Function Documentation

◆ getHomogeneousMatrix()

vpHomogeneousMatrix vpXmlParserHomogeneousMatrix::getHomogeneousMatrix ( ) const

Definition at line 542 of file vpXmlParserHomogeneousMatrix.cpp.

◆ getHomogeneousMatrixName()

std::string vpXmlParserHomogeneousMatrix::getHomogeneousMatrixName ( ) const

Definition at line 547 of file vpXmlParserHomogeneousMatrix.cpp.

◆ parse()

int vpXmlParserHomogeneousMatrix::parse ( vpHomogeneousMatrix M,
const std::string &  filename,
const std::string &  name 
)

Parse an xml file to load an homogeneous matrix

Parameters
M: homogeneous matrix to fill.
filename: name of the xml file to parse.
name: name of the homogeneous matrix to find in the xml file.
Returns
error code.

Definition at line 523 of file vpXmlParserHomogeneousMatrix.cpp.

◆ save()

int vpXmlParserHomogeneousMatrix::save ( const vpHomogeneousMatrix M,
const std::string &  filename,
const std::string &  name 
)

Save an homogeneous matrix in an xml file.

Parameters
M: homogeneous matrix to save.
filename: name of the xml file to fill.
name: name of the homogeneous matrix.
Returns
error code.

Definition at line 536 of file vpXmlParserHomogeneousMatrix.cpp.

◆ setHomogeneousMatrixName()

void vpXmlParserHomogeneousMatrix::setHomogeneousMatrixName ( const std::string &  name)

Definition at line 552 of file vpXmlParserHomogeneousMatrix.cpp.