From 83b7d093f6717176e5cbf528267ad0ab20c54ac1 Mon Sep 17 00:00:00 2001
From: pFernbach <pierre.fernbach@gmail.com>
Date: Wed, 15 Jan 2020 17:32:27 +0100
Subject: [PATCH] [C++] fix compilation warnings

---
 .../hpp/bezier-com-traj/solve_end_effector.hh    | 16 ++++++++--------
 ...waypoints_c0_dc0_ddc0_j0_x3_j1_ddc1_dc1_c1.hh | 12 ++++++------
 ...waypoints_c0_dc0_ddc0_j0_x5_j1_ddc1_dc1_c1.hh | 14 ++++++--------
 .../waypoints/waypoints_definition.hh            |  2 +-
 python/bezier_com_traj.cpp                       |  2 +-
 src/utils.cpp                                    |  2 +-
 6 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/include/hpp/bezier-com-traj/solve_end_effector.hh b/include/hpp/bezier-com-traj/solve_end_effector.hh
index ed33fd9..7764e1d 100644
--- a/include/hpp/bezier-com-traj/solve_end_effector.hh
+++ b/include/hpp/bezier-com-traj/solve_end_effector.hh
@@ -168,7 +168,7 @@ void computeConstraintsMatrix(const ProblemData& pData, const std::vector<waypoi
   // test : constraint x[z] to be always higher than init[z] and goal[z].
   // TODO replace z with the direction of the contact normal ... need to change the API
   MatrixXX mxz = MatrixXX::Zero(DIM_VAR, DIM_VAR);
-  size_t j = DIM_POINT - 1;
+  int j = DIM_POINT - 1;
   VectorX nxz = VectorX::Zero(DIM_VAR);
   while (j < (DIM_VAR)) {
     mxz(j, j) = -1;
@@ -189,17 +189,17 @@ void computeConstraintsMatrix(const ProblemData& pData, const std::vector<waypoi
     b.segment<DIM_POINT>(i*DIM_POINT)   =  Vector3(10,10,10);*/
 }
 
-std::pair<MatrixXX, VectorX> computeDistanceCostFunction(int numPoints, const ProblemData& pData, double T,
+std::pair<MatrixXX, VectorX> computeDistanceCostFunction(size_t numPoints, const ProblemData& pData, double T,
                                                          std::vector<point3_t> pts_path) {
   assert(numPoints == pts_path.size() && "Pts_path size must be equal to numPoints");
-  double step = 1. / (numPoints - 1);
+  double step = 1. / (double)(numPoints - 1);
   std::vector<point_t> pi = computeConstantWaypoints(pData, T);
   waypoint_t c_wp;
   MatrixXX H = MatrixXX::Zero(dimVar(pData), dimVar(pData));
   VectorX g = VectorX::Zero(dimVar(pData));
   point3_t pk;
   for (size_t i = 0; i < numPoints; ++i) {
-    c_wp = evaluateCurveWaypointAtTime(pData, pi, i * step);
+    c_wp = evaluateCurveWaypointAtTime(pData, pi, (double)i * step);
     pk = pts_path[i];
     //  std::cout<<"pk = "<<pk.transpose()<<std::endl;
     //  std::cout<<"coef First : "<<ckcit->first<<std::endl;
@@ -214,11 +214,11 @@ std::pair<MatrixXX, VectorX> computeDistanceCostFunction(int numPoints, const Pr
 }
 
 template <typename Path>
-std::pair<MatrixXX, VectorX> computeDistanceCostFunction(int numPoints, const ProblemData& pData, double T,
+std::pair<MatrixXX, VectorX> computeDistanceCostFunction(size_t numPoints, const ProblemData& pData, double T,
                                                          const Path& path) {
-  double step = 1. / (numPoints - 1);
+  double step = 1. /(double)(numPoints - 1);
   std::vector<point3_t> pts_path;
-  for (size_t i = 0; i < numPoints; ++i) pts_path.push_back(path((double)(i * step)));
+  for (size_t i = 0; i < numPoints; ++i) pts_path.push_back(path(((double)i * step)));
   return computeDistanceCostFunction(numPoints, pData, T, pts_path);
 }
 
@@ -254,7 +254,7 @@ void computeVelCostFunctionDiscretized(int numPoints, const ProblemData& pData,
   for (std::vector<waypoint_t>::const_iterator ckcit = cks.begin(); ckcit != cks.end(); ++ckcit) {
     // H+=(ckcit->first.transpose() * ckcit->first);
     // g+=ckcit->second.transpose() * ckcit->first;
-    for (size_t i = 0; i < (dimVar(pData) / 3); ++i) {
+    for (int i = 0; i < (dimVar(pData) / 3); ++i) {
       H.block<3, 3>(i * 3, i * 3) += Matrix3::Identity() * ckcit->first(0, i * 3) * ckcit->first(0, i * 3);
       g.segment<3>(i * 3) += ckcit->second.segment<3>(0) * ckcit->first(0, i * 3);
     }
diff --git a/include/hpp/bezier-com-traj/waypoints/waypoints_c0_dc0_ddc0_j0_x3_j1_ddc1_dc1_c1.hh b/include/hpp/bezier-com-traj/waypoints/waypoints_c0_dc0_ddc0_j0_x3_j1_ddc1_dc1_c1.hh
index 2a249b0..6993d76 100644
--- a/include/hpp/bezier-com-traj/waypoints/waypoints_c0_dc0_ddc0_j0_x3_j1_ddc1_dc1_c1.hh
+++ b/include/hpp/bezier-com-traj/waypoints/waypoints_c0_dc0_ddc0_j0_x3_j1_ddc1_dc1_c1.hh
@@ -195,17 +195,17 @@ inline std::vector<point_t> computeConstantWaypoints(const ProblemData& pData, d
 // TODO
 inline bezier_wp_t::t_point_t computeWwaypoints(const ProblemData& pData, double T) {
   bezier_wp_t::t_point_t wps;
-  const int DIM_POINT = 6;
-  const int DIM_VAR = 9;
+  //const int DIM_POINT = 6;
+  //const int DIM_VAR = 9;
   std::vector<point_t> pi = computeConstantWaypoints(pData, T);
   std::vector<Matrix3> Cpi;
   for (std::size_t i = 0; i < pi.size(); ++i) {
     Cpi.push_back(skew(pi[i]));
   }
-  const Vector3 g = pData.contacts_.front().contactPhase_->m_gravity;
-  const Matrix3 Cg = skew(g);
-  const double T2 = T * T;
-  const double alpha = 1 / (T2);
+  //const Vector3 g = pData.contacts_.front().contactPhase_->m_gravity;
+  //const Matrix3 Cg = skew(g);
+  //const double T2 = T * T;
+  //const double alpha = 1 / (T2);
   std::cout << "NOT IMPLEMENTED YET" << std::endl;
   return wps;
 }
diff --git a/include/hpp/bezier-com-traj/waypoints/waypoints_c0_dc0_ddc0_j0_x5_j1_ddc1_dc1_c1.hh b/include/hpp/bezier-com-traj/waypoints/waypoints_c0_dc0_ddc0_j0_x5_j1_ddc1_dc1_c1.hh
index 7dc4ffc..8d3e9a0 100644
--- a/include/hpp/bezier-com-traj/waypoints/waypoints_c0_dc0_ddc0_j0_x5_j1_ddc1_dc1_c1.hh
+++ b/include/hpp/bezier-com-traj/waypoints/waypoints_c0_dc0_ddc0_j0_x5_j1_ddc1_dc1_c1.hh
@@ -83,8 +83,6 @@ inline waypoint_t evaluateVelocityCurveWaypointAtTime(const std::vector<point_t>
   const double t7 = t6 * t;
   const double t8 = t7 * t;
   const double t9 = t8 * t;
-  const double t10 = t9 * t;
-  const double t11 = t10 * t;
 
   // equation found with sympy
   wp.first.block<3, 3>(0, 0) = Matrix3::Identity() * alpha;   // x0
@@ -214,17 +212,17 @@ inline std::vector<point_t> computeConstantWaypoints(const ProblemData& pData, d
 // TODO
 inline bezier_wp_t::t_point_t computeWwaypoints(const ProblemData& pData, double T) {
   bezier_wp_t::t_point_t wps;
-  const int DIM_POINT = 6;
-  const int DIM_VAR = 15;
+  //const int DIM_POINT = 6;
+  //const int DIM_VAR = 15;
   std::vector<point_t> pi = computeConstantWaypoints(pData, T);
   std::vector<Matrix3> Cpi;
   for (std::size_t i = 0; i < pi.size(); ++i) {
     Cpi.push_back(skew(pi[i]));
   }
-  const Vector3 g = pData.contacts_.front().contactPhase_->m_gravity;
-  const Matrix3 Cg = skew(g);
-  const double T2 = T * T;
-  const double alpha = 1 / (T2);
+  //const Vector3 g = pData.contacts_.front().contactPhase_->m_gravity;
+  //const Matrix3 Cg = skew(g);
+  //const double T2 = T * T;
+  //const double alpha = 1 / (T2);
   std::cout << "NOT IMPLEMENTED YET" << std::endl;
   return wps;
 }
diff --git a/include/hpp/bezier-com-traj/waypoints/waypoints_definition.hh b/include/hpp/bezier-com-traj/waypoints/waypoints_definition.hh
index 5ade006..368f976 100644
--- a/include/hpp/bezier-com-traj/waypoints/waypoints_definition.hh
+++ b/include/hpp/bezier-com-traj/waypoints/waypoints_definition.hh
@@ -113,7 +113,7 @@ bezier_wp_t::t_point_t computeWwaypoints(const ProblemData& pData, double T);
 
 coefs_t computeFinalVelocityPoint(const ProblemData& pData, double T);
 
-size_t dimVar(const ProblemData& pData);
+int dimVar(const ProblemData& pData);
 
 std::pair<MatrixXX, VectorX> computeVelocityCost(const ProblemData& pData, double T,
                                                  std::vector<bezier_t::point_t> pi = std::vector<bezier_t::point_t>());
diff --git a/python/bezier_com_traj.cpp b/python/bezier_com_traj.cpp
index dbc179e..8c0902b 100644
--- a/python/bezier_com_traj.cpp
+++ b/python/bezier_com_traj.cpp
@@ -259,7 +259,7 @@ MatrixVector* computeEndEffectorDistanceCostPython(const ProblemData& pData, con
   std::vector<bezier_t::point_t> pi = computeConstantWaypoints(pData, time);
   // transform the matrice 3xN in a std::vector<point3_t> of size N :
   std::vector<point3_t> pts_path;
-  for (size_t c = 0; c < pts_l.cols(); ++c) {
+  for (int c = 0; c < pts_l.cols(); ++c) {
     pts_path.push_back(pts_l.block<3, 1>(0, c));
   }
   MatrixVector* res = new MatrixVector();
diff --git a/src/utils.cpp b/src/utils.cpp
index ce7abfe..2034708 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -77,7 +77,7 @@ T_time computeDiscretizedTimeFixed(const VectorX& phaseTimings, const unsigned i
   timeArray.push_back(std::make_pair(0., 0));
   for (int i = 0; i < phaseTimings.size(); ++i) {
     double step = (double)phaseTimings[i] / pointsPerPhase;
-    for (int j = 0; j < pointsPerPhase; ++j) {
+    for (size_t j = 0; j < pointsPerPhase; ++j) {
       t += step;
       timeArray.push_back(std::make_pair(t, i));
     }
-- 
GitLab