From 0529516ebb286621d25ac931944a15cf062aef89 Mon Sep 17 00:00:00 2001 From: Francois Keith <francois.keith@inrialpes.fr> Date: Mon, 18 Jul 2011 17:29:39 +0200 Subject: [PATCH] Adding const operator wherever it's possible --- include/jrl/walkgen/patterngeneratorinterface.hh | 12 ++++++------ .../FootTrajectoryGenerationAbstract.h | 8 ++++---- .../FootTrajectoryGenerationMultiple.cpp | 12 ++++++------ .../FootTrajectoryGenerationMultiple.h | 12 ++++++------ src/Mathematics/Polynome.cpp | 4 ++-- src/Mathematics/Polynome.h | 4 ++-- src/PatternGeneratorInterfacePrivate.cpp | 13 +++++++------ .../OrientationsPreview.cpp | 4 ++-- .../OrientationsPreview.h | 6 +++--- src/patterngeneratorinterfaceprivate.hh | 12 ++++++------ 10 files changed, 44 insertions(+), 43 deletions(-) diff --git a/include/jrl/walkgen/patterngeneratorinterface.hh b/include/jrl/walkgen/patterngeneratorinterface.hh index ee096c12..83b93211 100644 --- a/include/jrl/walkgen/patterngeneratorinterface.hh +++ b/include/jrl/walkgen/patterngeneratorinterface.hh @@ -184,11 +184,11 @@ namespace PatternGeneratorJRL virtual void SetCurrentJointValues(MAL_VECTOR( &lCurrentJointValues,double))=0; /*! \brief Returns the walking mode. */ - virtual int GetWalkMode()=0; + virtual int GetWalkMode() const=0; /*! \brief Get the leg joint velocity */ virtual void GetLegJointVelocity(MAL_VECTOR( &dqr,double), - MAL_VECTOR( &dql,double))=0; + MAL_VECTOR( &dql,double)) const=0; /*! \brief Read a sequence of steps. */ virtual void ReadSequenceOfSteps(std::istringstream &strm)=0; @@ -240,7 +240,7 @@ namespace PatternGeneratorJRL /*! \brief Get the waist position and orientation as a quaternion, and the planar X-Y orientation in Orientation. */ - virtual void getWaistPositionAndOrientation(double TQ[7],double &Orientation)=0; + virtual void getWaistPositionAndOrientation(double TQ[7],double &Orientation) const=0; /*! \brief Set Waist position and Orientation */ virtual void setWaistPositionAndOrientation(double TQ[7])=0; @@ -248,10 +248,10 @@ namespace PatternGeneratorJRL /*! \brief Get Waist velocity */ virtual void getWaistVelocity(double &dx, double &dy, - double &omega)=0; + double &omega) const=0; /*! \brief An other method to get the waist position using a matrix. */ - virtual void getWaistPositionMatrix(MAL_S4x4_MATRIX( &lWaistAbsPos,double))=0; + virtual void getWaistPositionMatrix(MAL_S4x4_MATRIX( &lWaistAbsPos,double)) const=0; /*!@} */ @@ -260,7 +260,7 @@ namespace PatternGeneratorJRL virtual void setZMPInitialPoint(MAL_S3_VECTOR(&,double) lZMPInitialPoint)=0; /*! \brief Get the initial ZMP reference point. */ - virtual void getZMPInitialPoint(MAL_S3_VECTOR(&,double) lZMPInitialPoint)=0; + virtual void getZMPInitialPoint(MAL_S3_VECTOR(&,double) lZMPInitialPoint) const=0; /*! \name System to call a given method based on registration of a method. @{ diff --git a/src/FootTrajectoryGeneration/FootTrajectoryGenerationAbstract.h b/src/FootTrajectoryGeneration/FootTrajectoryGenerationAbstract.h index 50db2ccf..c6343556 100644 --- a/src/FootTrajectoryGeneration/FootTrajectoryGenerationAbstract.h +++ b/src/FootTrajectoryGeneration/FootTrajectoryGenerationAbstract.h @@ -134,7 +134,7 @@ namespace PatternGeneratorJRL { m_TSingle =aTSingle;}; /*! \brief Get single support time */ - double GetSingleSupportTime() + double GetSingleSupportTime() const { return m_TSingle;}; /*! @} */ @@ -147,7 +147,7 @@ namespace PatternGeneratorJRL { m_TDouble =aTDouble;}; /*! \brief Get single support time */ - double GetDoubleSupportTime() + double GetDoubleSupportTime() const { return m_TDouble;}; /*! @}*/ @@ -161,7 +161,7 @@ namespace PatternGeneratorJRL { m_SamplingPeriod = aSamplingPeriod;}; /*! \brief Get single support time */ - double GetSamplingPeriod() + double GetSamplingPeriod() const { return m_SamplingPeriod;}; /*!@}*/ @@ -170,7 +170,7 @@ namespace PatternGeneratorJRL @{*/ /*! Get Omega */ - double GetOmega() + double GetOmega() const { return m_Omega; }; /*! Set Omega */ diff --git a/src/FootTrajectoryGeneration/FootTrajectoryGenerationMultiple.cpp b/src/FootTrajectoryGeneration/FootTrajectoryGenerationMultiple.cpp index fba8d701..9b816af0 100644 --- a/src/FootTrajectoryGeneration/FootTrajectoryGenerationMultiple.cpp +++ b/src/FootTrajectoryGeneration/FootTrajectoryGenerationMultiple.cpp @@ -67,13 +67,13 @@ void FootTrajectoryGenerationMultiple::SetNumberOfIntervals(int lNumberOfInterva m_NatureOfIntervals.resize(lNumberOfIntervals); } -int FootTrajectoryGenerationMultiple::GetNumberOfIntervals() +int FootTrajectoryGenerationMultiple::GetNumberOfIntervals() const { return m_SetOfFootTrajectoryGenerationObjects.size(); } -void FootTrajectoryGenerationMultiple::SetTimeIntervals(vector<double> &lDeltaTj) +void FootTrajectoryGenerationMultiple::SetTimeIntervals(const vector<double> &lDeltaTj) { m_DeltaTj = lDeltaTj; m_RefTime.resize(lDeltaTj.size()); @@ -88,7 +88,7 @@ void FootTrajectoryGenerationMultiple::SetTimeIntervals(vector<double> &lDeltaTj } -void FootTrajectoryGenerationMultiple::GetTimeIntervals(vector<double> &lDeltaTj) +void FootTrajectoryGenerationMultiple::GetTimeIntervals(vector<double> &lDeltaTj) const { lDeltaTj = m_DeltaTj; } @@ -190,7 +190,7 @@ int FootTrajectoryGenerationMultiple::SetNatureInterval(unsigned int IntervalInd /*! This method returns the nature of the interval. */ -int FootTrajectoryGenerationMultiple::GetNatureInterval(unsigned int IntervalIndex) +int FootTrajectoryGenerationMultiple::GetNatureInterval(unsigned int IntervalIndex) const { if (IntervalIndex>=m_NatureOfIntervals.size()) return -100; @@ -228,7 +228,7 @@ int FootTrajectoryGenerationMultiple::SetParametersWithInitPosInitSpeed(unsigned } -double FootTrajectoryGenerationMultiple::GetAbsoluteTimeReference() +double FootTrajectoryGenerationMultiple::GetAbsoluteTimeReference() const { return m_AbsoluteTimeReference; } @@ -243,7 +243,7 @@ void FootTrajectoryGenerationMultiple::CallMethod(std::string &, //Method, { } -int FootTrajectoryGenerationMultiple::DisplayIntervals() +int FootTrajectoryGenerationMultiple::DisplayIntervals() const { for(unsigned int i=0;i<m_DeltaTj.size();i++) { diff --git a/src/FootTrajectoryGeneration/FootTrajectoryGenerationMultiple.h b/src/FootTrajectoryGeneration/FootTrajectoryGenerationMultiple.h index 66a77c87..c79c63ac 100644 --- a/src/FootTrajectoryGeneration/FootTrajectoryGenerationMultiple.h +++ b/src/FootTrajectoryGeneration/FootTrajectoryGenerationMultiple.h @@ -96,22 +96,22 @@ namespace PatternGeneratorJRL void SetNumberOfIntervals(int lNumberOfIntervals); /*! \brief Get number of intervals. */ - int GetNumberOfIntervals(); + int GetNumberOfIntervals() const; /*! \brief Set the time for each interval. */ - void SetTimeIntervals(std::vector<double> & lDeltaTj); + void SetTimeIntervals(const std::vector<double> & lDeltaTj); /*! \brief Get the time for each interval */ - void GetTimeIntervals(std::vector<double> & lDeltaTj); + void GetTimeIntervals(std::vector<double> & lDeltaTj) const; /*! \brief Set nature of interval */ int SetNatureInterval(unsigned int IntervalIndex, int Nature); /*! \brief Get nature of interval */ - int GetNatureInterval(unsigned int IntervalIndex); + int GetNatureInterval(unsigned int IntervalIndex) const; /*! \brief Display intervals time. */ - int DisplayIntervals(); + int DisplayIntervals() const; /*! @} */ @@ -157,7 +157,7 @@ namespace PatternGeneratorJRL @{ */ /*! Returns the time when the trajectory starts. */ - double GetAbsoluteTimeReference(); + double GetAbsoluteTimeReference() const; /*! Set the time when the trajectory starts. */ void SetAbsoluteTimeReference(double lAbsoluteTimeReference); diff --git a/src/Mathematics/Polynome.cpp b/src/Mathematics/Polynome.cpp index 5e3f3b58..a978b190 100644 --- a/src/Mathematics/Polynome.cpp +++ b/src/Mathematics/Polynome.cpp @@ -81,12 +81,12 @@ void Polynome::GetCoefficients(vector<double> &lCoefficients) const } -void Polynome::SetCoefficients(vector<double> &lCoefficients) +void Polynome::SetCoefficients(const vector<double> &lCoefficients) { m_Coefficients = lCoefficients; } -void Polynome::print() +void Polynome::print() const { for(unsigned int i=0;i<m_Coefficients.size();i++) cout << m_Coefficients[i] << " " ; diff --git a/src/Mathematics/Polynome.h b/src/Mathematics/Polynome.h index 5f4cce41..afe986cf 100644 --- a/src/Mathematics/Polynome.h +++ b/src/Mathematics/Polynome.h @@ -64,14 +64,14 @@ namespace PatternGeneratorJRL void GetCoefficients(std::vector<double> &lCoefficients) const; /*! Set the coefficients. */ - void SetCoefficients(std::vector<double> &lCoefficients); + void SetCoefficients(const std::vector<double> &lCoefficients); inline int Degree() { return m_Degree; }; /*! Print the coefficient. */ - void print(); + void print() const; protected: diff --git a/src/PatternGeneratorInterfacePrivate.cpp b/src/PatternGeneratorInterfacePrivate.cpp index 4bca9e15..491fd6a8 100644 --- a/src/PatternGeneratorInterfacePrivate.cpp +++ b/src/PatternGeneratorInterfacePrivate.cpp @@ -1543,7 +1543,7 @@ namespace PatternGeneratorJRL { } - int PatternGeneratorInterfacePrivate::GetWalkMode() + int PatternGeneratorInterfacePrivate::GetWalkMode() const { return m_StepStackHandler->GetWalkMode(); } @@ -1556,7 +1556,7 @@ namespace PatternGeneratorJRL { } void PatternGeneratorInterfacePrivate::GetLegJointVelocity(MAL_VECTOR( & dqr,double), - MAL_VECTOR( & dql,double)) + MAL_VECTOR( & dql,double)) const { // TO DO: take the joint specific to the legs @@ -1679,12 +1679,13 @@ namespace PatternGeneratorJRL { } - void PatternGeneratorInterfacePrivate::getWaistPositionMatrix(MAL_S4x4_MATRIX( &lWaistAbsPos,double)) + void PatternGeneratorInterfacePrivate::getWaistPositionMatrix(MAL_S4x4_MATRIX( &lWaistAbsPos,double)) const { lWaistAbsPos = m_WaistAbsPos; } - void PatternGeneratorInterfacePrivate::getWaistPositionAndOrientation(double aTQ[7], double &Orientation) + //TODO test me + void PatternGeneratorInterfacePrivate::getWaistPositionAndOrientation(double aTQ[7], double &Orientation) const { // Position aTQ[0] = MAL_S4x4_MATRIX_ACCESS_I_J(m_WaistAbsPos, 0,3); @@ -1741,7 +1742,7 @@ namespace PatternGeneratorJRL { void PatternGeneratorInterfacePrivate::getWaistVelocity(double & dx, double & dy, - double & omega) + double & omega) const { dx = m_AbsLinearVelocity(0); dy = m_AbsLinearVelocity(1); @@ -1886,7 +1887,7 @@ namespace PatternGeneratorJRL { m_ZMPInitialPointSet = true; } - void PatternGeneratorInterfacePrivate::getZMPInitialPoint(MAL_S3_VECTOR(&,double) lZMPInitialPoint) + void PatternGeneratorInterfacePrivate::getZMPInitialPoint(MAL_S3_VECTOR(&,double) lZMPInitialPoint) const { lZMPInitialPoint = m_ZMPInitialPoint; } diff --git a/src/ZMPRefTrajectoryGeneration/OrientationsPreview.cpp b/src/ZMPRefTrajectoryGeneration/OrientationsPreview.cpp index 541bd641..b4e58922 100644 --- a/src/ZMPRefTrajectoryGeneration/OrientationsPreview.cpp +++ b/src/ZMPRefTrajectoryGeneration/OrientationsPreview.cpp @@ -75,8 +75,8 @@ void OrientationsPreview::preview_orientations(double Time, const reference_t & Ref, double StepDuration, const deque<support_state_t> & PrwSupportStates_deq, - std::deque<FootAbsolutePosition> & LeftFootPositions_deq, - std::deque<FootAbsolutePosition> & RightFootPositions_deq, + const std::deque<FootAbsolutePosition> & LeftFootPositions_deq, + const std::deque<FootAbsolutePosition> & RightFootPositions_deq, std::deque<double> & PreviewedSupportAngles_deq) { diff --git a/src/ZMPRefTrajectoryGeneration/OrientationsPreview.h b/src/ZMPRefTrajectoryGeneration/OrientationsPreview.h index aacdfd28..2909ed85 100644 --- a/src/ZMPRefTrajectoryGeneration/OrientationsPreview.h +++ b/src/ZMPRefTrajectoryGeneration/OrientationsPreview.h @@ -71,9 +71,9 @@ namespace PatternGeneratorJRL /// \param[out] PreviewedSupportAngles void preview_orientations(double Time, const reference_t & Ref, double StepDuration, const std::deque<support_state_t> & PrwSupportStates_deq, - std::deque<FootAbsolutePosition> & LeftFootAbsolutePositions, - std::deque<FootAbsolutePosition> & RightFootAbsolutePositions, - std::deque<double> & PreviewedSupportAngles); + const std::deque<FootAbsolutePosition> & LeftFootAbsolutePositions, + const std::deque<FootAbsolutePosition> & RightFootAbsolutePositions, + std::deque<double> & PreviewedSupportAngles); /// \brief Interpolate previewed orientation of the trunk /// diff --git a/src/patterngeneratorinterfaceprivate.hh b/src/patterngeneratorinterfaceprivate.hh index 906502df..a5af2cc1 100644 --- a/src/patterngeneratorinterfaceprivate.hh +++ b/src/patterngeneratorinterfaceprivate.hh @@ -248,11 +248,11 @@ namespace PatternGeneratorJRL void SetCurrentJointValues(MAL_VECTOR( &lCurrentJointValues,double)); /*! \brief Returns the walking mode. */ - int GetWalkMode(); + int GetWalkMode() const; /*! \brief Get the leg joint velocity */ void GetLegJointVelocity(MAL_VECTOR( &dqr,double), - MAL_VECTOR( &dql,double)); + MAL_VECTOR( &dql,double)) const; /*! \brief Read a velocity reference. */ void setVelReference(istringstream &strm); @@ -313,7 +313,7 @@ namespace PatternGeneratorJRL /*! \brief Get the waist position and orientation as a quaternion, and the planar X-Y orientation in Orientation. */ - void getWaistPositionAndOrientation(double TQ[7],double &Orientation); + void getWaistPositionAndOrientation(double TQ[7],double &Orientation) const; /*! \brief Set Waist position and Orientation */ void setWaistPositionAndOrientation(double TQ[7]); @@ -321,10 +321,10 @@ namespace PatternGeneratorJRL /*! \brief Get Waist velocity */ void getWaistVelocity(double &dx, double &dy, - double &omega) ; + double &omega) const; /*! \brief An other method to get the waist position using a matrix. */ - void getWaistPositionMatrix(MAL_S4x4_MATRIX( &lWaistAbsPos,double)); + void getWaistPositionMatrix(MAL_S4x4_MATRIX( &lWaistAbsPos,double)) const; /*!@} */ @@ -345,7 +345,7 @@ namespace PatternGeneratorJRL void setZMPInitialPoint(MAL_S3_VECTOR(&,double) lZMPInitialPoint); /*! \brief Get the initial ZMP reference point. */ - void getZMPInitialPoint(MAL_S3_VECTOR(&,double) lZMPInitialPoint); + void getZMPInitialPoint(MAL_S3_VECTOR(&,double) lZMPInitialPoint) const; /*! \name System to call a given method based on registration of a method. @{ -- GitLab