Skip to content

Commit

Permalink
[ikin] fix handling of limbs versions
Browse files Browse the repository at this point in the history
  • Loading branch information
pattacini committed Oct 24, 2022
1 parent 8631bb2 commit 13c8d30
Show file tree
Hide file tree
Showing 17 changed files with 362 additions and 133 deletions.
2 changes: 1 addition & 1 deletion src/libraries/actionPrimitives/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ add_library(ICUB::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")

target_link_libraries(${PROJECT_NAME} perceptiveModels ${YARP_LIBRARIES})
target_link_libraries(${PROJECT_NAME} iKin perceptiveModels ${YARP_LIBRARIES})


set_target_properties(${PROJECT_NAME} PROPERTIES
Expand Down
6 changes: 4 additions & 2 deletions src/libraries/actionPrimitives/src/actionPrimitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <yarp/math/Rand.h>

#include <iCub/ctrl/math.h>
#include <iCub/iKin/iKinFwd.h>
#include <iCub/perception/springyFingers.h>
#include <iCub/perception/tactileFingers.h>
#include <iCub/action/actionPrimitives.h>
Expand Down Expand Up @@ -57,6 +58,7 @@ using namespace yarp::dev;
using namespace yarp::sig;
using namespace yarp::math;
using namespace iCub::ctrl;
using namespace iCub::iKin;
using namespace iCub::perception;
using namespace iCub::action;

Expand Down Expand Up @@ -407,9 +409,9 @@ bool ActionPrimitives::handleTorsoDOF(Property &opt, const string &key)
{
Bottle info;
cartCtrl->getInfo(info);
double hwver=info.find("arm_version").asFloat64();
iKinLimbVersion hwver(info.find("arm_version").asString());
map<string,int> remap{{ACTIONPRIM_TORSO_PITCH,0},{ACTIONPRIM_TORSO_ROLL,1},{ACTIONPRIM_TORSO_YAW,2}};
if (hwver>=3.0)
if (hwver>=iKinLimbVersion("3.0"))
{
remap[ACTIONPRIM_TORSO_ROLL]=0;
remap[ACTIONPRIM_TORSO_PITCH]=1;
Expand Down
124 changes: 118 additions & 6 deletions src/libraries/iKin/include/iCub/iKin/iKinFwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,118 @@ class iKinLimb : public iKinChain
};


/**
* \ingroup iKinFwd
*
* A class for defining the versions of the iCub limbs.
*/
class iKinLimbVersion
{
protected:
unsigned long int major;
unsigned long int minor;

public:
/**
* Default Constructor.
*/
iKinLimbVersion();

/**
* Constructor.
* @param version is a string for specifying different
* kinematics, e.g., "1.23".
*/
iKinLimbVersion(const std::string &version);

/**
* Constructor.
* @param major the major version.
* @param minor the mninor version.
*/
iKinLimbVersion(const unsigned long int major, const unsigned long int minor);

/**
* Copy Constructor.
*/
iKinLimbVersion(const iKinLimbVersion& v);

/**
* Return the major version.
* @return the major version.
*/
unsigned long int get_major() const;

/**
* Return the minor version.
* @return the minor version.
*/
unsigned long int get_minor() const;

/**
* Return the version string.
* @return the version string.
*/
std::string get_version() const;

/**
* Overloaded assignment operator.
* @param v the version to be assigned.
* @return .
*/
iKinLimbVersion& operator=(const iKinLimbVersion& v);

/**
* Overloaded < operator.
* @param v the version to compare with.
* @return true iff < v.
*/
bool operator<(const iKinLimbVersion& v) const;

/**
* Overloaded <= operator.
* @param v the version to compare with.
* @return true iff <= v.
*/
bool operator<=(const iKinLimbVersion& v) const;

/**
* Overloaded == operator.
* @param v the version to compare with.
* @return true iff == v.
*/
bool operator==(const iKinLimbVersion& v) const;

/**
* Overloaded != operator.
* @param v the version to compare with.
* @return true iff != v.
*/
bool operator!=(const iKinLimbVersion& v) const;

/**
* Overloaded >=</=> operator.
* @param v the version to compare with.
* @return true iff >= v.
*/
bool operator>=(const iKinLimbVersion& v) const;

/**
* Overloaded > operator.
* @param v the version to compare with.
* @return true iff > v.
*/
bool operator>(const iKinLimbVersion& v) const;

/**
* Overloaded - operator.
* @param v the version to compare with.
* @return the distance from v.
*/
iKinLimbVersion operator-(const iKinLimbVersion& v) const;
};


/**
* \ingroup iKinFwd
*
Expand All @@ -1045,7 +1157,7 @@ class iKinLimb : public iKinChain
class iCubTorso : public iKinLimb
{
protected:
double version;
iKinLimbVersion version;

virtual void allocate(const std::string &_type);

Expand Down Expand Up @@ -1081,7 +1193,7 @@ class iCubTorso : public iKinLimb
class iCubArm : public iKinLimb
{
protected:
double version;
iKinLimbVersion version;

virtual void allocate(const std::string &_type);

Expand Down Expand Up @@ -1236,7 +1348,7 @@ class iCubFinger : public iKinLimb
class iCubLeg : public iKinLimb
{
protected:
double version;
iKinLimbVersion version;

virtual void allocate(const std::string &_type);

Expand Down Expand Up @@ -1273,7 +1385,7 @@ class iCubLeg : public iKinLimb
class iCubEye : public iKinLimb
{
protected:
double version;
iKinLimbVersion version;

virtual void allocate(const std::string &_type);

Expand Down Expand Up @@ -1364,7 +1476,7 @@ class iCubHeadCenter : public iCubEye
class iCubInertialSensor : public iKinLimb
{
protected:
double version;
iKinLimbVersion version;

virtual void allocate(const std::string &_type);

Expand Down Expand Up @@ -1401,7 +1513,7 @@ class iCubInertialSensor : public iKinLimb
class iCubInertialSensorWaist : public iKinLimb
{
protected:
double version;
iKinLimbVersion version;

virtual void allocate(const std::string &_type);

Expand Down
Loading

0 comments on commit 13c8d30

Please sign in to comment.