Skip to content

Commit

Permalink
Retrieve latest joint fault state from firmware for exposition toward…
Browse files Browse the repository at this point in the history
…s client (#779)
  • Loading branch information
mfussi66 authored Dec 16, 2021
1 parent 5582e9e commit b9bf23c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(ICUB_COMPILE_BINDINGS "Compile optional language bindings" FALSE)

set(YCM_REQUIRED_VERSION 0.13.0)
set(YARP_REQUIRED_VERSION 3.5.1)
set(YARP_REQUIRED_VERSION 3.5.100)

find_package(YCM ${YCM_REQUIRED_VERSION} REQUIRED)
find_package(YARP ${YARP_REQUIRED_VERSION} REQUIRED)
Expand Down
4 changes: 2 additions & 2 deletions conf/iCubFindDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ checkandset_dependency(Qt5)

if(icub_firmware_shared_FOUND AND ICUB_USE_icub_firmware_shared)
# icub-firmware-shared 4.0.7 was actually a wrong version exported by icub-firmware-shared <= 1.15
if(icub_firmware_shared_VERSION VERSION_GREATER 4 OR icub_firmware_shared_VERSION VERSION_LESS 1.22.1)
message(FATAL_ERROR "An old version of icub-firmware-shared has been detected, but at least 1.22.1 is required")
if(icub_firmware_shared_VERSION VERSION_GREATER 4 OR icub_firmware_shared_VERSION VERSION_LESS 1.22.2)
message(FATAL_ERROR "An old version of icub-firmware-shared has been detected, but at least 1.22.2 is required")
endif()
endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ embObjMotionControl::embObjMotionControl() :
ImplementAxisInfo(this),
ImplementPWMControl(this),
ImplementCurrentControl(this),
ImplementJointFault(this),
SAFETY_THRESHOLD(2.0),
_rotorsLimits(0),
_jointsLimits(0),
Expand Down Expand Up @@ -321,6 +322,7 @@ bool embObjMotionControl::initializeInterfaces(measureConvFactors &f)
ImplementAxisInfo::initialize(_njoints, _axisMap);
ImplementCurrentControl::initialize(_njoints, _axisMap, f.ampsToSensor);
ImplementPWMControl::initialize(_njoints, _axisMap, f.dutycycleToPWM);
ImplementJointFault::initialize(_njoints, _axisMap);

return true;

Expand Down Expand Up @@ -1245,7 +1247,7 @@ bool embObjMotionControl::init()
{
protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, n, eoprot_tag_mc_joint_status_core);
id32v.push_back(protid);
protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, n, eoprot_tag_mc_motor_status_basic);
protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, n, eoprot_tag_mc_motor_status);
id32v.push_back(protid);
}

Expand Down Expand Up @@ -1435,6 +1437,7 @@ bool embObjMotionControl::close()
ImplementAxisInfo::uninitialize();
ImplementCurrentControl::uninitialize();
ImplementPWMControl::uninitialize();
ImplementJointFault::uninitialize();

if (_measureConverter) {delete _measureConverter; _measureConverter=0;}

Expand Down Expand Up @@ -5256,4 +5259,37 @@ bool embObjMotionControl::getMotorEncTolerance(int axis, double *mEncTolerance_p
return true;
}

bool embObjMotionControl::getLastJointFaultRaw(int j, int& fault, std::string& message)
{
eOmc_motor_status_t status;

eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol,
eoprot_entity_mc_motor, j,
eoprot_tag_mc_motor_status);

bool ret = res->getLocalValue(protid, &status);

message.clear();

if (!ret)
{
fault = -1;
message = "Could not retrieve the fault state.";
return false;
}

if (status.mc_fault_state == EOERROR_CODE_DUMMY)
{
fault = EOERROR_CODE_DUMMY;
message = "No fault detected.";

return true;
}

fault = eoerror_code2value(status.mc_fault_state);
message = eoerror_code2string(status.mc_fault_state);

return true;
}

// eof
19 changes: 13 additions & 6 deletions src/libraries/icubmod/embObjMotionControl/embObjMotionControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ using namespace std;

#include <yarp/dev/IVirtualAnalogSensor.h>


#include<yarp/dev/ImplementJointFault.h>


#include "IethResource.h"
#include"EoError.h"
#include <ethManager.h>
#include <abstractEthResource.h>

Expand All @@ -55,6 +56,7 @@ using namespace std;

#include "mcEventDownsampler.h"


#ifdef NETWORK_PERFORMANCE_BENCHMARK
#include <PeriodicEventsVerifier.h>
#endif
Expand Down Expand Up @@ -179,10 +181,10 @@ class yarp::dev::embObjMotionControl: public DeviceDriver,
public ImplementPWMControl,
public ICurrentControlRaw,
public ImplementCurrentControl,
public eth::IethResource
public eth::IethResource,
public IJointFaultRaw,
public ImplementJointFault
{


private:

eth::TheEthManager* ethManager;
Expand All @@ -196,8 +198,6 @@ class yarp::dev::embObjMotionControl: public DeviceDriver,

MCdiagnostics mcdiagnostics;



/////configuartion info (read from xml files)
int _njoints; /** Number of joints handled by this EMS */
eomc::behaviour_flags_t behFlags; /** Contains all flags that define the behaviour of this device */
Expand Down Expand Up @@ -612,6 +612,13 @@ class yarp::dev::embObjMotionControl: public DeviceDriver,
virtual bool setRefCurrentsRaw(const int n_joint, const int *joints, const double *t) override;
virtual bool getRefCurrentsRaw(double *t) override;
virtual bool getRefCurrentRaw(int j, double *t) override;

// Used in joint faults interface
// Teturns true if it was successful and writes the fault code in the fault parameter
// with the associated string in message. If no fault is detected the fault parameters is set to -1.
// Returns false and fault is set to -2 if retrieval was unsuccessful.
virtual bool getLastJointFaultRaw(int j, int& fault, std::string& message) override;

};

#endif // include guard

0 comments on commit b9bf23c

Please sign in to comment.