Commit 658c131e authored by florent's avatar florent
Browse files

Add rotation and translation joints

     include/Makefile.am: install new headers,
     * include/hpp/core/freeflyer-joint.hh: remove trailing white spaces,
     * include/hpp/core/parser.hh, add callback functions
     * include/hpp/core/rotation-joint.hh: new,
     * include/hpp/core/translation-joint.hh, new,
     * src/parser.cc: implement new callback functions
parent 51eccf89
......@@ -14,6 +14,8 @@ else
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
......
......@@ -28,7 +28,7 @@ namespace hpp {
}
return shPtr;
}
void
void
fillPropertyVector(std::vector<CkppPropertyShPtr>& inOutPropertyVector)
const
{
......
......@@ -19,7 +19,7 @@ namespace hpp {
Parser();
~Parser();
ktStatus propertyFiller(const std::string& inContent,
ktStatus propertyFiller(const std::string& inContent,
CkppPropertyShPtr& inOutProperty);
ktStatus writeHumanoidRobot(const CkppComponentConstShPtr& inComponent,
......@@ -44,6 +44,30 @@ namespace hpp {
inPrebuiltChildComponentVector,
CkprXMLBuildingContextShPtr& inOutContext,
CkppComponentShPtr& outComponent);
ktStatus
writeHppRotationJoint(const CkppComponentConstShPtr& inComponent,
CkprXMLWriterShPtr& inOutWriter,
CkprXMLTagShPtr& inOutTag);
ktStatus
buildHppRotationJoint(const CkprXMLTagConstShPtr& inTag,
const CkppComponentShPtr&
inOutParentComponent,
std::vector< CkppComponentShPtr >&
inPrebuiltChildComponentVector,
CkprXMLBuildingContextShPtr& inOutContext,
CkppComponentShPtr& outComponent);
ktStatus
writeHppTranslationJoint(const CkppComponentConstShPtr& inComponent,
CkprXMLWriterShPtr& inOutWriter,
CkprXMLTagShPtr& inOutTag);
ktStatus
buildHppTranslationJoint(const CkprXMLTagConstShPtr& inTag,
const CkppComponentShPtr&
inOutParentComponent,
std::vector< CkppComponentShPtr >&
inPrebuiltChildComponentVector,
CkprXMLBuildingContextShPtr& inOutContext,
CkppComponentShPtr& outComponent);
}; // Parser
} // namespace core
} // namespace hpp
......
#ifndef HPP_CORE_ROTATION_JOINT_HH
#define HPP_CORE_ROTATION_JOINT_HH
#include <KineoModel/kppRotationJointComponent.h>
#include "hpp/core/joint-properties.hh"
namespace hpp {
namespace core {
KIT_PREDEF_CLASS(RotationJoint);
class RotationJoint : public CkppRotationJointComponent,
public JointProperties
{
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();
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);
}
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 core
} // namespace hpp
#endif //HPP_CORE_ROTATION_JOINT_HH
#ifndef HPP_CORE_TRANSLATION_JOINT_HH
#define HPP_CORE_TRANSLATION_JOINT_HH
#include <KineoModel/kppTranslationJointComponent.h>
#include "hpp/core/joint-properties.hh"
namespace hpp {
namespace core {
KIT_PREDEF_CLASS(TranslationJoint);
class TranslationJoint : public CkppTranslationJointComponent,
public JointProperties
{
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();
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);
}
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);
}
};
} // namespace core
} // namespace hpp
#endif //HPP_CORE_TRANSLATION_JOINT_HH
......@@ -24,26 +24,41 @@ ktStatus hpp::core::Parser::propertyFiller(const std::string& inContent,
hpp::core::Parser::Parser()
{
ktStatus status = KD_ERROR;
std::cout << "Registering Parser::writeHumanoidRobot" << std::endl;
// Write humanoid robot
CkprParserManager::defaultManager()->addXMLWriterMethod < Parser >
(this, &Parser::writeHumanoidRobot);
std::cout << "Registering Parser::buildHumanoidRobot" << std::endl;
// Read humanoid robot
status =
CkprParserManager::defaultManager()->addXMLInheritedBuilderMethod < Parser >
("HPP_HUMANOID_ROBOT", "DEVICE", this, &Parser::buildHumanoidRobot, NULL);
assert(status == KD_OK);
std::cout << "Registering Parser::writeHppFreeflyerJoint" << std::endl;
// Write freeflyer joint
CkprParserManager::defaultManager()->addXMLWriterMethod < Parser >
(this, &Parser::writeHppFreeflyerJoint);
std::cout << "Registering Parser::buildHppFreeflyerJoint" << std::endl;
// Read freeflyer joint
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);
// Write rotation joint
CkprParserManager::defaultManager()->addXMLWriterMethod < Parser >
(this, &Parser::writeHppRotationJoint);
// Read rotation joint
status =
CkprParserManager::defaultManager()->addXMLInheritedBuilderMethod < Parser >
("HPP_ROTATION_JOINT", "ROTATION_JOINT", this,
&Parser::buildHppRotationJoint, NULL);
assert(status == KD_OK);
// Write translation joint
CkprParserManager::defaultManager()->addXMLWriterMethod < Parser >
(this, &Parser::writeHppTranslationJoint);
// Read translation joint
status =
CkprParserManager::defaultManager()->addXMLInheritedBuilderMethod < Parser >
("HPP_TRANSLATION_JOINT", "TRANSLATION_JOINT", this,
&Parser::buildHppTranslationJoint, NULL);
assert(status == KD_OK);
}
hpp::core::Parser::~Parser()
......@@ -80,7 +95,6 @@ writeHppFreeflyerJoint(const CkppComponentConstShPtr& inComponent,
CkprXMLWriterShPtr& inOutWriter,
CkprXMLTagShPtr& inOutTag)
{
std::cout << "hpp::core::Parser::writeHppFreeflyerJoint" << std::endl;
if (KIT_DYNAMIC_PTR_CAST(const FreeflyerJoint, inComponent)) {
inOutTag->name("HPP_FREEFLYER_JOINT");
return KD_OK;
......@@ -96,8 +110,55 @@ buildHppFreeflyerJoint(const CkprXMLTagConstShPtr& inTag,
CkprXMLBuildingContextShPtr& inOutContext,
CkppComponentShPtr& outComponent)
{
std::cout << "Creating a joint" << std::endl;
outComponent = FreeflyerJoint::create("FREEFLYER");
return KD_OK;
}
ktStatus hpp::core::Parser::
writeHppRotationJoint(const CkppComponentConstShPtr& inComponent,
CkprXMLWriterShPtr& inOutWriter,
CkprXMLTagShPtr& inOutTag)
{
if (KIT_DYNAMIC_PTR_CAST(const RotationJoint, inComponent)) {
inOutTag->name("HPP_ROTATION_JOINT");
return KD_OK;
}
return KD_ERROR;
}
ktStatus hpp::core::Parser::
buildHppRotationJoint(const CkprXMLTagConstShPtr& inTag,
const CkppComponentShPtr& inOutParentComponent,
std::vector< CkppComponentShPtr >&
inPrebuiltChildComponentVector,
CkprXMLBuildingContextShPtr& inOutContext,
CkppComponentShPtr& outComponent)
{
outComponent = RotationJoint::create("ROTATION");
return KD_OK;
}
ktStatus hpp::core::Parser::
writeHppTranslationJoint(const CkppComponentConstShPtr& inComponent,
CkprXMLWriterShPtr& inOutWriter,
CkprXMLTagShPtr& inOutTag)
{
if (KIT_DYNAMIC_PTR_CAST(const TranslationJoint, inComponent)) {
inOutTag->name("HPP_TRANSLATION_JOINT");
return KD_OK;
}
return KD_ERROR;
}
ktStatus hpp::core::Parser::
buildHppTranslationJoint(const CkprXMLTagConstShPtr& inTag,
const CkppComponentShPtr& inOutParentComponent,
std::vector< CkppComponentShPtr >&
inPrebuiltChildComponentVector,
CkprXMLBuildingContextShPtr& inOutContext,
CkppComponentShPtr& outComponent)
{
outComponent = TranslationJoint::create("TRANSLATION");
return KD_OK;
}
Markdown is supported
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