XmlParserHomogeneousMatrix

class XmlParserHomogeneousMatrix(self)

Bases: pybind11_object

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[])
{
  vpHomogeneousMatrix eMc;

  // Create a XML parser
  vpXmlParserHomogeneousMatrix p;

  // 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;
}

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);
  vpHomogeneousMatrix M(r);

  // Create a XML parser
  vpXmlParserHomogeneousMatrix p;

  // 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;
}

Methods

__init__

getHomogeneousMatrix

getHomogeneousMatrixName

parse

param M:

homogeneous matrix to fill.

save

param M:

homogeneous matrix to save.

setHomogeneousMatrixName

Inherited Methods

Operators

__doc__

__init__

__module__

Attributes

SEQUENCE_ERROR

SEQUENCE_OK

__annotations__

class XmlCodeSequenceType(self, value: int)

Bases: pybind11_object

Values:

  • SEQUENCE_OK

  • SEQUENCE_ERROR

__and__(self, other: object) object
__eq__(self, other: object) bool
__ge__(self, other: object) bool
__getstate__(self) int
__gt__(self, other: object) bool
__hash__(self) int
__index__(self) int
__init__(self, value: int)
__int__(self) int
__invert__(self) object
__le__(self, other: object) bool
__lt__(self, other: object) bool
__ne__(self, other: object) bool
__or__(self, other: object) object
__rand__(self, other: object) object
__ror__(self, other: object) object
__rxor__(self, other: object) object
__setstate__(self, state: int) None
__xor__(self, other: object) object
property name : str
__init__(self)
getHomogeneousMatrix(self) visp._visp.core.HomogeneousMatrix
getHomogeneousMatrixName(self) str
parse(self, M: visp._visp.core.HomogeneousMatrix, filename: str, name: str) int
Parameters:
M: visp._visp.core.HomogeneousMatrix

homogeneous matrix to fill.

filename: str

name of the xml file to parse.

name: str

name of the homogeneous matrix to find in the xml file.

Returns:

error code.

save(self, M: visp._visp.core.HomogeneousMatrix, filename: str, name: str) int
Parameters:
M: visp._visp.core.HomogeneousMatrix

homogeneous matrix to save.

filename: str

name of the xml file to fill.

name: str

name of the homogeneous matrix.

Returns:

error code.

setHomogeneousMatrixName(self, name: str) None