Commit 425f68d1 authored by florent's avatar florent
Browse files

Add namespace io for local classes

    * include/Makefile.am,
    * src/Makefile.am: move headers for include to src,
    * src/parser.cc,
    * include/hpp/core/parser.hh: implement Parser::buildDummyDevice
      for tests,
    * src/freeflyer-joint.hh,
    * src/joint-properties.cc,
    * src/joint-properties.hh,
    * src/rotation-joint.hh,
    * src/translation-joint.hh:  insert class into io namespace,
parent f0de5b3a
......@@ -12,10 +12,6 @@ if BODY
else
nobase_include_HEADERS += \
hpp/core/parser.hh \
hpp/core/joint-properties.hh \
hpp/core/freeflyer-joint.hh \
hpp/core/rotation-joint.hh \
hpp/core/translation-joint.hh \
hpp/core/fwd.hh
endif
......
......@@ -12,6 +12,8 @@
#include <kprParserXML/kprXMLBuildingContext.h>
#include <kprParserXML/kprXMLWriter.h>
KIT_PREDEF_CLASS(CkppDeviceComponent);
namespace hpp {
namespace core {
class Parser {
......@@ -78,6 +80,7 @@ namespace hpp {
CkprXMLBuildingContextShPtr& inOutContext,
CkppComponentShPtr& outComponent);
/// @}
static CkppDeviceComponentShPtr buildDummyDevice();
}; // Parser
} // namespace core
} // namespace hpp
......
......@@ -20,7 +20,11 @@ else
libhppCore_la_LIBADD += @HPPMODEL_LIBS@
libhppCore_la_SOURCES += \
parser.cc \
joint-properties.cc
joint-properties.cc \
joint-properties.hh \
freeflyer-joint.hh \
rotation-joint.hh \
translation-joint.hh
endif
# Add kwsPlus CPPFLAGS.
......
......@@ -3,71 +3,73 @@
#include <KineoModel/kppFreeFlyerJointComponent.h>
#include "hpp/core/joint-properties.hh"
#include "joint-properties.hh"
namespace hpp {
namespace core {
KIT_PREDEF_CLASS(FreeflyerJoint);
///
/// \brief Intermediate freeflyer joint.
///
/// This class implements a freeflyer joint deriving from
/// CkppFreeFlyerJointComponent only for kxml input output purposes.
///
/// Joints of this class contain inertia data as CkppDoubleProperty
/// attributes.
///
/// Once read from a file the device containing this joint will be
/// transformed into a ChppHumanoidRobot.
namespace io {
KIT_PREDEF_CLASS(FreeflyerJoint);
///
/// \brief Intermediate freeflyer joint.
///
/// This class implements a freeflyer joint deriving from
/// CkppFreeFlyerJointComponent only for kxml input output purposes.
///
/// Joints of this class contain inertia data as CkppDoubleProperty
/// attributes.
///
/// Once read from a file the device containing this joint will be
/// transformed into a ChppHumanoidRobot.
class FreeflyerJoint : public CkppFreeFlyerJointComponent,
public JointProperties
{
public:
virtual bool isComponentClonable () const
class FreeflyerJoint : public CkppFreeFlyerJointComponent,
public JointProperties
{
return false;
}
static FreeflyerJointShPtr create(const std::string& inName)
{
FreeflyerJoint *ptr = new FreeflyerJoint();
FreeflyerJointShPtr shPtr = FreeflyerJointShPtr(ptr);
FreeflyerJointWkPtr wkPtr = FreeflyerJointWkPtr(shPtr);
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();
if (ptr->init(wkPtr, inName) != KD_OK) {
shPtr.reset();
return shPtr;
}
return shPtr;
}
return shPtr;
}
void
fillPropertyVector(std::vector<CkppPropertyShPtr>& inOutPropertyVector)
const
{
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);
}
void
fillPropertyVector(std::vector<CkppPropertyShPtr>& inOutPropertyVector)
const
{
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:
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);
}
};
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 io
} // namespace core
} // namespace hpp
#endif //HPP_CORE_FREEFLYER_JOINT_HH
......@@ -5,9 +5,9 @@
#include <KineoModel/kppDoubleProperty.h>
#include "hpp/core/joint-properties.hh"
#include "joint-properties.hh"
using hpp::core::JointProperties;
using hpp::core::io::JointProperties;
// Mass
const CkppProperty::TPropertyID
......
......@@ -12,53 +12,54 @@ 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;
namespace io {
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;
// 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;
// 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;
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);
};
protected:
JointProperties();
/// Create properties
ktStatus init(const CkppComponentWkPtr& inComponent);
};
} // namespace io
} // namespace core
} // namespace hpp
......
......@@ -9,7 +9,10 @@
#include <kprParserXML/kprParserManager.h>
#include <hppModel/hppHumanoidRobot.h>
#include "hpp/core/parser.hh"
#include "hpp/core/freeflyer-joint.hh"
#include "freeflyer-joint.hh"
#include "rotation-joint.hh"
#include "translation-joint.hh"
#include "humanoid-robot.hh"
hpp::core::Parser::Parser()
{
......@@ -60,8 +63,7 @@ ktStatus hpp::core::Parser::writeHumanoidRobot
CkprXMLWriterShPtr& inOutWriter,
CkprXMLTagShPtr& inOutTag)
{
std::cout << "hpp::core::Parser::writeHumanoidRobot" << std::endl;
if (KIT_DYNAMIC_PTR_CAST(const ChppHumanoidRobot, inComponent)) {
if (KIT_DYNAMIC_PTR_CAST(const io::HumanoidRobot, inComponent)) {
inOutTag->name("HPP_HUMANOID_ROBOT");
return KD_OK;
}
......@@ -75,8 +77,7 @@ ktStatus hpp::core::Parser::buildHumanoidRobot
CkprXMLBuildingContextShPtr& inOutContext,
CkppComponentShPtr& outComponent)
{
std::cout << "Creating a humanoid robot" << std::endl;
outComponent = ChppHumanoidRobot::create("Humanoid Robot");
outComponent = io::HumanoidRobot::create("Humanoid Robot");
return KD_OK;
}
......@@ -85,7 +86,7 @@ writeHppFreeflyerJoint(const CkppComponentConstShPtr& inComponent,
CkprXMLWriterShPtr& inOutWriter,
CkprXMLTagShPtr& inOutTag)
{
if (KIT_DYNAMIC_PTR_CAST(const FreeflyerJoint, inComponent)) {
if (KIT_DYNAMIC_PTR_CAST(const io::FreeflyerJoint, inComponent)) {
inOutTag->name("HPP_FREEFLYER_JOINT");
return KD_OK;
}
......@@ -100,7 +101,7 @@ buildHppFreeflyerJoint(const CkprXMLTagConstShPtr& inTag,
CkprXMLBuildingContextShPtr& inOutContext,
CkppComponentShPtr& outComponent)
{
outComponent = FreeflyerJoint::create("FREEFLYER");
outComponent = io::FreeflyerJoint::create("FREEFLYER");
return KD_OK;
}
......@@ -109,7 +110,7 @@ writeHppRotationJoint(const CkppComponentConstShPtr& inComponent,
CkprXMLWriterShPtr& inOutWriter,
CkprXMLTagShPtr& inOutTag)
{
if (KIT_DYNAMIC_PTR_CAST(const RotationJoint, inComponent)) {
if (KIT_DYNAMIC_PTR_CAST(const io::RotationJoint, inComponent)) {
inOutTag->name("HPP_ROTATION_JOINT");
return KD_OK;
}
......@@ -124,7 +125,7 @@ buildHppRotationJoint(const CkprXMLTagConstShPtr& inTag,
CkprXMLBuildingContextShPtr& inOutContext,
CkppComponentShPtr& outComponent)
{
outComponent = RotationJoint::create("ROTATION");
outComponent = io::RotationJoint::create("ROTATION");
return KD_OK;
}
......@@ -133,7 +134,7 @@ writeHppTranslationJoint(const CkppComponentConstShPtr& inComponent,
CkprXMLWriterShPtr& inOutWriter,
CkprXMLTagShPtr& inOutTag)
{
if (KIT_DYNAMIC_PTR_CAST(const TranslationJoint, inComponent)) {
if (KIT_DYNAMIC_PTR_CAST(const io::TranslationJoint, inComponent)) {
inOutTag->name("HPP_TRANSLATION_JOINT");
return KD_OK;
}
......@@ -148,7 +149,17 @@ buildHppTranslationJoint(const CkprXMLTagConstShPtr& inTag,
CkprXMLBuildingContextShPtr& inOutContext,
CkppComponentShPtr& outComponent)
{
outComponent = TranslationJoint::create("TRANSLATION");
outComponent = io::TranslationJoint::create("TRANSLATION");
return KD_OK;
}
CkppDeviceComponentShPtr hpp::core::Parser::buildDummyDevice()
{
// Create a humanoid robot with one freeflyer joint
io::HumanoidRobotShPtr robot = io::HumanoidRobot::create("TEST");
io::FreeflyerJointShPtr joint = io::FreeflyerJoint::create("FF");
joint->mass->value(1.55);
robot->setRootJoint(joint);
return robot;
}
......@@ -3,71 +3,73 @@
#include <KineoModel/kppRotationJointComponent.h>
#include "hpp/core/joint-properties.hh"
#include "joint-properties.hh"
namespace hpp {
namespace core {
KIT_PREDEF_CLASS(RotationJoint);
///
/// \brief Intermediate rotation joint.
///
/// This class implements a rotation joint deriving from
/// CkppRotationJointComponent only for kxml input output purposes.
///
/// Joints of this class contain inertia data as CkppDoubleProperty
/// attributes.
///
/// Once read from a file the device containing this joint will be
/// transformed into a ChppHumanoidRobot.
namespace io {
KIT_PREDEF_CLASS(RotationJoint);
///
/// \brief Intermediate rotation joint.
///
/// This class implements a rotation joint deriving from
/// CkppRotationJointComponent only for kxml input output purposes.
///
/// Joints of this class contain inertia data as CkppDoubleProperty
/// attributes.
///
/// Once read from a file the device containing this joint will be
/// transformed into a ChppHumanoidRobot.
class RotationJoint : public CkppRotationJointComponent,
public JointProperties
{
public:
virtual bool isComponentClonable () const
class RotationJoint : public CkppRotationJointComponent,
public JointProperties
{
return false;
}
static RotationJointShPtr create(const std::string& inName)
{
RotationJoint *ptr = new RotationJoint();
RotationJointShPtr shPtr = RotationJointShPtr(ptr);
RotationJointWkPtr wkPtr = RotationJointWkPtr(shPtr);
public:
virtual bool isComponentClonable () const
{
return false;
}
static RotationJointShPtr create(const std::string& inName)
{
RotationJoint *ptr = new RotationJoint();
RotationJointShPtr shPtr = RotationJointShPtr(ptr);
RotationJointWkPtr wkPtr = RotationJointWkPtr(shPtr);
if (ptr->init(wkPtr, inName) != KD_OK) {
shPtr.reset();
if (ptr->init(wkPtr, inName) != KD_OK) {
shPtr.reset();
return shPtr;
}
return shPtr;
}
return shPtr;
}
void
fillPropertyVector(std::vector<CkppPropertyShPtr>& inOutPropertyVector)
const
{
CkppRotationJointComponent::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);
}
void
fillPropertyVector(std::vector<CkppPropertyShPtr>& inOutPropertyVector)
const
{
CkppRotationJointComponent::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:
RotationJoint() : CkppRotationJointComponent() {}
ktStatus init (const RotationJointWkPtr &inWeakPtr,
const std::string &inName)
{
ktStatus status = KD_OK;
status = CkppRotationJointComponent::init(inWeakPtr, inName);
if (status == KD_ERROR) return KD_ERROR;
return JointProperties::init(inWeakPtr);
}
};
protected:
RotationJoint() : CkppRotationJointComponent() {}
ktStatus init (const RotationJointWkPtr &inWeakPtr,
const std::string &inName)
{
ktStatus status = KD_OK;
status = CkppRotationJointComponent::init(inWeakPtr, inName);
if (status == KD_ERROR) return KD_ERROR;
return JointProperties::init(inWeakPtr);
}
};
} // namespace io
} // namespace core
} // namespace hpp
#endif //HPP_CORE_ROTATION_JOINT_HH
......@@ -3,71 +3,73 @@
#include <KineoModel/kppTranslationJointComponent.h>
#include "hpp/core/joint-properties.hh"
#include "joint-properties.hh"
namespace hpp {
namespace core {
KIT_PREDEF_CLASS(TranslationJoint);
///
/// \brief Intermediate translation joint.
///
/// This class implements a translation joint deriving from
/// CkppTranslationJointComponent only for kxml input output purposes.
///
/// Joints of this class contain inertia data as CkppDoubleProperty
/// attributes.
///
/// Once read from a file the device containing this joint will be
/// transformed into a ChppHumanoidRobot.
namespace io {
KIT_PREDEF_CLASS(TranslationJoint);
///
/// \brief Intermediate translation joint.
///
/// This class implements a translation joint deriving from
/// CkppTranslationJointComponent only for kxml input output purposes.
///
/// Joints of this class contain inertia data as CkppDoubleProperty
/// attributes.
///
/// Once read from a file the device containing this joint will be
/// transformed into a ChppHumanoidRobot.
class TranslationJoint : public CkppTranslationJointComponent,
public JointProperties
{
public:
virtual bool isComponentClonable () const
class TranslationJoint : public CkppTranslationJointComponent,
public JointProperties
{
return false;
}
static TranslationJointShPtr create(const std::string& inName)
{
TranslationJoint *ptr = new TranslationJoint();
TranslationJointShPtr shPtr = TranslationJointShPtr(ptr);
TranslationJointWkPtr wkPtr = TranslationJointWkPtr(shPtr);
public:
virtual bool isComponentClonable () const
{
return false;
}
static TranslationJointShPtr create(const std::string& inName)
{
TranslationJoint *ptr = new TranslationJoint();
TranslationJointShPtr shPtr = TranslationJointShPtr(ptr);
TranslationJointWkPtr wkPtr = TranslationJointWkPtr(shPtr);
if (ptr->init(wkPtr, inName) != KD_OK) {
shPtr.reset();
if (ptr->init(wkPtr, inName) != KD_OK) {
shPtr.reset();
return shPtr;
}
return shPtr;
}
return shPtr;
}
void
fillPropertyVector(std::vector<CkppPropertyShPtr>& inOutPropertyVector)
const
{
CkppTranslationJointComponent::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);
}
void
fillPropertyVector(std::vector<CkppPropertyShPtr>& inOutPropertyVector)
const
{
CkppTranslationJointComponent::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:
TranslationJoint() : CkppTranslationJointComponent() {}
ktStatus init (const TranslationJointWkPtr &inWeakPtr,
const std::string &inName)
{
ktStatus status = KD_OK;
status = CkppTranslationJointComponent::init(inWeakPtr, inName);
if (status == KD_ERROR) return KD_ERROR;
return JointProperties::init(inWeakPtr);
}
};