Skip to content

Commit

Permalink
Deprecate IControlMode::setXXXMode(int) methods
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed May 22, 2017
1 parent ed21bfb commit e5b2734
Show file tree
Hide file tree
Showing 13 changed files with 194 additions and 89 deletions.
7 changes: 7 additions & 0 deletions doc/release/v2_3_70.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ Important Changes
* Removed deprecated device ClientControlBoard and related tests.
* Removed deprecated device ServerControlBoard and related tests.
* iPIDControl class pulled out from ControlBoardInterfaces yarpdev headers and put in separated files. Reimplemented without templates.
* The following methods have been deprecated, use `IControlMode2::setControlMode(int, VOCAB_CM_XXX)` instead:
- `IControlMode::setPositionMode(int)`
- `IControlMode::setVelocityMode(int)`
- `IControlMode::setTorqueMode(int)`
- `IControlMode::setImpedancePositionMode(int)`
- `IControlMode::setImpedanceVelocityMode(int)`
- ...plus their IControlModeRaw counterparts


#### YARP_math
Expand Down
24 changes: 0 additions & 24 deletions src/devices/fakeMotionControl/fakeMotionControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1879,30 +1879,6 @@ bool FakeMotionControl::stopRaw(const int n_joint, const int *joints)
///////////// END Position Control INTERFACE //////////////////

// ControlMode
bool FakeMotionControl::setPositionModeRaw(int j)
{
return DEPRECATED("setPositionModeRaw");
}

bool FakeMotionControl::setVelocityModeRaw(int j)
{
return DEPRECATED("setVelocityModeRaw");
}

bool FakeMotionControl::setTorqueModeRaw(int j)
{
return DEPRECATED("setTorqueModeRaw");
}

bool FakeMotionControl::setImpedancePositionModeRaw(int j)
{
return DEPRECATED("setImpedancePositionModeRaw");
}

bool FakeMotionControl::setImpedanceVelocityModeRaw(int j)
{
return DEPRECATED("setImpedanceVelocityModeRaw");
}

// puo' essere richiesto con get
bool FakeMotionControl::getControlModeRaw(int j, int *v)
Expand Down
5 changes: 0 additions & 5 deletions src/devices/fakeMotionControl/fakeMotionControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,6 @@ class yarp::dev::FakeMotionControl : public DeviceDriver,
/////////////////////////////// END Position Control INTERFACE

// ControlMode
virtual bool setPositionModeRaw(int j);
virtual bool setVelocityModeRaw(int j);
virtual bool setTorqueModeRaw(int j);
virtual bool setImpedancePositionModeRaw(int j);
virtual bool setImpedanceVelocityModeRaw(int j);
virtual bool getControlModeRaw(int j, int *v);
virtual bool getControlModesRaw(int *v);

Expand Down
42 changes: 32 additions & 10 deletions src/libYARP_dev/include/yarp/dev/IControlMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,60 @@ class YARP_dev_API yarp::dev::IControlMode
public:
virtual ~IControlMode(){}

#ifndef YARP_NO_DEPRECATED // since YARP 2.3.70
/**
* Set position mode, single axis.
* @param j joint number
* @return: true/false success failure.
* @deprecated since YARP 2.3.70
*/
virtual bool setPositionMode(int j)=0;
YARP_DEPRECATED_MSG("Use IControlMode2::setControlMode(j, VOCAB_CM_POSITION) instead")
YARP_DEPRECATED virtual bool setPositionMode(int j) { return false; }

This comment has been minimized.

Copy link
@randaz81

randaz81 May 22, 2017

👍
This is more compact:

YARP_DEPRECATED virtual bool setPositionMode(int j)
{ IControlMode2* p; p=dynamic_cast<IControlMode2*>(this); 
 if (p)  {return p->setControlMode(j,VOCAB_CM_POSITION);} else {yError()<< "setPositionMode is DEPRECATED, use setControlMode(j,VOCAB_CM_POSITION) instead" ; return false;}}

You can now remove all references to setPositionMode() in ImplementXXXMode etc

This comment has been minimized.

Copy link
@PeterBowman

PeterBowman May 22, 2017

Author Owner

Hi, @randaz81, thank you for taking a look. I'm not sure if this is possible: I'd need to forward-declare IControlMode2, which then throws target is not pointer or reference to complete type errors upon dynamic cast. Apart from that, do you want to keep the YARP_DEPRECATED_MSG macro to produce hints at compile time? (I've noticed that the following YARP_DEPRECATED is superfluous, one of them will be removed)

#endif // YARP_NO_DEPRECATED

#ifndef YARP_NO_DEPRECATED // since YARP 2.3.70
/**
* Set velocity mode, single axis.
* @param j joint number
* @return: true/false success failure.
* @deprecated since YARP 2.3.70
*/
virtual bool setVelocityMode(int j)=0;
YARP_DEPRECATED_MSG("Use IControlMode2::setControlMode(j, VOCAB_CM_VELOCITY) instead")
YARP_DEPRECATED virtual bool setVelocityMode(int j) { return false; }
#endif // YARP_NO_DEPRECATED

#ifndef YARP_NO_DEPRECATED // since YARP 2.3.70
/**
* Set torque mode, single axis.
* @param j joint number
* @return: true/false success failure.
* @deprecated since YARP 2.3.70
*/
virtual bool setTorqueMode(int j)=0;
YARP_DEPRECATED_MSG("Use IControlMode2::setControlMode(j, VOCAB_CM_TORQUE) instead")
YARP_DEPRECATED virtual bool setTorqueMode(int j) { return false; }
#endif // YARP_NO_DEPRECATED

#ifndef YARP_NO_DEPRECATED // since YARP 2.3.70
/**
* Set impedance position mode, single axis.
* @param j joint number
* @return: true/false success failure.
* @deprecated since YARP 2.3.70
*/
virtual bool setImpedancePositionMode(int j)=0;
YARP_DEPRECATED_MSG("Use IControlMode2::setControlMode(j, VOCAB_CM_IMPEDANCE_POS) instead")
YARP_DEPRECATED virtual bool setImpedancePositionMode(int j) { return false; }
#endif // YARP_NO_DEPRECATED

#ifndef YARP_NO_DEPRECATED // since YARP 2.3.70
/**
* Set impedance velocity mode, single axis.
* @param j joint number
* @return: true/false success failure.
* @deprecated since YARP 2.3.70
*/
virtual bool setImpedanceVelocityMode(int j)=0;
YARP_DEPRECATED_MSG("Use IControlMode2::setControlMode(j, VOCAB_CM_IMPEDANCE_VEL) instead")
YARP_DEPRECATED virtual bool setImpedanceVelocityMode(int j) { return false; }
#endif // YARP_NO_DEPRECATED

/**
* Get the current control mode.
Expand Down Expand Up @@ -89,11 +109,13 @@ class yarp::dev::IControlModeRaw
public:
virtual ~IControlModeRaw(){}

virtual bool setPositionModeRaw(int j)=0;
virtual bool setVelocityModeRaw(int j)=0;
virtual bool setTorqueModeRaw(int j)=0;
virtual bool setImpedancePositionModeRaw(int j)=0;
virtual bool setImpedanceVelocityModeRaw(int j)=0;
#ifndef YARP_NO_DEPRECATED // since YARP 2.3.70
YARP_DEPRECATED virtual bool setPositionModeRaw(int j) { return false; }
YARP_DEPRECATED virtual bool setVelocityModeRaw(int j) { return false; }
YARP_DEPRECATED virtual bool setTorqueModeRaw(int j) { return false; }
YARP_DEPRECATED virtual bool setImpedancePositionModeRaw(int j) { return false; }
YARP_DEPRECATED virtual bool setImpedanceVelocityModeRaw(int j) { return false; }
#endif // YARP_NO_DEPRECATED
virtual bool getControlModeRaw(int j, int *mode)=0;
virtual bool getControlModesRaw(int* modes)=0;
};
Expand Down
4 changes: 4 additions & 0 deletions src/libYARP_dev/include/yarp/dev/IControlMode2.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ class YARP_dev_API yarp::dev::IControlMode2 : public yarp::dev::IControlMode
public:
virtual ~IControlMode2(){}

#ifndef YARP_NO_DEPRECATED // since YARP 2.3.70
using IControlMode::setPositionMode;
using IControlMode::setVelocityMode;
using IControlMode::setTorqueMode;
using IControlMode::setImpedancePositionMode;
using IControlMode::setImpedanceVelocityMode;
#endif // YARP_NO_DEPRECATED
using IControlMode::getControlMode;
using IControlMode::getControlModes;

Expand Down Expand Up @@ -96,11 +98,13 @@ class yarp::dev::IControlMode2Raw: public IControlModeRaw
public:
virtual ~IControlMode2Raw(){}

#ifndef YARP_NO_DEPRECATED // since YARP 2.3.70
using IControlModeRaw::setPositionModeRaw;
using IControlModeRaw::setVelocityModeRaw;
using IControlModeRaw::setTorqueModeRaw;
using IControlModeRaw::setImpedancePositionModeRaw;
using IControlModeRaw::setImpedanceVelocityModeRaw;
#endif // YARP_NO_DEPRECATED
using IControlModeRaw::getControlModeRaw;
using IControlModeRaw::getControlModesRaw;

Expand Down
22 changes: 17 additions & 5 deletions src/libYARP_dev/include/yarp/dev/ImplementControlMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ namespace yarp {
}
}

#if defined(_MSC_VER) && !defined(YARP_NO_DEPRECATED) // since YARP 2.3.70
// A class implementing setXxxxxMode(int) causes a warning on MSVC
YARP_WARNING_PUSH
YARP_DISABLE_DEPRECATED_WARNING
#endif

class YARP_dev_API yarp::dev::ImplementControlMode: public IControlMode
{
void *helper;
Expand All @@ -25,13 +31,19 @@ class YARP_dev_API yarp::dev::ImplementControlMode: public IControlMode
bool uninitialize();
ImplementControlMode(IControlModeRaw *v);
~ImplementControlMode();
bool setTorqueMode(int j);
bool setImpedancePositionMode(int j);
bool setImpedanceVelocityMode(int j);
bool setPositionMode(int j);
bool setVelocityMode(int j);
#ifndef YARP_NO_DEPRECATED // since YARP 2.3.70
YARP_DEPRECATED bool setTorqueMode(int j);
YARP_DEPRECATED bool setImpedancePositionMode(int j);
YARP_DEPRECATED bool setImpedanceVelocityMode(int j);
YARP_DEPRECATED bool setPositionMode(int j);
YARP_DEPRECATED bool setVelocityMode(int j);
#endif // YARP_NO_DEPRECATED
bool getControlMode(int j, int *f);
bool getControlModes(int *modes);
};

#if defined(_MSC_VER) && !defined(YARP_NO_DEPRECATED) // since YARP 2.3.70
YARP_WARNING_POP
#endif

#endif // YARP_DEV_IMPLEMENTCONTROLMODE_H
21 changes: 16 additions & 5 deletions src/libYARP_dev/include/yarp/dev/ImplementControlMode2.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ namespace yarp {
}
}

#if defined(_MSC_VER) && !defined(YARP_NO_DEPRECATED) // since YARP 2.3.70
// A class implementing setXxxxxMode(int) causes a warning on MSVC
YARP_WARNING_PUSH
YARP_DISABLE_DEPRECATED_WARNING
#endif

class YARP_dev_API yarp::dev::ImplementControlMode2: public IControlMode2
{
void *helper;
Expand All @@ -35,11 +41,13 @@ class YARP_dev_API yarp::dev::ImplementControlMode2: public IControlMode2
virtual ~ImplementControlMode2();

// Control mode
bool setTorqueMode(int j);
bool setImpedancePositionMode(int j);
bool setImpedanceVelocityMode(int j);
bool setPositionMode(int j);
bool setVelocityMode(int j);
#ifndef YARP_NO_DEPRECATED // since YARP 2.3.70
YARP_DEPRECATED bool setTorqueMode(int j);
YARP_DEPRECATED bool setImpedancePositionMode(int j);
YARP_DEPRECATED bool setImpedanceVelocityMode(int j);
YARP_DEPRECATED bool setPositionMode(int j);
YARP_DEPRECATED bool setVelocityMode(int j);
#endif // YARP_NO_DEPRECATED
bool getControlMode(int j, int *f);
bool getControlModes(int *modes);
// Control Mode 2
Expand All @@ -49,5 +57,8 @@ class YARP_dev_API yarp::dev::ImplementControlMode2: public IControlMode2
bool setControlModes(int *modes);
};

#if defined(_MSC_VER) && !defined(YARP_NO_DEPRECATED) // since YARP 2.3.70
YARP_WARNING_POP
#endif

#endif // YARP_DEV_IMPLEMENTCONTROLMODE2_H
18 changes: 17 additions & 1 deletion src/libYARP_dev/src/ControlMode2Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,41 +60,57 @@ bool ImplementControlMode2::uninitialize ()
return true;
}


#ifndef YARP_NO_DEPRECATED // since YARP 2.3.70
bool ImplementControlMode2::setPositionMode(int j)
{
JOINTIDCHECK
int k=castToMapper(helper)->toHw(j);
YARP_WARNING_PUSH
YARP_DISABLE_DEPRECATED_WARNING
return raw->setPositionModeRaw(k);
YARP_WARNING_POP
}

bool ImplementControlMode2::setVelocityMode(int j)
{
JOINTIDCHECK
int k=castToMapper(helper)->toHw(j);
YARP_WARNING_PUSH
YARP_DISABLE_DEPRECATED_WARNING
return raw->setVelocityModeRaw(k);
YARP_WARNING_POP
}

bool ImplementControlMode2::setTorqueMode(int j)
{
JOINTIDCHECK
int k=castToMapper(helper)->toHw(j);
YARP_WARNING_PUSH
YARP_DISABLE_DEPRECATED_WARNING
return raw->setTorqueModeRaw(k);
YARP_WARNING_POP
}

bool ImplementControlMode2::setImpedancePositionMode(int j)
{
JOINTIDCHECK
int k=castToMapper(helper)->toHw(j);
YARP_WARNING_PUSH
YARP_DISABLE_DEPRECATED_WARNING
return raw->setImpedancePositionModeRaw(k);
YARP_WARNING_POP
}

bool ImplementControlMode2::setImpedanceVelocityMode(int j)
{
JOINTIDCHECK
int k=castToMapper(helper)->toHw(j);
YARP_WARNING_PUSH
YARP_DISABLE_DEPRECATED_WARNING
return raw->setImpedanceVelocityModeRaw(k);
YARP_WARNING_POP
}
#endif // YARP_NO_DEPRECATED

bool ImplementControlMode2::getControlMode(int j, int *f)
{
Expand Down
17 changes: 17 additions & 0 deletions src/libYARP_dev/src/ControlModeImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,40 +50,57 @@ bool ImplementControlMode::uninitialize ()
return true;
}

#ifndef YARP_NO_DEPRECATED // since YARP 2.3.70
bool ImplementControlMode::setPositionMode(int j)
{
JOINTIDCHECK
int k=castToMapper(helper)->toHw(j);
YARP_WARNING_PUSH
YARP_DISABLE_DEPRECATED_WARNING
return raw->setPositionModeRaw(k);
YARP_WARNING_POP
}

bool ImplementControlMode::setVelocityMode(int j)
{
JOINTIDCHECK
int k=castToMapper(helper)->toHw(j);
YARP_WARNING_PUSH
YARP_DISABLE_DEPRECATED_WARNING
return raw->setVelocityModeRaw(k);
YARP_WARNING_POP
}

bool ImplementControlMode::setTorqueMode(int j)
{
JOINTIDCHECK
int k=castToMapper(helper)->toHw(j);
YARP_WARNING_PUSH
YARP_DISABLE_DEPRECATED_WARNING
return raw->setTorqueModeRaw(k);
YARP_WARNING_POP
}

bool ImplementControlMode::setImpedancePositionMode(int j)
{
JOINTIDCHECK
int k=castToMapper(helper)->toHw(j);
YARP_WARNING_PUSH
YARP_DISABLE_DEPRECATED_WARNING
return raw->setImpedancePositionModeRaw(k);
YARP_WARNING_POP
}

bool ImplementControlMode::setImpedanceVelocityMode(int j)
{
JOINTIDCHECK
int k=castToMapper(helper)->toHw(j);
YARP_WARNING_PUSH
YARP_DISABLE_DEPRECATED_WARNING
return raw->setImpedanceVelocityModeRaw(k);
YARP_WARNING_POP
}
#endif // YARP_NO_DEPRECATED

bool ImplementControlMode::getControlMode(int j, int *f)
{
Expand Down
Loading

0 comments on commit e5b2734

Please sign in to comment.