Commit ad36e61a authored by Florent Lamiraux's avatar Florent Lamiraux Committed by Florent Lamiraux florent@laas.fr
Browse files

Start refactoring the package

    Use cmake,
    Make joint classes derive from Kineo and jrl-dynamics corresponding joint
    classes.
parent 59b43264
[submodule "cmake"]
path = cmake
url = git://github.com/jrl-umi3218/jrl-cmakemodules.git
#
# Copyright (c) 2011 CNRS
# Authors: Florent Lamiraux
#
#
# This file is part of hpp-model
# hpp-model is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
#
# hpp-model is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Lesser Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with
# hpp-model If not, see
# <http://www.gnu.org/licenses/>.
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
SET(CXX_DISABLE_WERROR TRUE)
INCLUDE(cmake/base.cmake)
INCLUDE(cmake/cpack.cmake)
SET(PROJECT_NAME hpp-model)
SET(PROJECT_DESCRIPTION
"Implementation of hybrid geometric and dynamic humanoid robots"
)
SET(PROJECT_URL "")
# Where to compile shared objects
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
SETUP_PROJECT()
SET(${PROJECT_NAME}_HEADERS
include/hpp/model/exception.hh
include/hpp/model/freeflyer-joint.hh
include/hpp/model/fwd.hh
include/hpp/model/joint.hh
)
# Declare dependencies
ADD_REQUIRED_DEPENDENCY("jrl-dynamics >= 1.19")
ADD_REQUIRED_DEPENDENCY("kwsIO >= 1.0")
# Add dependency toward hpp-model library in pkg-config file.
PKG_CONFIG_APPEND_LIBS("hpp-model")
ADD_SUBDIRECTORY(src)
SETUP_PROJECT_FINALIZE()
SETUP_PROJECT_CPACK()
This package implements a hybrid geometric and dynamic robot.
Two kinematic chains are built and handled in parallel. One (geometric) is
handled by Kineo, while the other one (dynamic) is handled by jrl-dynamics.
Subproject commit e58a30cafcdb38f133d0e50c5db1122cc39a1f33
///
/// Copyright (c) 2011 CNRS
/// Authors: Florent Lamiraux
///
///
// This file is part of hpp-model
// hpp-model is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// hpp-model is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// hpp-model If not, see
// <http://www.gnu.org/licenses/>.
#ifndef HPP_MODEL_EXCEPTION_HH
#define HPP_MODEL_EXCEPTION_HH
#include <string>
namespace hpp {
namespace model {
class Exception : public std::exception
{
public:
virtual ~Exception() throw ();
Exception (const std::string& message) : message_(message) {}
virtual const char* what () const throw ()
{
return message_.c_str ();
}
private:
std::string message_;
}; // class Exception
} // namespace model
} // namespace hpp
#endif // HPP_MODEL_EXCEPTION_HH
///
/// Copyright (c) 2011 CNRS
/// Authors: Florent Lamiraux
///
///
// This file is part of hpp-model
// hpp-model is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// hpp-model is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// hpp-model If not, see
// <http://www.gnu.org/licenses/>.
#ifndef HPP_MODEL_FREEFLYER_JOINT_HH
#define HPP_MODEL_FREEFLYER_JOINT_HH
#include <KineoModel/kppFreeFlyerJointComponent.h>
#include <jrl/dynamics/joint.hh>
#include "hpp/model/joint.hh"
namespace hpp {
namespace model {
KIT_PREDEF_CLASS(FreeflyerJoint);
///
/// \brief Freeflyer joint.
///
/// This class implements a freeflyer joint deriving from
/// CkppFreeFlyerJointComponent and from jrl-dynamic FreeflyerJoint
///
/// Joints of this class contain inertia data as CkppDoubleProperty
/// attributes.
///
class FreeflyerJoint : public Joint,
public CkppFreeFlyerJointComponent,
public dynamicsJRLJapan::JointFreeflyer
{
public:
virtual ~FreeflyerJoint();
public:
virtual bool isComponentClonable () const
{
return false;
}
static FreeflyerJointShPtr create(const std::string& name,
const CkitMat4& initialPosition);
virtual void
fillPropertyVector(std::vector<CkppPropertyShPtr> &outPropertyVector)
const;
protected:
FreeflyerJoint(const CkitMat4& initialPosition);
ktStatus init (const FreeflyerJointWkPtr &inWeakPtr,
const std::string &inName,
const CkitMat4& initialPosition);
private:
FreeflyerJointWkPtr weakPtr_;
}; // class FreeflyerJoint
} // namespace model
} // namespace hpp
#endif // HPP_MODEL_FREEFLYER_JOINT_HH
///
/// Copyright (c) 2011 CNRS
/// Authors: Florent Lamiraux
///
///
// This file is part of hpp-model
// hpp-model is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// hpp-model is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// hpp-model If not, see
// <http://www.gnu.org/licenses/>.
#ifndef HPP_MODEL_FWD_HH
# define HPP_MODEL_FWD_HH
namespace hpp {
namespace model {
class Exception;
class FreeflyerJoint;
class Joint;
} // namespace model
} // namespace hpp
#endif //HPP_MODEL_FWD_HH
///
/// Copyright (c) 2011 CNRS
/// Authors: Florent Lamiraux
///
///
// This file is part of hpp-model
// hpp-model is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// hpp-model is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// hpp-model If not, see
// <http://www.gnu.org/licenses/>.
#ifndef HPP_MODEL_JOINT_COMMON_HH
#define HPP_MODEL_JOINT_COMMON_HH
#include <jrl/mal/matrixabstractlayer.hh>
#include <KineoModel/kppProperty.h>
#include <KineoModel/kppJointComponent.h>
KIT_PREDEF_CLASS(CkppDoubleProperty);
KIT_PREDEF_CLASS(CkwsJoint);
KIT_PREDEF_CLASS(CjrlJoint);
KIT_PREDEF_CLASS(ChppBody);
namespace hpp {
namespace model {
KIT_PREDEF_CLASS(Body);
KIT_PREDEF_CLASS(Joint);
class Joint
{
public:
///
/// \name Conversion between KineoWorks and Mal homogeneous Matrices
/// @{
///
/// \brief Conversion from KineoWorks to Matrix Abstraction Layer
///
static matrix4d abstractMatrixFromCkitMat4(const CkitMat4& matrix);
///
/// \brief Conversion from Matrix Abstraction Layer to KineoWorks
///
static CkitMat4 CkitMat4MatrixFromAbstract(const matrix4d& matrix);
///
///@}
///
///
/// \name Access to parent classes
/// @{
///
/// \brief Get shared pointer to CkppJointComponent part
///
CkppJointComponentShPtr kppJoint() const;
///
/// \brief Access to dynamic part of the joint.
///
CjrlJoint* jrlJoint();
///
/// \brief Const access to dynamic part of the joint.
///
const CjrlJoint* jrlJoint() const;
///
/// @}
///
///
/// \name Kinematic chain
/// @{
///
/// \brief Get the parent joint
///
virtual JointShPtr parentJoint() const;
///
/// \brief Get the child joint at given rank
///
virtual JointShPtr childJoint(unsigned int rank) const;
///
/// \brief Add a child to the joint
///
virtual void addChildJoint(JointShPtr inJoint);
///
/// \brief Get number of child joints
///
virtual unsigned int countChildJoints() const;
///
/// @}
///
///
/// \name Bounds of the degrees of freedom
/// @{
///
/// \brief Determine whether the degree of freedom of the joint is bounded
///
/// \param dofRank Rank of the degree of freedom that is bounded
/// \param bounded Whether the degree of freedom is bounded
///
void isBounded(unsigned int dofRank, bool bounded);
///
/// \brief Return whether the degree of freedom of the joint is bounded
///
/// \param dofRank Rank of the degree of freedom that is bounded
///
bool isBounded(unsigned int dofRank) const;
///
/// \brief Get the lower bound of a given degree of freedom of the joint.
///
/// \param dofRank Id of the dof in the joint
///
virtual double lowerBound(unsigned int dofRank) const;
///
/// \brief Get the upper bound of a given degree of freedom of the joint.
///
///\param dofRank Id of the dof in the joint
///
virtual double upperBound(unsigned int dofRank) const;
///
/// \brief Set the lower bound of a given degree of freedom of the joint.
///
/// \param dofRank Id of the dof in the joint
///
virtual void lowerBound(unsigned int dofRank, double lowerBound);
///
/// \brief Set the upper bound of a given degree of freedom of the joint.
///
/// \param dofRank Id of the dof in the joint
///
virtual void upperBound(unsigned int dofRank, double upperBound);
///
/// \brief Set the bounds of the degrees of freedom of the joint
///
/// \param dofRank Rank of the degree of freedom that is bounded
///
/// \param upperBound upper bound of this degree of freedom
void bounds(unsigned int dofRank, const double& lowerBound,
const double& upperBound);
///
/// \brief Set the velocity bounds of the degrees of freedom of the joint
///
/// \param dofRank Rank of the degree of freedom that is bounded
///
/// \param upperVelocityBound upper velocity bound of this deg. of freedom
void velocityBounds(unsigned int dofRank,
const double& lowerVelocityBound,
const double& upperVelocityBound);
///
/// @}
///
///
/// \name Attached body
/// @{
///
/// \brief Attach a body to the joint
///
void setAttachedBody(const ChppBodyShPtr& inBody);
///
/// \brief Get the body attached to the joint
///
ChppBodyShPtr attachedBody() const;
///
/// @}
///
///
/// \name CkppComponent properties
/// @{
///
void fillPropertyVector(std::vector<CkppPropertyShPtr>& outPropertyVector)
const;
// 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:
Joint();
/// \brief Create properties and store weak pointer
ktStatus init(const JointWkPtr& weakPtr);
private:
JointWkPtr weakPtr_;
}; // class Joint
} // namespace model
} // namespace hpp
std::ostream& operator<<(std::ostream& os, const hpp::model::Joint& joint);
#endif // HPP_MODEL_JOINT_COMMON_HH
#
# Copyright (c) 2011 CNRS
# Authors: Florent Lamiraux
#
#
# This file is part of hpp-model
# hpp-model is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
#
# hpp-model is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Lesser Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with
# hpp-model If not, see
# <http://www.gnu.org/licenses/>.
SET(LIBRARY_NAME ${PROJECT_NAME})
ADD_LIBRARY(${LIBRARY_NAME}
SHARED
body.cc
joint.cc
freeflyer-joint.cc
)
SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} jrl-dynamics)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} kwsIO)
INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION lib)
///
/// Copyright (c) 2011 CNRS
/// Authors: Florent Lamiraux
///
///
// This file is part of hpp-model
// hpp-model is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// hpp-model is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// hpp-model If not, see
// <http://www.gnu.org/licenses/>.
#include <iostream>
#include <sstream>
#include <string>
#include "hpp/model/joint.hh"
#include "hpp/model/freeflyer-joint.hh"
#include "hpp/model/exception.hh"
namespace hpp {
namespace model {
FreeflyerJointShPtr FreeflyerJoint::create(const std::string& name,
const CkitMat4& initialPosition)
{
FreeflyerJoint *ptr = new FreeflyerJoint(initialPosition);
FreeflyerJointShPtr shPtr = FreeflyerJointShPtr(ptr);
FreeflyerJointWkPtr wkPtr = FreeflyerJointWkPtr(shPtr);
if (ptr->init(wkPtr, name, initialPosition) != KD_OK) {
shPtr.reset();
return shPtr;
}
return shPtr;
}
void FreeflyerJoint::
fillPropertyVector(std::vector<CkppPropertyShPtr>& outPropertyVector)
const
{
CkppFreeFlyerJointComponent::fillPropertyVector(outPropertyVector);
Joint::fillPropertyVector(outPropertyVector);
}
FreeflyerJoint::FreeflyerJoint(const CkitMat4& initialPosition) :
hpp::model::Joint(),
CkppFreeFlyerJointComponent(),
dynamicsJRLJapan::JointFreeflyer
(Joint::abstractMatrixFromCkitMat4(initialPosition))
{
}
FreeflyerJoint::~FreeflyerJoint()
{
}
ktStatus FreeflyerJoint::init (const FreeflyerJointWkPtr &inWeakPtr,
const std::string &name,
const CkitMat4& initialPosition)
{
ktStatus status = KD_OK;
weakPtr_ = inWeakPtr;
status = CkppFreeFlyerJointComponent::init(inWeakPtr, name);
if (status == KD_ERROR) return KD_ERROR;
status = Joint::init(inWeakPtr);
if (status == KD_ERROR) return KD_ERROR;
kwsJoint()->setCurrentPosition(initialPosition);
return KD_OK;
}
} // namespace model
} // namespace hpp
///
/// Copyright (c) 2011 CNRS
/// Authors: Florent Lamiraux
///
///
// This file is part of hpp-model
// hpp-model is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// hpp-model is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// hpp-model If not, see
// <http://www.gnu.org/licenses/>.
#include <iostream>
#include <sstream>
#include <string>
#include <KineoModel/kppDoubleProperty.h>
#include <KineoModel/kppJointComponent.h>
#include <KineoWorks2/kwsJoint.h>
#include <KineoWorks2/kwsJointDof.h>
#include <kwsIO/kwsioMat.h>
#include <jrl/mal/matrixabstractlayer.hh>
#include <abstract-robot-dynamics/joint.hh>
#include "hpp/model/joint.hh"
#include "hpp/model/body.hh"
#include "hpp/model/exception.hh"
using hpp::model::Joint;
using hpp::model::JointShPtr;
using hpp::model::JointWkPtr;
using hpp::model::Exception;
// Mass
const CkppProperty::TPropertyID
Joint::MASS