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

Retrieve latest joint fault state from firmware for exposition towards client #779

Merged
merged 14 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,29 @@ 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;
}

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

return true;
}

// eof
16 changes: 10 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,10 @@ 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
virtual bool getLastJointFaultRaw(int j, int& fault, std::string& message) override;

};

#endif // include guard