Commit 1a1603e3 authored by florent's avatar florent
Browse files

Start extending Kineo parser for hpp-model classes.

      * include/Makefile.am: add extra headers,
      * include/hpp/core/freeflyer-joint.hh: new,
      * include/hpp/core/joint-properties.hh: new,
      * include/hpp/core/parser.hh: new,
      *  src/Makefile.am: add extra source files,
      * src/joint-properties.cc: new,
      * src/parser.cc: new.
parent b6e1d006
......@@ -9,6 +9,10 @@ nobase_include_HEADERS = \
if BODY
hppModeldir = $(includedir)/hppModel
hppModel_HEADERS = hppModel/hppModel/hppBody.h
else
nobase_include_HEADERS += \
hpp/core/parser.hh \
hpp/core/joint-properties.hh
endif
......
#ifndef HPP_CORE_FREEFLYER_JOINT_HH
#define HPP_CORE_FREEFLYER_JOINT_HH
#include <KineoModel/kppFreeFlyerJointComponent.h>
#include "hpp/core/joint-properties.hh"
namespace hpp {
namespace core {
KIT_PREDEF_CLASS(FreeflyerJoint);
class FreeflyerJoint : public CkppFreeFlyerJointComponent,
public hpp::core::JointProperties
{
public:
virtual bool isComponentClonable () const
{
return false;
}
static FreeflyerJointShPtr create(const std::string& inName)
{
FreeflyerJoint *ptr = new FreeflyerJoint();
FreeflyerJointShPtr shPtr = FreeflyerJointShPtr(ptr);
FreeflyerJointWkPtr wkPtr = FreeflyerJointWkPtr(shPtr);
if (ptr->init(wkPtr, inName) != KD_OK) {
shPtr.reset();
return shPtr;
}
return shPtr;
}
void
fillPropertyVector(std::vector<CkppPropertyShPtr>& outPropertyVector)
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);
}
protected:
FreeflyerJoint() : CkppFreeFlyerJointComponent() {}
ktStatus init (const FreeflyerJointWkPtr &inWeakPtr,
const std::string &inName)
{
ktStatus status = KD_OK;
status = CkppFreeFlyerJointComponent::init(inWeakPtr, inName);
if (status == KD_ERROR) return KD_ERROR;
return JointProperties::init(inWeakPtr);
}
};
} // namespace core
} // namespace hpp
#endif //HPP_CORE_FREEFLYER_JOINT_HH
/*
Copyright 2010 CNRS-LAAS
Author: Florent Lamiraux
*/
#ifndef HPP_CORE_JOINT_PROPERTIES_HH
#define HPP_CORE_JOINT_PROPERTIES_HH
#include <KineoModel/kppProperty.h>
KIT_PREDEF_CLASS(CkppDoubleProperty);
namespace hpp {
namespace core {
KIT_PREDEF_CLASS(JointProperties)
class JointProperties
{
public:
// Mass
static const CkppProperty::TPropertyID MASS_ID;
static const std::string MASS_STRING_ID;
// Local center of mass
static const CkppProperty::TPropertyID COM_X_ID;
static const std::string COM_X_STRING_ID;
static const CkppProperty::TPropertyID COM_Y_ID;
static const std::string COM_Y_STRING_ID;
static const CkppProperty::TPropertyID COM_Z_ID;
static const std::string COM_Z_STRING_ID;
// Inertia matrix
static const CkppProperty::TPropertyID INERTIA_MATRIX_XX_ID;
static const std::string INERTIA_MATRIX_XX_STRING_ID;
static const CkppProperty::TPropertyID INERTIA_MATRIX_YY_ID;
static const std::string INERTIA_MATRIX_YY_STRING_ID;
static const CkppProperty::TPropertyID INERTIA_MATRIX_ZZ_ID;
static const std::string INERTIA_MATRIX_ZZ_STRING_ID;
static const CkppProperty::TPropertyID INERTIA_MATRIX_XY_ID;
static const std::string INERTIA_MATRIX_XY_STRING_ID;
static const CkppProperty::TPropertyID INERTIA_MATRIX_XZ_ID;
static const std::string INERTIA_MATRIX_XZ_STRING_ID;
static const CkppProperty::TPropertyID INERTIA_MATRIX_YZ_ID;
static const std::string INERTIA_MATRIX_YZ_STRING_ID;
CkppDoublePropertyShPtr mass;
CkppDoublePropertyShPtr comX;
CkppDoublePropertyShPtr comY;
CkppDoublePropertyShPtr comZ;
CkppDoublePropertyShPtr inertiaMatrixXX;
CkppDoublePropertyShPtr inertiaMatrixYY;
CkppDoublePropertyShPtr inertiaMatrixZZ;
CkppDoublePropertyShPtr inertiaMatrixXY;
CkppDoublePropertyShPtr inertiaMatrixXZ;
CkppDoublePropertyShPtr inertiaMatrixYZ;
protected:
JointProperties();
/// Create properties
ktStatus init(const CkppComponentWkPtr& inComponent);
};
} // namespace core
} // namespace hpp
#endif // HPP_CORE_JOINT_PROPERTIES_HH
/*
* Copyright (c) 2010 LAAS-CNRS
*
* Author: Florent Lamiraux
*/
#ifndef HPPMODEL_PARSER_HH
#define HPPMODEL_PARSER_HH
#include <KineoModel/kppComponent.h>
#include <kprParserXML/kprXMLTag.h>
#include <kprParserXML/kprXMLBuildingContext.h>
#include <kprParserXML/kprXMLWriter.h>
namespace hpp {
namespace core {
class Parser {
public:
Parser();
~Parser();
ktStatus writeHumanoidRobot(const CkppComponentConstShPtr& inComponent,
CkprXMLWriterShPtr& inOutWriter,
CkprXMLTagShPtr& inOutTag);
ktStatus buildHumanoidRobot(const CkprXMLTagConstShPtr& inTag,
const CkppComponentShPtr&
inOutParentComponent,
std::vector< CkppComponentShPtr >&
inPrebuiltChildComponentVector,
CkprXMLBuildingContextShPtr& inOutContext,
CkppComponentShPtr& outComponent);
ktStatus
writeHppFreeflyerJoint(const CkppComponentConstShPtr& inComponent,
CkprXMLWriterShPtr& inOutWriter,
CkprXMLTagShPtr& inOutTag);
ktStatus
buildHppFreeflyerJoint(const CkprXMLTagConstShPtr& inTag,
const CkppComponentShPtr&
inOutParentComponent,
std::vector< CkppComponentShPtr >&
inPrebuiltChildComponentVector,
CkprXMLBuildingContextShPtr& inOutContext,
CkppComponentShPtr& outComponent);
}; // Parser
} // namespace core
} // namespace hpp
#endif // HPPMODEL_PARSER_HH
......@@ -18,6 +18,9 @@ if BODY
else
AM_CPPFLAGS += @HPPMODEL_CFLAGS@
libhppCore_la_LIBADD += @HPPMODEL_LIBS@
libhppCore_la_SOURCES += \
parser.cc \
joint-properties.cc
endif
# Add kwsPlus CPPFLAGS.
......
/*
Copyright 2010 CNRS-LAAS
Author: Florent Lamiraux
*/
#include <KineoModel/kppDoubleProperty.h>
#include "hpp/core/joint-properties.hh"
using hpp::core::JointProperties;
// Mass
const CkppProperty::TPropertyID
JointProperties::MASS_ID(CkppProperty::makeID());
const std::string JointProperties::MASS_STRING_ID("MASS");
const CkppProperty::TPropertyID
// Center of mass
// X coordinate
JointProperties::COM_X_ID(CkppProperty::makeID());
const std::string JointProperties::COM_X_STRING_ID("COM_X");
// Y coordinate
const CkppProperty::TPropertyID
JointProperties::COM_Y_ID(CkppProperty::makeID());
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("");
// Inertia matrix
// XX coefficient
const CkppProperty::TPropertyID
JointProperties::INERTIA_MATRIX_XX_ID(CkppProperty::makeID());
const std::string
JointProperties::INERTIA_MATRIX_XX_STRING_ID("INERTIA_MATRIX_XX");
// YY coefficient
const CkppProperty::TPropertyID
JointProperties::INERTIA_MATRIX_YY_ID(CkppProperty::makeID());
const std::string
JointProperties::INERTIA_MATRIX_YY_STRING_ID("INERTIA_MATRIX_YY");
// ZZ coefficient
const CkppProperty::TPropertyID
JointProperties::INERTIA_MATRIX_ZZ_ID(CkppProperty::makeID());
const std::string
JointProperties::INERTIA_MATRIX_ZZ_STRING_ID("INERTIA_MATRIX_ZZ");
// XY coefficient
const CkppProperty::TPropertyID
JointProperties::INERTIA_MATRIX_XY_ID(CkppProperty::makeID());
const std::string
JointProperties::INERTIA_MATRIX_XY_STRING_ID("INERTIA_MATRIX_XY");
// XZ coefficient
const CkppProperty::TPropertyID
JointProperties::INERTIA_MATRIX_XZ_ID(CkppProperty::makeID());
const std::string
JointProperties::INERTIA_MATRIX_XZ_STRING_ID("INERTIA_MATRIX_XZ");
// YZ coefficient
const CkppProperty::TPropertyID
JointProperties::INERTIA_MATRIX_YZ_ID(CkppProperty::makeID());
const std::string
JointProperties::INERTIA_MATRIX_YZ_STRING_ID("INERTIA_MATRIX_YZ");
JointProperties::JointProperties()
{
}
ktStatus JointProperties::init(const CkppComponentWkPtr& inWeakPtr)
{
CkppComponentShPtr component = inWeakPtr.lock();
mass = CkppDoubleProperty::create("MASS", component,
MASS_ID , MASS_STRING_ID , 0.0);
if (!mass) return KD_ERROR;
comX = CkppDoubleProperty::create("COM_X", component,
COM_X_ID, COM_X_STRING_ID, 0.0);
if (!comX) return KD_ERROR;
comY = CkppDoubleProperty::create("COM_Y", component,
COM_Y_ID, COM_Y_STRING_ID, 0.0);
if (!comY) return KD_ERROR;
comZ = CkppDoubleProperty::create("COM_Z", component,
COM_Z_ID, COM_Z_STRING_ID, 0.0);
if (!comZ) return KD_ERROR;
inertiaMatrixXX =
CkppDoubleProperty::create("INERTIA_MATRIX_XX", component,
INERTIA_MATRIX_XX_ID,
INERTIA_MATRIX_XX_STRING_ID, 0.0);
if (!inertiaMatrixXX) return KD_ERROR;
inertiaMatrixYY =
CkppDoubleProperty::create("INERTIA_MATRIX_YY", component,
INERTIA_MATRIX_YY_ID,
INERTIA_MATRIX_YY_STRING_ID, 0.0);
if (!inertiaMatrixYY) return KD_ERROR;
inertiaMatrixZZ =
CkppDoubleProperty::create("INERTIA_MATRIX_ZZ", component,
INERTIA_MATRIX_ZZ_ID,
INERTIA_MATRIX_ZZ_STRING_ID, 0.0);
if (!inertiaMatrixZZ) return KD_ERROR;
inertiaMatrixXY =
CkppDoubleProperty::create("INERTIA_MATRIX_XY", component,
INERTIA_MATRIX_XY_ID,
INERTIA_MATRIX_XY_STRING_ID, 0.0);
if (!inertiaMatrixXY) return KD_ERROR;
inertiaMatrixXZ =
CkppDoubleProperty::create("INERTIA_MATRIX_XZ", component,
INERTIA_MATRIX_XZ_ID,
INERTIA_MATRIX_XZ_STRING_ID, 0.0);
if (!inertiaMatrixXZ) return KD_ERROR;
inertiaMatrixYZ =
CkppDoubleProperty::create("INERTIA_MATRIX_YZ", component,
INERTIA_MATRIX_YZ_ID,
INERTIA_MATRIX_YZ_STRING_ID, 0.0);
if (!inertiaMatrixYZ) return KD_ERROR;
return KD_OK;
}
/*
* Copyright (c) 2010 LAAS-CNRS
*
* Author: Florent Lamiraux
*/
#include <iostream>
#include <kprParserXML/kprParserManager.h>
#include <hppModel/hppHumanoidRobot.h>
#include "hpp/core/parser.hh"
#include "hpp/core/freeflyer-joint.hh"
hpp::core::Parser::Parser()
{
CkprParserManager::defaultManager()->addXMLWriterMethod < Parser >
(this, &Parser::writeHumanoidRobot);
CkprParserManager::defaultManager()->addXMLTagBuilderMethod < Parser >
("HUMANOID_ROBOT", this, &Parser::buildHumanoidRobot, NULL);
}
hpp::core::Parser::~Parser()
{
}
ktStatus hpp::core::Parser::writeHumanoidRobot
(const CkppComponentConstShPtr& inComponent,
CkprXMLWriterShPtr& inOutWriter,
CkprXMLTagShPtr& inOutTag)
{
std::cout << "hpp::core::Parser::writeHumanoidRobot" << std::endl;
if (KIT_DYNAMIC_PTR_CAST(ChppHumanoidRobot const, inComponent)) {
inOutTag->name("HUMANOID_ROBOT");
return KD_OK;
}
return KD_ERROR;
}
ktStatus hpp::core::Parser::buildHumanoidRobot
(const CkprXMLTagConstShPtr& inTag,
const CkppComponentShPtr& inOutParentComponent,
std::vector< CkppComponentShPtr >& inPrebuiltChildComponentVector,
CkprXMLBuildingContextShPtr& inOutContext,
CkppComponentShPtr& outComponent)
{
std::cout << "Creating a humanoid robot" << std::endl;
outComponent = ChppHumanoidRobot::create("Humanoid Robot");
return KD_OK;
}
ktStatus hpp::core::Parser::
writeHppFreeflyerJoint(const CkppComponentConstShPtr& inComponent,
CkprXMLWriterShPtr& inOutWriter,
CkprXMLTagShPtr& inOutTag)
{
std::cout << "hpp::core::Parser::writeHppFreeflyerJoint" << std::endl;
if (KIT_DYNAMIC_PTR_CAST(FreeflyerJoint const, inComponent)) {
inOutTag->name("HPP_FREEFLYER_JOINT");
return KD_OK;
}
return KD_ERROR;
}
ktStatus hpp::core::Parser::
buildHppFreeflyerJoint(const CkprXMLTagConstShPtr& inTag,
const CkppComponentShPtr& inOutParentComponent,
std::vector< CkppComponentShPtr >&
inPrebuiltChildComponentVector,
CkprXMLBuildingContextShPtr& inOutContext,
CkppComponentShPtr& outComponent)
{
std::cout << "Creating a joint" << std::endl;
outComponent = FreeflyerJoint::create("FREEFLYER");
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