Skip to content

Commit

Permalink
Introduce use of override keyword for virtual methods; added correspo…
Browse files Browse the repository at this point in the history
…nding gcc warning.
  • Loading branch information
Guillaume227 committed Mar 14, 2024
1 parent 0a83575 commit b54b60f
Show file tree
Hide file tree
Showing 41 changed files with 290 additions and 325 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ add_definitions(-Wno-deprecated-declarations)
# Ignore them for now.
add_definitions(-Wno-sign-conversion)

add_definitions(-Werror=suggest-override)

# Project configuration
if(NOT INSTALL_PYTHON_INTERFACE_ONLY)
set(PROJECT_USE_CMAKE_EXPORT TRUE)
Expand Down
48 changes: 23 additions & 25 deletions include/tsid/contacts/contact-6d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,37 +55,35 @@ class Contact6d : public ContactBase {
const double maxNormalForce,
const double forceRegWeight);

virtual ~Contact6d() {}

/// Return the number of motion constraints
virtual unsigned int n_motion() const;
unsigned int n_motion() const override;

/// Return the number of force variables
virtual unsigned int n_force() const;
unsigned int n_force() const override;

virtual const ConstraintBase& computeMotionTask(const double t,
ConstRefVector q,
ConstRefVector v, Data& data);
const ConstraintBase& computeMotionTask(double t,
ConstRefVector q,
ConstRefVector v, Data& data) override;

virtual const ConstraintInequality& computeForceTask(const double t,
ConstRefVector q,
ConstRefVector v,
const Data& data);
const ConstraintInequality& computeForceTask(double t,
ConstRefVector q,
ConstRefVector v,
const Data& data) override;

virtual const Matrix& getForceGeneratorMatrix();
const Matrix& getForceGeneratorMatrix() override;

virtual const ConstraintEquality& computeForceRegularizationTask(
const double t, ConstRefVector q, ConstRefVector v, const Data& data);
const ConstraintEquality& computeForceRegularizationTask(
double t, ConstRefVector q, ConstRefVector v, const Data& data) override;

const TaskSE3Equality& getMotionTask() const;
const ConstraintBase& getMotionConstraint() const;
const ConstraintInequality& getForceConstraint() const;
const ConstraintEquality& getForceRegularizationTask() const;
const TaskSE3Equality& getMotionTask() const override;
const ConstraintBase& getMotionConstraint() const override;
const ConstraintInequality& getForceConstraint() const override;
const ConstraintEquality& getForceRegularizationTask() const override;

double getNormalForce(ConstRefVector f) const;
double getMinNormalForce() const;
double getMaxNormalForce() const;
const Matrix3x& getContactPoints() const;
double getNormalForce(ConstRefVector f) const override;
double getMinNormalForce() const override;
double getMaxNormalForce() const override;
const Matrix3x& getContactPoints() const override;

const Vector& Kp() const;
const Vector& Kd() const;
Expand All @@ -95,9 +93,9 @@ class Contact6d : public ContactBase {
bool setContactPoints(ConstRefMatrix contactPoints);
bool setContactNormal(ConstRefVector contactNormal);

bool setFrictionCoefficient(const double frictionCoefficient);
bool setMinNormalForce(const double minNormalForce);
bool setMaxNormalForce(const double maxNormalForce);
bool setFrictionCoefficient(double frictionCoefficient);
bool setMinNormalForce(double minNormalForce) override;
bool setMaxNormalForce(double maxNormalForce) override;
void setReference(const SE3& ref);
void setForceReference(ConstRefVector& f_ref);
void setRegularizationTaskWeightVector(ConstRefVector& w);
Expand Down
2 changes: 1 addition & 1 deletion include/tsid/contacts/contact-base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ContactBase {

ContactBase(const std::string& name, RobotWrapper& robot);

virtual ~ContactBase() {}
virtual ~ContactBase() = default;

const std::string& name() const;

Expand Down
46 changes: 22 additions & 24 deletions include/tsid/contacts/contact-point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,38 +45,36 @@ class ContactPoint : public ContactBase {
const double frictionCoefficient, const double minNormalForce,
const double maxNormalForce);

virtual ~ContactPoint() {}

/// Return the number of motion constraints
virtual unsigned int n_motion() const;
unsigned int n_motion() const override;

/// Return the number of force variables
virtual unsigned int n_force() const;
unsigned int n_force() const override;

virtual const ConstraintBase& computeMotionTask(const double t,
ConstRefVector q,
ConstRefVector v, Data& data);
const ConstraintBase& computeMotionTask(double t,
ConstRefVector q,
ConstRefVector v, Data& data) override;

virtual const ConstraintInequality& computeForceTask(const double t,
ConstRefVector q,
ConstRefVector v,
const Data& data);
const ConstraintInequality& computeForceTask(double t,
ConstRefVector q,
ConstRefVector v,
const Data& data) override;

virtual const Matrix& getForceGeneratorMatrix();
const Matrix& getForceGeneratorMatrix() override;

virtual const ConstraintEquality& computeForceRegularizationTask(
const double t, ConstRefVector q, ConstRefVector v, const Data& data);
const ConstraintEquality& computeForceRegularizationTask(
double t, ConstRefVector q, ConstRefVector v, const Data& data) override;

const TaskSE3Equality& getMotionTask() const;
const ConstraintBase& getMotionConstraint() const;
const ConstraintInequality& getForceConstraint() const;
const ConstraintEquality& getForceRegularizationTask() const;
const TaskSE3Equality& getMotionTask() const override;
const ConstraintBase& getMotionConstraint() const override;
const ConstraintInequality& getForceConstraint() const override;
const ConstraintEquality& getForceRegularizationTask() const override;
double getMotionTaskWeight() const;
const Matrix3x& getContactPoints() const;
const Matrix3x& getContactPoints() const override;

double getNormalForce(ConstRefVector f) const;
double getMinNormalForce() const;
double getMaxNormalForce() const;
double getNormalForce(ConstRefVector f) const override;
double getMinNormalForce() const override;
double getMaxNormalForce() const override;

const Vector&
Kp(); // cannot be const because it set a member variable inside
Expand All @@ -88,8 +86,8 @@ class ContactPoint : public ContactBase {
bool setContactNormal(ConstRefVector contactNormal);

bool setFrictionCoefficient(const double frictionCoefficient);
bool setMinNormalForce(const double minNormalForce);
bool setMaxNormalForce(const double maxNormalForce);
bool setMinNormalForce(const double minNormalForce) override;
bool setMaxNormalForce(const double maxNormalForce) override;
bool setMotionTaskWeight(const double w);
void setReference(const SE3& ref);
void setForceReference(ConstRefVector& f_ref);
Expand Down
44 changes: 22 additions & 22 deletions include/tsid/contacts/contact-two-frame-positions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,35 +49,35 @@ class ContactTwoFramePositions : public ContactBase {
const double maxNormalForce);

/// Return the number of motion constraints
virtual unsigned int n_motion() const;
unsigned int n_motion() const override;

/// Return the number of force variables
virtual unsigned int n_force() const;
unsigned int n_force() const override;

virtual const ConstraintBase& computeMotionTask(const double t,
ConstRefVector q,
ConstRefVector v, Data& data);
const ConstraintBase& computeMotionTask(double t,
ConstRefVector q,
ConstRefVector v, Data& data) override;

virtual const ConstraintInequality& computeForceTask(const double t,
ConstRefVector q,
ConstRefVector v,
const Data& data);
const ConstraintInequality& computeForceTask(double t,
ConstRefVector q,
ConstRefVector v,
const Data& data) override;

virtual const Matrix& getForceGeneratorMatrix();
const Matrix& getForceGeneratorMatrix() override;

virtual const ConstraintEquality& computeForceRegularizationTask(
const double t, ConstRefVector q, ConstRefVector v, const Data& data);
const ConstraintEquality& computeForceRegularizationTask(
double t, ConstRefVector q, ConstRefVector v, const Data& data) override;

const TaskTwoFramesEquality& getMotionTask() const;
const ConstraintBase& getMotionConstraint() const;
const ConstraintInequality& getForceConstraint() const;
const ConstraintEquality& getForceRegularizationTask() const;
const TaskTwoFramesEquality& getMotionTask() const override;
const ConstraintBase& getMotionConstraint() const override;
const ConstraintInequality& getForceConstraint() const override;
const ConstraintEquality& getForceRegularizationTask() const override;
double getMotionTaskWeight() const;
const Matrix3x& getContactPoints() const;
const Matrix3x& getContactPoints() const override;

double getNormalForce(ConstRefVector f) const;
double getMinNormalForce() const;
double getMaxNormalForce() const;
double getNormalForce(ConstRefVector f) const override;
double getMinNormalForce() const override;
double getMaxNormalForce() const override;

const Vector&
Kp(); // cannot be const because it set a member variable inside
Expand All @@ -89,8 +89,8 @@ class ContactTwoFramePositions : public ContactBase {
bool setContactNormal(ConstRefVector contactNormal);

bool setFrictionCoefficient(const double frictionCoefficient);
bool setMinNormalForce(const double minNormalForce);
bool setMaxNormalForce(const double maxNormalForce);
bool setMinNormalForce(const double minNormalForce) override;
bool setMaxNormalForce(const double maxNormalForce) override;
bool setMotionTaskWeight(const double w);
void setForceReference(ConstRefVector& f_ref);
void setRegularizationTaskWeightVector(ConstRefVector& w);
Expand Down
2 changes: 1 addition & 1 deletion include/tsid/contacts/measured-3Dforce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Measured3Dforce : public MeasuredForceBase {
Measured3Dforce(const std::string &name, RobotWrapper &robot,
const std::string &frameName);

const Vector &computeJointTorques(Data &data);
const Vector &computeJointTorques(Data &data) override;

/**
* Set the value of the external wrench applied by the environment on the
Expand Down
2 changes: 1 addition & 1 deletion include/tsid/contacts/measured-6Dwrench.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Measured6Dwrench : public MeasuredForceBase {
Measured6Dwrench(const std::string &name, RobotWrapper &robot,
const std::string &frameName);

const Vector &computeJointTorques(Data &data);
const Vector &computeJointTorques(Data &data) override;

/**
* Set the value of the external wrench applied by the environment on the
Expand Down
2 changes: 2 additions & 0 deletions include/tsid/contacts/measured-force-base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class MeasuredForceBase {

MeasuredForceBase(const std::string &name, RobotWrapper &robot);

virtual ~MeasuredForceBase() = default;

const std::string &name() const;

void name(const std::string &name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,57 +56,55 @@ class InverseDynamicsFormulationAccForce
InverseDynamicsFormulationAccForce(const std::string& name,
RobotWrapper& robot, bool verbose = false);

virtual ~InverseDynamicsFormulationAccForce() {}
Data& data() override;

Data& data();

unsigned int nVar() const;
unsigned int nEq() const;
unsigned int nIn() const;
unsigned int nVar() const override;
unsigned int nEq() const override;
unsigned int nIn() const override;

bool addMotionTask(TaskMotion& task, double weight,
unsigned int priorityLevel,
double transition_duration = 0.0);
double transition_duration = 0.0) override;

bool addForceTask(TaskContactForce& task, double weight,
unsigned int priorityLevel,
double transition_duration = 0.0);
double transition_duration = 0.0) override;

bool addActuationTask(TaskActuation& task, double weight,
unsigned int priorityLevel,
double transition_duration = 0.0);
double transition_duration = 0.0) override;

bool updateTaskWeight(const std::string& task_name, double weight);
bool updateTaskWeight(const std::string& task_name, double weight) override;

bool addRigidContact(ContactBase& contact, double force_regularization_weight,
double motion_weight = 1.0,
unsigned int motion_priority_level = 0);
unsigned int motion_priority_level = 0) override;

TSID_DEPRECATED bool addRigidContact(ContactBase& contact);
TSID_DEPRECATED bool addRigidContact(ContactBase& contact) override;

bool updateRigidContactWeights(const std::string& contact_name,
double force_regularization_weight,
double motion_weight = -1.0);
double motion_weight = -1.0) override;

bool addMeasuredForce(MeasuredForceBase& measuredForce);
bool addMeasuredForce(MeasuredForceBase& measuredForce) override;

bool removeTask(const std::string& taskName,
double transition_duration = 0.0);
double transition_duration = 0.0) override;

bool removeRigidContact(const std::string& contactName,
double transition_duration = 0.0);
double transition_duration = 0.0) override;

bool removeMeasuredForce(const std::string& measuredForceName);
bool removeMeasuredForce(const std::string& measuredForceName) override;

const HQPData& computeProblemData(double time, ConstRefVector q,
ConstRefVector v);
ConstRefVector v) override;

const Vector& getActuatorForces(const HQPOutput& sol);
const Vector& getAccelerations(const HQPOutput& sol);
const Vector& getContactForces(const HQPOutput& sol);
const Vector& getActuatorForces(const HQPOutput& sol) override;
const Vector& getAccelerations(const HQPOutput& sol) override;
const Vector& getContactForces(const HQPOutput& sol) override;
Vector getContactForces(const std::string& name, const HQPOutput& sol);
bool getContactForces(const std::string& name, const HQPOutput& sol,
RefVector f);
RefVector f) override;

public:
template <class TaskLevelPointer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class InverseDynamicsFormulationBase {
InverseDynamicsFormulationBase(const std::string& name, RobotWrapper& robot,
bool verbose = false);

virtual ~InverseDynamicsFormulationBase() {}
virtual ~InverseDynamicsFormulationBase() = default;

virtual Data& data() = 0;

Expand Down
2 changes: 1 addition & 1 deletion include/tsid/math/constraint-base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ConstraintBase {
const unsigned int cols);

ConstraintBase(const std::string& name, ConstRefMatrix A);
virtual ~ConstraintBase() {}
virtual ~ConstraintBase() = default;

virtual const std::string& name() const;
virtual unsigned int rows() const = 0;
Expand Down
33 changes: 16 additions & 17 deletions include/tsid/math/constraint-bound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,28 @@ class ConstraintBound : public ConstraintBase {

ConstraintBound(const std::string& name, ConstRefVector lb,
ConstRefVector ub);
virtual ~ConstraintBound() {}

unsigned int rows() const;
unsigned int cols() const;
void resize(const unsigned int r, const unsigned int c);
unsigned int rows() const override;
unsigned int cols() const override;
void resize(unsigned int r, unsigned int c) override;

bool isEquality() const;
bool isInequality() const;
bool isBound() const;
bool isEquality() const override;
bool isInequality() const override;
bool isBound() const override;

const Vector& vector() const;
const Vector& lowerBound() const;
const Vector& upperBound() const;
const Vector& vector() const override;
const Vector& lowerBound() const override;
const Vector& upperBound() const override;

Vector& vector();
Vector& lowerBound();
Vector& upperBound();
Vector& vector() override;
Vector& lowerBound() override;
Vector& upperBound() override;

bool setVector(ConstRefVector b);
bool setLowerBound(ConstRefVector lb);
bool setUpperBound(ConstRefVector ub);
bool setVector(ConstRefVector b) override;
bool setLowerBound(ConstRefVector lb) override;
bool setUpperBound(ConstRefVector ub) override;

bool checkConstraint(ConstRefVector x, double tol = 1e-6) const;
bool checkConstraint(ConstRefVector x, double tol = 1e-6) const override;

protected:
Vector m_lb;
Expand Down
Loading

0 comments on commit b54b60f

Please sign in to comment.