Commit 98c53283 authored by florent's avatar florent
Browse files

Add class Humanoid to as a buffer between kxml and ChppHumanoidRobot.

    * humanoid-robot.cc: new,
    * humanoid-robot.hh: new.
parent 1a746749
/*
* Copyright (c) 2010 LAAS-CNRS
*
* Author: Florent Lamiraux
*/
#include <hppModel/hppHumanoidRobot.h>
#include "humanoid-robot.hh"
using hpp::core::io::HumanoidRobot;
ChppHumanoidRobotShPtr HumanoidRobot::createHppHumanoidRobot() const
{
ChppHumanoidRobotShPtr robot = ChppHumanoidRobot::create(name());
try {
buildKinematicChain(rootJointComponent());
}
catch (const std::exception& exc) {
std::cerr <<
"Exception in hpp::core::io::HumanoidRobot::createHppHumanoidRobot():"
<< exc.what() << std::endl;
robot.reset();
}
return robot;
}
void
HumanoidRobot::buildKinematicChain(const CkppJointComponentConstShPtr& root)
const
{
std::string message;
}
/*
* Copyright (c) 2010 LAAS-CNRS
*
* Author: Florent Lamiraux
*/
#ifndef HPP_CORE_HUMANOID_ROBOT_HH
#define HPP_CORE_HUMANOID_ROBOT_HH
#include <KineoModel/kppDeviceComponent.h>
KIT_PREDEF_CLASS(ChppHumanoidRobot);
namespace hpp {
namespace core {
namespace io {
KIT_PREDEF_CLASS(HumanoidRobot);
class exception : public std::exception{
public:
exception (const std::string& inMessage) throw() : std::exception()
{
message_ = inMessage;
}
exception (const exception&) throw() : std::exception() {};
virtual ~exception() throw() {};
virtual const char* what() const throw()
{
return message_.c_str();
}
private:
std::string message_;
};
///
/// \brief Intermediate humanoid robot.
///
/// This class implements a humanoid robot deriving from
/// CkppDeviceComponent only for kxml input output purposes.
///
/// Once read from a file the device containing this joint will be
/// transformed into a ChppHumanoidRobot.
class HumanoidRobot : public CkppDeviceComponent
{
public:
virtual bool isComponentClonable () const
{
return false;
}
static HumanoidRobotShPtr create(const std::string& inName)
{
HumanoidRobot *ptr = new HumanoidRobot();
HumanoidRobotShPtr shPtr = HumanoidRobotShPtr(ptr);
HumanoidRobotWkPtr wkPtr = HumanoidRobotWkPtr(shPtr);
if (ptr->init(wkPtr, inName) != KD_OK) {
shPtr.reset();
return shPtr;
}
return shPtr;
}
void
fillPropertyVector(std::vector<CkppPropertyShPtr>& inOutPropertyVector)
const
{
CkppDeviceComponent::fillPropertyVector(inOutPropertyVector);
}
/// Create an instance of ChppHumanoidRobot from this object.
ChppHumanoidRobotShPtr createHppHumanoidRobot() const;
protected:
HumanoidRobot() : CkppDeviceComponent() {}
ktStatus init (const HumanoidRobotWkPtr &inWeakPtr,
const std::string &inName)
{
ktStatus status = KD_OK;
status = CkppDeviceComponent::init(inWeakPtr, inName);
return status;
}
private:
/// Recursively builds the kinematic chain of the ChppHumanoidRobot
void
buildKinematicChain(const CkppJointComponentConstShPtr& root) const;
};
} // namespace io
} // namespace core
} // namespace hpp
#endif //HPP_CORE_HUMANOID_ROBOT_HH
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