Commit 9a35a861 authored by florent's avatar florent
Browse files

Fix writing and reading in kxml file.

    * include/Makefile.am: install new headers,
    * include/hpp/core/freeflyer-joint.hh,
    * include/hpp/core/parser.hh,
    * src/joint-properties.cc,
    * src/parser.cc.
parent 1a1603e3
......@@ -12,7 +12,9 @@ if BODY
else
nobase_include_HEADERS += \
hpp/core/parser.hh \
hpp/core/joint-properties.hh
hpp/core/joint-properties.hh \
hpp/core/freeflyer-joint.hh \
hpp/core/fwd.hh
endif
......
......@@ -9,7 +9,7 @@ namespace hpp {
namespace core {
KIT_PREDEF_CLASS(FreeflyerJoint);
class FreeflyerJoint : public CkppFreeFlyerJointComponent,
public hpp::core::JointProperties
public JointProperties
{
public:
virtual bool isComponentClonable () const
......@@ -29,20 +29,20 @@ namespace hpp {
return shPtr;
}
void
fillPropertyVector(std::vector<CkppPropertyShPtr>& outPropertyVector)
fillPropertyVector(std::vector<CkppPropertyShPtr>& inOutPropertyVector)
const
{
CkppFreeFlyerJointComponent::fillPropertyVector(outPropertyVector);
outPropertyVector.push_back(mass);
outPropertyVector.push_back(comX);
outPropertyVector.push_back(comY);
outPropertyVector.push_back(comZ);
outPropertyVector.push_back(inertiaMatrixXX);
outPropertyVector.push_back(inertiaMatrixYY);
outPropertyVector.push_back(inertiaMatrixZZ);
outPropertyVector.push_back(inertiaMatrixXY);
outPropertyVector.push_back(inertiaMatrixXZ);
outPropertyVector.push_back(inertiaMatrixYZ);
CkppFreeFlyerJointComponent::fillPropertyVector(inOutPropertyVector);
inOutPropertyVector.push_back(mass);
inOutPropertyVector.push_back(comX);
inOutPropertyVector.push_back(comY);
inOutPropertyVector.push_back(comZ);
inOutPropertyVector.push_back(inertiaMatrixXX);
inOutPropertyVector.push_back(inertiaMatrixYY);
inOutPropertyVector.push_back(inertiaMatrixZZ);
inOutPropertyVector.push_back(inertiaMatrixXY);
inOutPropertyVector.push_back(inertiaMatrixXZ);
inOutPropertyVector.push_back(inertiaMatrixYZ);
}
protected:
......
......@@ -19,6 +19,9 @@ namespace hpp {
Parser();
~Parser();
ktStatus propertyFiller(const std::string& inContent,
CkppPropertyShPtr& inOutProperty);
ktStatus writeHumanoidRobot(const CkppComponentConstShPtr& inComponent,
CkprXMLWriterShPtr& inOutWriter,
CkprXMLTagShPtr& inOutTag);
......
......@@ -26,7 +26,7 @@ const std::string JointProperties::COM_Y_STRING_ID("COM_Y");
// Z coordinate
const CkppProperty::TPropertyID
JointProperties::COM_Z_ID(CkppProperty::makeID());
const std::string JointProperties::COM_Z_STRING_ID("");
const std::string JointProperties::COM_Z_STRING_ID("COM_Z");
// Inertia matrix
// XX coefficient
......@@ -68,55 +68,55 @@ ktStatus JointProperties::init(const CkppComponentWkPtr& inWeakPtr)
{
CkppComponentShPtr component = inWeakPtr.lock();
mass = CkppDoubleProperty::create("MASS", component,
MASS_ID , MASS_STRING_ID , 0.0);
MASS_ID , MASS_STRING_ID);
if (!mass) return KD_ERROR;
comX = CkppDoubleProperty::create("COM_X", component,
COM_X_ID, COM_X_STRING_ID, 0.0);
COM_X_ID, COM_X_STRING_ID);
if (!comX) return KD_ERROR;
comY = CkppDoubleProperty::create("COM_Y", component,
COM_Y_ID, COM_Y_STRING_ID, 0.0);
COM_Y_ID, COM_Y_STRING_ID);
if (!comY) return KD_ERROR;
comZ = CkppDoubleProperty::create("COM_Z", component,
COM_Z_ID, COM_Z_STRING_ID, 0.0);
COM_Z_ID, COM_Z_STRING_ID);
if (!comZ) return KD_ERROR;
inertiaMatrixXX =
CkppDoubleProperty::create("INERTIA_MATRIX_XX", component,
INERTIA_MATRIX_XX_ID,
INERTIA_MATRIX_XX_STRING_ID, 0.0);
INERTIA_MATRIX_XX_STRING_ID);
if (!inertiaMatrixXX) return KD_ERROR;
inertiaMatrixYY =
CkppDoubleProperty::create("INERTIA_MATRIX_YY", component,
INERTIA_MATRIX_YY_ID,
INERTIA_MATRIX_YY_STRING_ID, 0.0);
INERTIA_MATRIX_YY_STRING_ID);
if (!inertiaMatrixYY) return KD_ERROR;
inertiaMatrixZZ =
CkppDoubleProperty::create("INERTIA_MATRIX_ZZ", component,
INERTIA_MATRIX_ZZ_ID,
INERTIA_MATRIX_ZZ_STRING_ID, 0.0);
INERTIA_MATRIX_ZZ_STRING_ID);
if (!inertiaMatrixZZ) return KD_ERROR;
inertiaMatrixXY =
CkppDoubleProperty::create("INERTIA_MATRIX_XY", component,
INERTIA_MATRIX_XY_ID,
INERTIA_MATRIX_XY_STRING_ID, 0.0);
INERTIA_MATRIX_XY_STRING_ID);
if (!inertiaMatrixXY) return KD_ERROR;
inertiaMatrixXZ =
CkppDoubleProperty::create("INERTIA_MATRIX_XZ", component,
INERTIA_MATRIX_XZ_ID,
INERTIA_MATRIX_XZ_STRING_ID, 0.0);
INERTIA_MATRIX_XZ_STRING_ID);
if (!inertiaMatrixXZ) return KD_ERROR;
inertiaMatrixYZ =
CkppDoubleProperty::create("INERTIA_MATRIX_YZ", component,
INERTIA_MATRIX_YZ_ID,
INERTIA_MATRIX_YZ_STRING_ID, 0.0);
INERTIA_MATRIX_YZ_STRING_ID);
if (!inertiaMatrixYZ) return KD_ERROR;
return KD_OK;
......
......@@ -5,17 +5,45 @@
*/
#include <iostream>
#include <typeinfo>
#include <kprParserXML/kprParserManager.h>
#include <hppModel/hppHumanoidRobot.h>
#include "hpp/core/parser.hh"
#include "hpp/core/freeflyer-joint.hh"
ktStatus hpp::core::Parser::propertyFiller(const std::string& inContent,
CkppPropertyShPtr& inOutProperty)
{
std::cout << "propertyFiller(" << inContent << ")"
<< std::endl
<< "property type: " << typeid(inOutProperty.get()).name()
<< std::endl;
return KD_OK;
}
hpp::core::Parser::Parser()
{
ktStatus status = KD_ERROR;
std::cout << "Registering Parser::writeHumanoidRobot" << std::endl;
CkprParserManager::defaultManager()->addXMLWriterMethod < Parser >
(this, &Parser::writeHumanoidRobot);
CkprParserManager::defaultManager()->addXMLTagBuilderMethod < Parser >
("HUMANOID_ROBOT", this, &Parser::buildHumanoidRobot, NULL);
std::cout << "Registering Parser::buildHumanoidRobot" << std::endl;
status =
CkprParserManager::defaultManager()->addXMLInheritedBuilderMethod < Parser >
("HPP_HUMANOID_ROBOT", "DEVICE", this, &Parser::buildHumanoidRobot, NULL);
assert(status == KD_OK);
std::cout << "Registering Parser::writeHppFreeflyerJoint" << std::endl;
CkprParserManager::defaultManager()->addXMLWriterMethod < Parser >
(this, &Parser::writeHppFreeflyerJoint);
std::cout << "Registering Parser::buildHppFreeflyerJoint" << std::endl;
status =
CkprParserManager::defaultManager()->addXMLInheritedBuilderMethod < Parser >
("HPP_FREEFLYER_JOINT", "FREEFLYER_JOINT", this,
&Parser::buildHppFreeflyerJoint, NULL);
assert(status == KD_OK);
// std::cout << "Registering " << std::endl;
// CkprParserManager::defaultManager()->addPropertyFillerMethod < Parser >
// (this, &hpp::core::Parser::propertyFiller);
}
hpp::core::Parser::~Parser()
......@@ -28,8 +56,8 @@ ktStatus hpp::core::Parser::writeHumanoidRobot
CkprXMLTagShPtr& inOutTag)
{
std::cout << "hpp::core::Parser::writeHumanoidRobot" << std::endl;
if (KIT_DYNAMIC_PTR_CAST(ChppHumanoidRobot const, inComponent)) {
inOutTag->name("HUMANOID_ROBOT");
if (KIT_DYNAMIC_PTR_CAST(const ChppHumanoidRobot, inComponent)) {
inOutTag->name("HPP_HUMANOID_ROBOT");
return KD_OK;
}
return KD_ERROR;
......@@ -53,7 +81,7 @@ writeHppFreeflyerJoint(const CkppComponentConstShPtr& inComponent,
CkprXMLTagShPtr& inOutTag)
{
std::cout << "hpp::core::Parser::writeHppFreeflyerJoint" << std::endl;
if (KIT_DYNAMIC_PTR_CAST(FreeflyerJoint const, inComponent)) {
if (KIT_DYNAMIC_PTR_CAST(const FreeflyerJoint, inComponent)) {
inOutTag->name("HPP_FREEFLYER_JOINT");
return KD_OK;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment