Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[skinDynLib] Add linkName and frameName to dynContact and skinContact, and forceTorqueEstimateConfidence to skinContact #462

Closed
wants to merge 10 commits into from
Closed
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ before_script:
script:

- cmake --build .
- ctest --output-on-failure --build .
- sudo make install
- sudo make uninstall

5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ else (NOT ICUB_HAS_GSL)
endif (NOT ICUB_HAS_GSL)

### enable testing
option(BUILD_TESTING "Compile tests" OFF)
if(BUILD_TESTING)
enable_testing()
endif()

option(ICUB_DASHBOARD_SUBMIT "Submit compile tests to cdash" FALSE)

if (ICUB_DASHBOARD_SUBMIT)
Expand Down
1 change: 1 addition & 0 deletions admin/scripts/generate-cmake-options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CMAKE_OPTIONS="\
-DTEST_MACHINE_HOSTNAME:STRING=$1 \
-DTEST_MACHINE_OS_TYPE:STRING=$2 \
-DTEST_MACHINE_TEST_TYPE:STRING=$3 \
-DBUILD_TESTING:BOOL=TRUE \
-DENABLE_icubmod_cartesiancontrollerclient:BOOL=TRUE \
-DENABLE_icubmod_cartesiancontrollerserver:BOOL=TRUE \
-DENABLE_icubmod_gazecontrollerclient:BOOL=TRUE \
Expand Down
2 changes: 1 addition & 1 deletion conf/iCubVersion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

set(ICUB_VERSION_MAJOR "1")
set(ICUB_VERSION_MINOR "9")
set(ICUB_VERSION_PATCH "0")
set(ICUB_VERSION_PATCH "1")
set(ICUB_VERSION "${ICUB_VERSION_MAJOR}.${ICUB_VERSION_MINOR}.${ICUB_VERSION_PATCH}")

set(ICUB_VERSION_MODIFIER "")
Expand Down
16 changes: 16 additions & 0 deletions src/doc/release/v1_10_0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
iCub 1.10.0 (UNRELEASED) Release Notes
========================

New Features
------------

### Libraries

#### `skinDynLib`
Add `linkName` and `frameName` attributes to `iCub::skinDynLib::dynContact` and `iCub::skinDynLib::skinContact`, to simplify
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I wrong or going to a newline in markdown has no effect? I think that writing paragraphs on a single line is the best choice, and new line behavior should be handled by the soft wrap configuration of the editor the user uses.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several reasons why I prefer to break paragraph in raw Markdown, even if this has no effect on the rendered document:

  • Small lines simplify the usage of git, as merging, diffing, conflicts, etc etc is all managed at line (in the raw document) level
  • One of the main features of Markdown is to be quite readable even when it not rendered, and (at least in my case) I typically edit Markdown parallel with source code, meaning that no soft wrap is enabled in the editor.

interfacing with software in which link and frames are identified by names, such as software that load the robot description
from file formats like URDF and SDF. This attributes have been also added to the on-wire representation of this class, creating
an incompatibility between versions of iCub before 1.8 and version after 1.10 , meaning that a module compiled with iCub 1.8 will
not be able to communicate with a module compiled with iCub 1.10 . Recompiling all your software with iCub 1.10 (without any modification
to the source code) should be sufficient to ensure that everything works fine.

3 changes: 3 additions & 0 deletions src/libraries/skinDynLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ icub_export_library(${PROJECTNAME} INTERNAL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/i
DESTINATION include/iCub/skinDynLib
FILES ${folder_header})

if(BUILD_TESTING)
add_subdirectory(test)
endif()

23 changes: 23 additions & 0 deletions src/libraries/skinDynLib/include/iCub/skinDynLib/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,29 @@ inline std::list<unsigned int> vectorofIntEqualto(const std::vector<int> vec, co
return res;
};

/**
* \brief Macro to deprecate functions and methods
*
* see https://blog.samat.io/2017/02/27/Deprecating-functions-and-methods-in-Cplusplus/
*/
// C++14
#if __cplusplus >= 201402L
#if defined(__has_cpp_attribute)
#if __has_cpp_attribute(deprecated)
#define SKINDYNLIB_DEPRECATED(msg) [[deprecated(msg)]]
#endif
#endif
// Earlier standards
#else
#if defined(__GNUC__) || defined(__clang__)
#define SKINDYNLIB_DEPRECATED(msg) __attribute__((deprecated(msg)))
#elif defined(_MSC_VER)
#define SKINDYNLIB_DEPRECATED(msg) __declspec(deprecated(msg))
#else
#define SKINDYNLIB_DEPRECATED(msg)
#endif
#endif

}

}//end namespace
Expand Down
40 changes: 31 additions & 9 deletions src/libraries/skinDynLib/include/iCub/skinDynLib/dynContact.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class dynContact : public yarp::os::Portable
BodyPart bodyPart;
/// number of the link where the contact is applied
unsigned int linkNumber;
/// center of pressure of the contact expressed w.r.t. the reference frame of the link
/// center of pressure of the contact expressed w.r.t. the reference frame
yarp::sig::Vector CoP;
///contact force direction (unit vector)
yarp::sig::Vector Fdir;
Expand All @@ -79,6 +79,10 @@ class dynContact : public yarp::os::Portable
///verbosity flag
unsigned int verbose;

/// name of the link on which the contact is applied
std::string linkName;
/// name of the frame on which all the vector quantities are expressed
std::string frameName;

void init(const BodyPart &_bodyPart, unsigned int _linkNumber, const yarp::sig::Vector &_CoP,
const yarp::sig::Vector &_Mu=yarp::sig::Vector(0), const yarp::sig::Vector &_Fdir=yarp::sig::Vector(0));
Expand Down Expand Up @@ -147,7 +151,7 @@ class dynContact : public yarp::os::Portable
*/
virtual const yarp::sig::Vector& getMoment() const;
/**
* Get the contact center of pressure expressed in the link reference frame.
* Get the contact center of pressure expressed in the reference frame.
* @return a 3-dim vector
*/
virtual const yarp::sig::Vector& getCoP() const;
Expand All @@ -171,7 +175,16 @@ class dynContact : public yarp::os::Portable
* @return the contact id
*/
virtual unsigned long getId() const;

/**
* Get the name of the link on which the contact is applied.
* @return the link name
*/
virtual std::string getLinkName() const;
/**
* Get the name of the frame in which the quantities of this contact are expressed.
* @return the link name
*/
virtual std::string getFrameName() const;
//~~~~~~~~~~~~~~~~~~~~~~
// IS methods
//~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -228,23 +241,29 @@ class dynContact : public yarp::os::Portable
*/
virtual bool setForceMoment(const yarp::sig::Vector &_FMu);
/**
* Set the contact center of pressure in link reference frame
* Set the contact center of pressure in reference frame
* @param _CoP a 3x1 vector
* @return true if the operation succeeded, false otherwise
*/
virtual bool setCoP(const yarp::sig::Vector &_CoP);
/**
* Set the contact link number (0 is the first link)
* @param _linkNum the link number
* @return true if the operation succeeded, false otherwise
*/
virtual void setLinkNumber(unsigned int _linkNum);
/**
* Set the body part of this contact
* @param _bodyPart the contact body part
* @return true if the operation succeeded, false otherwise
*/
virtual void setBodyPart(BodyPart _bodyPart);
/**
* Set the name of the link on which the contact is applied.
*/
virtual void setLinkName(const std::string & _linkName);
/**
* Set the name of the frame in which the quantities of this contact are expressed.
*/
virtual void setFrameName(const std::string & _linkName);

//~~~~~~~~~~~~~~~~~~~~~~
// FIX/UNFIX methods
Expand Down Expand Up @@ -288,21 +307,23 @@ class dynContact : public yarp::os::Portable
// SERIALIZATION methods
//~~~~~~~~~~~~~~~~~~~~~~
/*
* Read dynContact from a connection. It expects a list of 4 elements, that are:
* Read dynContact from a connection. It expects a list of 5 elements, that are:
* - a list of 3 int, containing contactId, bodyPart and linkNumber
* - a list of 3 double, containing the CoP
* - a list of 3 double, containing the force
* - a list of 3 double, containing the moment
* - a list of 2 strings, containing linkName, frameName
* @param connection the connection to read from
* @return true iff a dynContact was read correctly
*/
virtual bool read(yarp::os::ConnectionReader& connection);
/**
* Write dynContact to a connection as a list of 4 elements, that are:
* Write dynContact to a connection as a list of 5 elements, that are:
* - a list of 3 int, containing contactId, bodyPart, linkNumber
* - a list of 3 double, containing the CoP
* - a list of 3 double, containing the force
* - a list of 3 double, containing the moment
* - a list of 2 strings, containing linkName, frameName
* @param connection the connection to write to
* @return true iff the dynContact was written correctly
*/
Expand All @@ -313,7 +334,8 @@ class dynContact : public yarp::os::Portable
* Convert this contact into a string. Useful to print some information.
* @param precision number of decimal digits to use in the string representation
* @return a string representation of this contact in this format:
* "Contact id: "<< contactId<< "Body part: "<< bodyPartName<< ", link: "<< linkNumber<<
* "Contact id: "<< contactId<< ", link name: "<< linkName << ", frame name: " << frameName <<
* ", Body part: "<< bodyPartName<< ", link index: "<< linkNumber<<
* ", CoP: "<< CoP<< ", F: "<< F<< ", M: "<< Mu
*/
virtual std::string toString(int precision=-1) const;
Expand Down
27 changes: 26 additions & 1 deletion src/libraries/skinDynLib/include/iCub/skinDynLib/skinContact.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ class skinContact : public dynContact
unsigned int activeTaxels;
// list of active taxel ids
std::vector<unsigned int> taxelList;

// non-zero integer representing the confidence on the provided force/torque estimate provided (default: 0)
unsigned int forceTorqueEstimateConfidence;


public:
//~~~~~~~~~~~~~~~~~~~~~~
// CONSTRUCTORS
Expand Down Expand Up @@ -187,6 +190,12 @@ class skinContact : public dynContact
* @return the list of taxels' id's
*/
std::vector<unsigned int> getTaxelList() const{ return taxelList; }
/**
* Get a non-zero integer representing the confidence in the provided force/torque estimate.
* @return the forceTorqueEstimateConfidence
* @note the concrete meaning of this parameter is implementation defined.
*/
unsigned int getForceTorqueEstimateConfidence() const{ return forceTorqueEstimateConfidence; }


//~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -228,6 +237,12 @@ class skinContact : public dynContact
* @return true if the operation succeeded, false otherwise
*/
void setTaxelList(const std::vector<unsigned int> &list);
/**
* Set a non-zero integer representing the confidence in the provided force/torque estimate.
* @param forceTorqueEstimateConfidence
* @note the concrete meaning of this parameter is implementation defined.
*/
void setForceTorqueEstimateConfidence(unsigned int forceTorqueEstimateConfidence);

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// SERIALIZATION methods
Expand All @@ -250,6 +265,8 @@ class skinContact : public dynContact
* - a list of 3 double, i.e. the normal direction
* - a list of N int, i.e. the active taxel ids
* - a double, i.e. the pressure
* - a list of 2 strings, containing linkName, frameName
* - a int, the forceTorqueEstimateConfidence
* @param connection connection to write to
* @return true iff a skinContact was written correctly
*/
Expand All @@ -271,7 +288,11 @@ class skinContact : public dynContact
* 20-?: list of the id's of the activated taxels;
* ?: pressure;
* @return a Vector representation of this skinContact
* @deprecated This method is deprecated since iCub 1.10, as it is not able to serialize string attribute
* such as linkName and frameName . Please use yarp::os::Portable facilities to serialize this class.
*/
SKINDYNLIB_DEPRECATED("toVector is not able to serialize string attributes such as "
"linkName and frameName. Please use yarp::os::Portable facilities to serialize this class.")
virtual yarp::sig::Vector toVector() const;

/**
Expand All @@ -291,7 +312,11 @@ class skinContact : public dynContact
* ?: pressure;
* @param v the vector to convert into a skinContact
* @return true iff operation succeeded, false otherwise
* @deprecated This method is deprecated since iCub 1.10, as it is not able to serialize string attribute
* such as linkName and frameName . Please use yarp::os::Portable facilities to serialize this class.
*/
SKINDYNLIB_DEPRECATED("fromVector is not able to serialize string attributes such as "
"linkName and frameName. Please use yarp::os::Portable facilities to serialize this class.")
virtual bool fromVector(const yarp::sig::Vector &v);

/**
Expand Down
Loading