Skip to content

Commit

Permalink
Provide forward compatibility with YARP 3.x (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Apr 27, 2018
1 parent 551a5fc commit 2ff7cf3
Show file tree
Hide file tree
Showing 21 changed files with 269 additions and 215 deletions.
48 changes: 25 additions & 23 deletions libraries/YarpPlugins/CanBusControlboard/CanBusControlboard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,6 @@ class CanBusControlboard : public yarp::dev::DeviceDriver, public yarp::dev::ICo
*/
virtual bool getTargetPositions(const int n_joint, const int *joints, double *refs);



// ------- IPositionDirect declarations. Implementation in IPositionDirectImpl.cpp -------

/** Set new position for a single axis.
Expand Down Expand Up @@ -581,27 +579,6 @@ class CanBusControlboard : public yarp::dev::DeviceDriver, public yarp::dev::ICo
*/
virtual bool setRefTorque(int j, double t);

/** Set the back-efm compensation gain for a given joint.
* @param j joint number
* @param bemf the returned bemf gain of joint j
* @return true/false on success/failure
*/
virtual bool getBemfParam(int j, double *bemf);

/** Set the back-efm compensation gain for a given joint.
* @param j joint number
* @param bemf new value
* @return true/false on success/failure
*/
virtual bool setBemfParam(int j, double bemf);

/** Set new pid value for a joint axis.
* @param j joint number
* @param pid new pid value
* @return true/false on success/failure
*/
virtual bool setTorquePid(int j, const yarp::dev::Pid &pid);

/** Get the value of the torque on a given joint (this is the
* feedback if you have a torque sensor).
* @param j joint number
Expand Down Expand Up @@ -632,6 +609,28 @@ class CanBusControlboard : public yarp::dev::DeviceDriver, public yarp::dev::ICo
*/
virtual bool getTorqueRanges(double *min, double *max);

#if YARP_VERSION_MAJOR != 3
/** Set the back-efm compensation gain for a given joint.
* @param j joint number
* @param bemf the returned bemf gain of joint j
* @return true/false on success/failure
*/
virtual bool getBemfParam(int j, double *bemf);

/** Set the back-efm compensation gain for a given joint.
* @param j joint number
* @param bemf new value
* @return true/false on success/failure
*/
virtual bool setBemfParam(int j, double bemf);

/** Set new pid value for a joint axis.
* @param j joint number
* @param pid new pid value
* @return true/false on success/failure
*/
virtual bool setTorquePid(int j, const yarp::dev::Pid &pid);

/** Set new pid value on multiple axes.
* @param pids pointer to a vector of pids
* @return true/false upon success/failure
Expand Down Expand Up @@ -729,6 +728,7 @@ class CanBusControlboard : public yarp::dev::DeviceDriver, public yarp::dev::ICo
* @return true/false on success/failure
*/
virtual bool setTorqueOffset(int j, double v);
#endif // YARP_VERSION_MAJOR != 3

// --------- IVelocityControl Declarations. Implementation in IVelocityControl2Impl.cpp ---------

Expand Down Expand Up @@ -805,6 +805,7 @@ class CanBusControlboard : public yarp::dev::DeviceDriver, public yarp::dev::ICo
*/
// virtual bool stop(const int n_joint, const int *joints);

#if YARP_VERSION_MAJOR != 3
/** Set new velocity pid value for a joint
* @param j joint number
* @param pid new pid value
Expand All @@ -830,6 +831,7 @@ class CanBusControlboard : public yarp::dev::DeviceDriver, public yarp::dev::ICo
* @return success/failure
*/
virtual bool getVelPids(yarp::dev::Pid *pids);
#endif // YARP_VERSION_MAJOR != 3

// -----------IInteracionMode Declarations. Implementation in IInteracionModeImpl.cpp --------------
/**
Expand Down
72 changes: 37 additions & 35 deletions libraries/YarpPlugins/CanBusControlboard/ITorqueControlImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,90 +57,91 @@ bool roboticslab::CanBusControlboard::setRefTorque(int j, double t)

// -----------------------------------------------------------------------------

bool roboticslab::CanBusControlboard::getBemfParam(int j, double *bemf)
bool roboticslab::CanBusControlboard::getTorque(int j, double *t)
{
CD_DEBUG("(%d)\n",j);
//CD_INFO("(%d)\n",j); //-- Too verbose in controlboardwrapper2 stream.

//-- Check index within range
if ( ! this->indexWithinRange(j) ) return false;

return iTorqueControlRaw[j]->getBemfParamRaw( 0, bemf );;
return iTorqueControlRaw[j]->getTorqueRaw( 0, t );;
}

// -----------------------------------------------------------------------------

bool roboticslab::CanBusControlboard::setBemfParam(int j, double bemf)
bool roboticslab::CanBusControlboard::getTorques(double *t)
{
CD_DEBUG("(%d,%f)\n",j,bemf);

//-- Check index within range
if ( ! this->indexWithinRange(j) ) return false;
CD_DEBUG("\n");

return iTorqueControlRaw[j]->setBemfParamRaw( 0, bemf );;
bool ok = true;
for(int j=0; j<nodes.size(); j++)
{
ok &= this->getTorque(j, &(t[j]));
}
return ok;
}

// -----------------------------------------------------------------------------

bool roboticslab::CanBusControlboard::setTorquePid(int j, const yarp::dev::Pid &pid)
bool roboticslab::CanBusControlboard::getTorqueRange(int j, double *min, double *max)
{
CD_DEBUG("(%d)\n",j);

//-- Check index within range
if ( ! this->indexWithinRange(j) ) return false;

return iTorqueControlRaw[j]->setTorquePidRaw( 0, pid );;
}

// -----------------------------------------------------------------------------

bool roboticslab::CanBusControlboard::getTorque(int j, double *t)
{
//CD_INFO("(%d)\n",j); //-- Too verbose in controlboardwrapper2 stream.

//-- Check index within range
if ( ! this->indexWithinRange(j) ) return false;

return iTorqueControlRaw[j]->getTorqueRaw( 0, t );;
return iTorqueControlRaw[j]->getTorqueRangeRaw( 0, min, max );
}

// -----------------------------------------------------------------------------

bool roboticslab::CanBusControlboard::getTorques(double *t)
bool roboticslab::CanBusControlboard::getTorqueRanges(double *min, double *max)
{
CD_DEBUG("\n");

bool ok = true;
for(int j=0; j<nodes.size(); j++)
{
ok &= this->getTorque(j, &(t[j]));
ok &= this->getTorqueRange(j, min, max);
}
return ok;
}

// -----------------------------------------------------------------------------

bool roboticslab::CanBusControlboard::getTorqueRange(int j, double *min, double *max)
#if YARP_VERSION_MAJOR != 3
bool roboticslab::CanBusControlboard::getBemfParam(int j, double *bemf)
{
CD_DEBUG("(%d)\n",j);

//-- Check index within range
if ( ! this->indexWithinRange(j) ) return false;

return iTorqueControlRaw[j]->getTorqueRangeRaw( 0, min, max );
return iTorqueControlRaw[j]->getBemfParamRaw( 0, bemf );;
}

// -----------------------------------------------------------------------------

bool roboticslab::CanBusControlboard::getTorqueRanges(double *min, double *max)
bool roboticslab::CanBusControlboard::setBemfParam(int j, double bemf)
{
CD_DEBUG("\n");
CD_DEBUG("(%d,%f)\n",j,bemf);

bool ok = true;
for(int j=0; j<nodes.size(); j++)
{
ok &= this->getTorqueRange(j, min, max);
}
return ok;
//-- Check index within range
if ( ! this->indexWithinRange(j) ) return false;

return iTorqueControlRaw[j]->setBemfParamRaw( 0, bemf );;
}

// -----------------------------------------------------------------------------

bool roboticslab::CanBusControlboard::setTorquePid(int j, const yarp::dev::Pid &pid)
{
CD_DEBUG("(%d)\n",j);

//-- Check index within range
if ( ! this->indexWithinRange(j) ) return false;

return iTorqueControlRaw[j]->setTorquePidRaw( 0, pid );;
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -336,3 +337,4 @@ bool roboticslab::CanBusControlboard::setTorqueOffset(int j, double v)
}

// -----------------------------------------------------------------------------
#endif // YARP_VERSION_MAJOR != 3
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bool roboticslab::CanBusControlboard::velocityMove(int j, double sp)
CD_DEBUG("(%d), (%f)\n",j , sp);

//-- Check index within range
if ( ! this->indexWithinRange(j) ) return false;
if ( ! this->indexWithinRange(j) ) return false;

return iVelocityControl2Raw[j]->velocityMoveRaw( 0, sp );
}
Expand Down Expand Up @@ -85,6 +85,7 @@ bool roboticslab::CanBusControlboard::getRefVelocities(const int n_joint, const

// -----------------------------------------------------------------------------

#if YARP_VERSION_MAJOR != 3
bool roboticslab::CanBusControlboard::setVelPid(int j, const yarp::dev::Pid &pid)
{
return true;
Expand All @@ -110,3 +111,6 @@ bool roboticslab::CanBusControlboard::getVelPids(yarp::dev::Pid *pids)
{
return true;
}

// -----------------------------------------------------------------------------
#endif // YARP_VERSION_MAJOR != 3
10 changes: 7 additions & 3 deletions libraries/YarpPlugins/CuiAbsolute/CuiAbsolute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,14 @@ class CuiAbsolute : public yarp::dev::DeviceDriver, public yarp::dev::IControlLi
virtual bool getRefTorqueRaw(int j, double *t);
virtual bool setRefTorquesRaw(const double *t);
virtual bool setRefTorqueRaw(int j, double t);
virtual bool getBemfParamRaw(int j, double *bemf);
virtual bool setBemfParamRaw(int j, double bemf);
virtual bool setTorquePidRaw(int j, const yarp::dev::Pid &pid);
virtual bool getTorqueRaw(int j, double *t);
virtual bool getTorquesRaw(double *t);
virtual bool getTorqueRangeRaw(int j, double *min, double *max);
virtual bool getTorqueRangesRaw(double *min, double *max);
#if YARP_VERSION_MAJOR != 3
virtual bool getBemfParamRaw(int j, double *bemf);
virtual bool setBemfParamRaw(int j, double bemf);
virtual bool setTorquePidRaw(int j, const yarp::dev::Pid &pid);
virtual bool setTorquePidsRaw(const yarp::dev::Pid *pids);
virtual bool setTorqueErrorLimitRaw(int j, double limit);
virtual bool setTorqueErrorLimitsRaw(const double *limits);
Expand All @@ -177,6 +178,7 @@ class CuiAbsolute : public yarp::dev::DeviceDriver, public yarp::dev::IControlLi
virtual bool disableTorquePidRaw(int j);
virtual bool enableTorquePidRaw(int j);
virtual bool setTorqueOffsetRaw(int j, double v);
#endif // YARP_VERSION_MAJOR != 3

// --------- IVelocityControlRaw Declarations. Implementation in IVelocityControl2RawImpl.cpp ---------
virtual bool velocityMoveRaw(int j, double sp);
Expand All @@ -190,10 +192,12 @@ class CuiAbsolute : public yarp::dev::DeviceDriver, public yarp::dev::IControlLi
// -- (just defined in IInteractionModeRaw) - virtual bool setRefAccelerationsRaw(const int n_joint, const int *joints, const double *accs);
// -- (just defined in IInteractionModeRaw) - virtual bool getRefAccelerationsRaw(const int n_joint, const int *joints, double *accs);
// -- (just defined in IInteractionModeRaw) - virtual bool stopRaw(const int n_joint, const int *joints);
#if YARP_VERSION_MAJOR != 3
virtual bool setVelPidRaw(int j, const yarp::dev::Pid &pid);
virtual bool setVelPidsRaw(const yarp::dev::Pid *pids);
virtual bool getVelPidRaw(int j, yarp::dev::Pid *pid);
virtual bool getVelPidsRaw(yarp::dev::Pid *pids);
#endif // YARP_VERSION_MAJOR != 3

// ------- IInteractionModeRaw declarations. Implementation in IInteractionModeRawImpl.cpp -------

Expand Down
35 changes: 18 additions & 17 deletions libraries/YarpPlugins/CuiAbsolute/ITorqueControlRawImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,47 @@ bool roboticslab::CuiAbsolute::setRefTorqueRaw(int j, double t)
return true;
}

bool roboticslab::CuiAbsolute::getBemfParamRaw(int j, double *bemf)
bool roboticslab::CuiAbsolute::getTorqueRaw(int j, double *t)
{
CD_INFO("\n");
//CD_INFO("\n"); //-- Too verbose in controlboardwrapper2 stream.
return true;
}

bool roboticslab::CuiAbsolute::setBemfParamRaw(int j, double bemf)
bool roboticslab::CuiAbsolute::getTorquesRaw(double *t)
{
CD_INFO("\n");
return true;
CD_ERROR("\n");
return false;
}

bool roboticslab::CuiAbsolute::setTorquePidRaw(int j, const yarp::dev::Pid &pid)
bool roboticslab::CuiAbsolute::getTorqueRangeRaw(int j, double *min, double *max)
{
CD_INFO("\n");
return true;
}

bool roboticslab::CuiAbsolute::getTorqueRaw(int j, double *t)
bool roboticslab::CuiAbsolute::getTorqueRangesRaw(double *min, double *max)
{
//CD_INFO("\n"); //-- Too verbose in controlboardwrapper2 stream.
return true;
CD_ERROR("\n");
return false;
}

bool roboticslab::CuiAbsolute::getTorquesRaw(double *t)
#if YARP_VERSION_MAJOR != 3
bool roboticslab::CuiAbsolute::getBemfParamRaw(int j, double *bemf)
{
CD_ERROR("\n");
return false;
CD_INFO("\n");
return true;
}

bool roboticslab::CuiAbsolute::getTorqueRangeRaw(int j, double *min, double *max)
bool roboticslab::CuiAbsolute::setBemfParamRaw(int j, double bemf)
{
CD_INFO("\n");
return true;
}

bool roboticslab::CuiAbsolute::getTorqueRangesRaw(double *min, double *max)
bool roboticslab::CuiAbsolute::setTorquePidRaw(int j, const yarp::dev::Pid &pid)
{
CD_ERROR("\n");
return false;
CD_INFO("\n");
return true;
}

bool roboticslab::CuiAbsolute::setTorquePidsRaw(const yarp::dev::Pid *pids)
Expand Down Expand Up @@ -157,4 +158,4 @@ bool roboticslab::CuiAbsolute::setTorqueOffsetRaw(int j, double v)
CD_INFO("\n");
return true;
}

#endif // YARP_VERSION_MAJOR != 3
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ bool roboticslab::CuiAbsolute::getRefVelocitiesRaw(const int n_joint, const int

// --------------------------------------------------------------------------------------------

#if YARP_VERSION_MAJOR != 3
bool roboticslab::CuiAbsolute::setVelPidRaw(int j, const yarp::dev::Pid &pid)
{
CD_ERROR("Missing implementation\n");
Expand Down Expand Up @@ -81,3 +82,4 @@ bool roboticslab::CuiAbsolute::getVelPidsRaw(yarp::dev::Pid *pids)
CD_ERROR("Missing implementation\n");
return false;
}
#endif // YARP_VERSION_MAJOR != 3
Loading

0 comments on commit 2ff7cf3

Please sign in to comment.