Commit d9766b8f authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

[Format] set Standard to C++03

avoid this error when compiling in C++ < 11
> error: '>>' should be '> >' within a nested template argument list
parent 3b29ac4e
Pipeline #7156 failed with stage
in 17 minutes and 8 seconds
--- ---
ColumnLimit: 80 ColumnLimit: 80
Standard: C++03
... ...
...@@ -73,7 +73,7 @@ public: ...@@ -73,7 +73,7 @@ public:
void rewind(void); void rewind(void);
protected: protected:
typedef std::list<std::vector<double>> DataType; typedef std::list<std::vector<double> > DataType;
DataType dataSet; DataType dataSet;
DataType::const_iterator currentData; DataType::const_iterator currentData;
bool iteratorSet; bool iteratorSet;
......
/* /*
Copyright (c) 2010-2013 Tommaso Urli Copyright (c) 2010-2013 Tommaso Urli
Tommaso Urli tommaso.urli@uniud.it University of Udine Tommaso Urli tommaso.urli@uniud.it University of Udine
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to permit persons to whom the Software is furnished to do so, subject to
the following conditions: the following conditions:
The above copyright notice and this permission notice shall be The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software. included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef __sot_core_stopwatch_H__ #ifndef __sot_core_stopwatch_H__
#define __sot_core_stopwatch_H__ #define __sot_core_stopwatch_H__
#include <ctime> #include <ctime>
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <sstream> #include <sstream>
#ifndef WIN32 #ifndef WIN32
/* The classes below are exported */ /* The classes below are exported */
#pragma GCC visibility push(default) #pragma GCC visibility push(default)
#endif #endif
// Generic stopwatch exception class // Generic stopwatch exception class
struct StopwatchException { struct StopwatchException {
public: public:
StopwatchException(std::string error) : error(error) {} StopwatchException(std::string error) : error(error) {}
std::string error; std::string error;
}; };
enum StopwatchMode { enum StopwatchMode {
NONE = 0, // Clock is not initialized NONE = 0, // Clock is not initialized
CPU_TIME = 1, // Clock calculates time ranges using ctime and CLOCKS_PER_SEC CPU_TIME = 1, // Clock calculates time ranges using ctime and CLOCKS_PER_SEC
REAL_TIME = 2 // Clock calculates time by asking the operating system how REAL_TIME = 2 // Clock calculates time by asking the operating system how
// much real time passed // much real time passed
}; };
#define STOP_WATCH_MAX_NAME_LENGTH 80 #define STOP_WATCH_MAX_NAME_LENGTH 80
/** /**
@brief A class representing a stopwatch. @brief A class representing a stopwatch.
@code @code
Stopwatch swatch(); Stopwatch swatch();
@endcode @endcode
The Stopwatch class can be used to measure execution time of code, The Stopwatch class can be used to measure execution time of code,
algorithms, etc., // TODO: he Stopwatch can be initialized in two algorithms, etc., // TODO: he Stopwatch can be initialized in two
time-taking modes, CPU time and real time: time-taking modes, CPU time and real time:
@code @code
swatch.set_mode(REAL_TIME); swatch.set_mode(REAL_TIME);
@endcode @endcode
CPU time is the time spent by the processor on a certain piece of code, CPU time is the time spent by the processor on a certain piece of code,
while real time is the real amount of time taken by a certain piece of while real time is the real amount of time taken by a certain piece of
code to execute (i.e. in general if you are doing hard work such as code to execute (i.e. in general if you are doing hard work such as
image or video editing on a different process the measured time will image or video editing on a different process the measured time will
probably increase). probably increase).
How does it work? Basically, one wraps the code to be measured with the How does it work? Basically, one wraps the code to be measured with the
following method calls: following method calls:
@code @code
swatch.start("My astounding algorithm"); swatch.start("My astounding algorithm");
// Hic est code // Hic est code
swatch.stop("My astounding algorithm"); swatch.stop("My astounding algorithm");
@endcode @endcode
A string representing the code ID is provided so that nested portions of A string representing the code ID is provided so that nested portions of
code can be profiled separately: code can be profiled separately:
@code @code
swatch.start("My astounding algorithm"); swatch.start("My astounding algorithm");
swatch.start("My astounding algorithm - Super smart init"); swatch.start("My astounding algorithm - Super smart init");
// Initialization // Initialization
swatch.stop("My astounding algorithm - Super smart init"); swatch.stop("My astounding algorithm - Super smart init");
swatch.start("My astounding algorithm - Main loop"); swatch.start("My astounding algorithm - Main loop");
// Loop // Loop
swatch.stop("My astounding algorithm - Main loop"); swatch.stop("My astounding algorithm - Main loop");
swatch.stop("My astounding algorithm"); swatch.stop("My astounding algorithm");
@endcode @endcode
Note: ID strings can be whatever you like, in the previous example I have Note: ID strings can be whatever you like, in the previous example I have
used "My astounding algorithm - *" only to enforce the fact that the used "My astounding algorithm - *" only to enforce the fact that the
measured code portions are part of My astounding algorithm, but there's no measured code portions are part of My astounding algorithm, but there's no
connection between the three measurements. connection between the three measurements.
If the code for a certain task is scattered through different files or If the code for a certain task is scattered through different files or
portions of the same file one can use the start-pause-stop method: portions of the same file one can use the start-pause-stop method:
@code @code
swatch.start("Setup"); swatch.start("Setup");
// First part of setup // First part of setup
swatch.pause("Setup"); swatch.pause("Setup");
swatch.start("Main logic"); swatch.start("Main logic");
// Main logic // Main logic
swatch.stop("Main logic"); swatch.stop("Main logic");
swatch.start("Setup"); swatch.start("Setup");
// Cleanup (part of the setup) // Cleanup (part of the setup)
swatch.stop("Setup"); swatch.stop("Setup");
@endcode @endcode
Finally, to report the results of the measurements just run: Finally, to report the results of the measurements just run:
@code @code
swatch.report("Code ID"); swatch.report("Code ID");
@endcode @endcode
Thou can also provide an additional std::ostream& parameter to report() to Thou can also provide an additional std::ostream& parameter to report() to
redirect the logging on a different output. Also, you can use the redirect the logging on a different output. Also, you can use the
get_total/min/max/average_time() methods to get the individual numeric data, get_total/min/max/average_time() methods to get the individual numeric data,
without all the details of the logging. You can also extend Stopwatch to without all the details of the logging. You can also extend Stopwatch to
implement your own logging syntax. implement your own logging syntax.
To report all the measurements: To report all the measurements:
@code @code
swatch.report_all(); swatch.report_all();
@endcode @endcode
Same as above, you can redirect the output by providing a std::ostream& Same as above, you can redirect the output by providing a std::ostream&
parameter. parameter.
*/ */
class Stopwatch { class Stopwatch {
public: public:
/** Constructor */ /** Constructor */
Stopwatch(StopwatchMode _mode = NONE); Stopwatch(StopwatchMode _mode = NONE);
/** Destructor */ /** Destructor */
~Stopwatch(); ~Stopwatch();
/** Tells if a performance with a certain ID exists */ /** Tells if a performance with a certain ID exists */
bool performance_exists(std::string perf_name); bool performance_exists(std::string perf_name);
/** Initialize stopwatch to use a certain time taking mode */ /** Initialize stopwatch to use a certain time taking mode */
void set_mode(StopwatchMode mode); void set_mode(StopwatchMode mode);
/** Start the stopwatch related to a certain piece of code */ /** Start the stopwatch related to a certain piece of code */
void start(std::string perf_name); void start(std::string perf_name);
/** Stops the stopwatch related to a certain piece of code */ /** Stops the stopwatch related to a certain piece of code */
void stop(std::string perf_name); void stop(std::string perf_name);
/** Stops the stopwatch related to a certain piece of code */ /** Stops the stopwatch related to a certain piece of code */
void pause(std::string perf_name); void pause(std::string perf_name);
/** Reset a certain performance record */ /** Reset a certain performance record */
void reset(std::string perf_name); void reset(std::string perf_name);
/** Resets all the performance records */ /** Resets all the performance records */
void reset_all(); void reset_all();
/** Dump the data of a certain performance record */ /** Dump the data of a certain performance record */
void report(std::string perf_name, int precision = 2, void report(std::string perf_name, int precision = 2,
std::ostream &output = std::cout); std::ostream &output = std::cout);
/** Dump the data of all the performance records */ /** Dump the data of all the performance records */
void report_all(int precision = 2, std::ostream &output = std::cout); void report_all(int precision = 2, std::ostream &output = std::cout);
/** Returns total execution time of a certain performance */ /** Returns total execution time of a certain performance */
long double get_total_time(std::string perf_name); long double get_total_time(std::string perf_name);
/** Returns average execution time of a certain performance */ /** Returns average execution time of a certain performance */
long double get_average_time(std::string perf_name); long double get_average_time(std::string perf_name);
/** Returns minimum execution time of a certain performance */ /** Returns minimum execution time of a certain performance */
long double get_min_time(std::string perf_name); long double get_min_time(std::string perf_name);
/** Returns maximum execution time of a certain performance */ /** Returns maximum execution time of a certain performance */
long double get_max_time(std::string perf_name); long double get_max_time(std::string perf_name);
/** Return last measurement of a certain performance */ /** Return last measurement of a certain performance */
long double get_last_time(std::string perf_name); long double get_last_time(std::string perf_name);
/** Return the time since the start of the last measurement of a given /** Return the time since the start of the last measurement of a given
performance. */ performance. */
long double get_time_so_far(std::string perf_name); long double get_time_so_far(std::string perf_name);
/** Turn off clock, all the Stopwatch::* methods return without doing /** Turn off clock, all the Stopwatch::* methods return without doing
anything after this method is called. */ anything after this method is called. */
void turn_off(); void turn_off();
/** Turn on clock, restore clock operativity after a turn_off(). */ /** Turn on clock, restore clock operativity after a turn_off(). */
void turn_on(); void turn_on();
/** Take time, depends on mode */ /** Take time, depends on mode */
long double take_time(); long double take_time();
protected: protected:
/** Struct to hold the performance data */ /** Struct to hold the performance data */
struct PerformanceData { struct PerformanceData {
PerformanceData() PerformanceData()
: clock_start(0), total_time(0), min_time(0), max_time(0), last_time(0), : clock_start(0), total_time(0), min_time(0), max_time(0), last_time(0),
paused(false), stops(0) {} paused(false), stops(0) {}
/** Start time */ /** Start time */
long double clock_start; long double clock_start;
/** Cumulative total time */ /** Cumulative total time */
long double total_time; long double total_time;
/** Minimum time */ /** Minimum time */
long double min_time; long double min_time;
/** Maximum time */ /** Maximum time */
long double max_time; long double max_time;
/** Last time */ /** Last time */
long double last_time; long double last_time;
/** Tells if this performance has been paused, only for internal use */ /** Tells if this performance has been paused, only for internal use */
bool paused; bool paused;
/** How many cycles have been this stopwatch executed? */ /** How many cycles have been this stopwatch executed? */
int stops; int stops;
}; };
/** Flag to hold the clock's status */ /** Flag to hold the clock's status */
bool active; bool active;
/** Time taking mode */ /** Time taking mode */
StopwatchMode mode; StopwatchMode mode;
/** Pointer to the dynamic structure which holds the collection of performance /** Pointer to the dynamic structure which holds the collection of performance
data */ data */
std::map<std::string, PerformanceData> *records_of; std::map<std::string, PerformanceData> *records_of;
}; };
Stopwatch &getProfiler(); Stopwatch &getProfiler();
#ifndef WIN32 #ifndef WIN32
#pragma GCC visibility pop #pragma GCC visibility pop
#endif #endif
#endif #endif
...@@ -35,7 +35,7 @@ using namespace dynamicgraph::sot; ...@@ -35,7 +35,7 @@ using namespace dynamicgraph::sot;
typedef pinocchio::CartesianProductOperation< typedef pinocchio::CartesianProductOperation<
pinocchio::VectorSpaceOperationTpl<3, double>, pinocchio::VectorSpaceOperationTpl<3, double>,
pinocchio::SpecialOrthogonalOperationTpl<3, double>> pinocchio::SpecialOrthogonalOperationTpl<3, double> >
R3xSO3_t; R3xSO3_t;
typedef pinocchio::SpecialEuclideanOperationTpl<3, double> SE3_t; typedef pinocchio::SpecialEuclideanOperationTpl<3, double> SE3_t;
template <Representation_t representation> struct LG_t { template <Representation_t representation> struct LG_t {
......
...@@ -598,7 +598,8 @@ const double sotHouseholdMatrices::THRESHOLD = 1e-9; ...@@ -598,7 +598,8 @@ const double sotHouseholdMatrices::THRESHOLD = 1e-9;
/* ---------------------------------------------------------- */ /* ---------------------------------------------------------- */
typedef bub::triangular_adaptor< typedef bub::triangular_adaptor<
bub::matrix_range<bub::matrix<double, boost::numeric::ublas::column_major>>, bub::matrix_range<
bub::matrix<double, boost::numeric::ublas::column_major> >,
bub::upper> bub::upper>
MatrixTriSquare; MatrixTriSquare;
...@@ -733,11 +734,11 @@ dynamicgraph::Vector &SotQr::computeControlLaw(dynamicgraph::Vector &control, ...@@ -733,11 +734,11 @@ dynamicgraph::Vector &SotQr::computeControlLaw(dynamicgraph::Vector &control,
if (rank1 < m1) // Rank deficiency if (rank1 < m1) // Rank deficiency
{ {
bub::matrix_range< bub::matrix_range<
bub::matrix<double, boost::numeric::ublas::column_major>> bub::matrix<double, boost::numeric::ublas::column_major> >
QR1sup(QR1, bub::range(0, rank1), bub::range(0, m1)); QR1sup(QR1, bub::range(0, rank1), bub::range(0, m1));
invGeneralizeCholeskiUpdate(QR1sup); invGeneralizeCholeskiUpdate(QR1sup);
} }
bub::matrix_range<bub::matrix<double, boost::numeric::ublas::column_major>> bub::matrix_range<bub::matrix<double, boost::numeric::ublas::column_major> >
QR1sup(QR1, bub::range(0, rank1), bub::range(0, rank1)); QR1sup(QR1, bub::range(0, rank1), bub::range(0, rank1));
const MatrixTriSquare R1(QR1sup); const MatrixTriSquare R1(QR1sup);
...@@ -829,11 +830,11 @@ dynamicgraph::Vector &SotQr::computeControlLaw(dynamicgraph::Vector &control, ...@@ -829,11 +830,11 @@ dynamicgraph::Vector &SotQr::computeControlLaw(dynamicgraph::Vector &control,
if (rank2 < m2) // Rank deficiency if (rank2 < m2) // Rank deficiency
{ {
bub::matrix_range< bub::matrix_range<
bub::matrix<double, boost::numeric::ublas::column_major>> bub::matrix<double, boost::numeric::ublas::column_major> >
QR2sup(QR2, bub::range(0, rank2), bub::range(0, m2)); QR2sup(QR2, bub::range(0, rank2), bub::range(0, m2));
invGeneralizeCholeskiUpdate(QR2sup); invGeneralizeCholeskiUpdate(QR2sup);
} }
bub::matrix_range<bub::matrix<double, boost::numeric::ublas::column_major>> bub::matrix_range<bub::matrix<double, boost::numeric::ublas::column_major> >
QR2sup(QR2, bub::range(0, rank2), bub::range(0, rank2)); QR2sup(QR2, bub::range(0, rank2), bub::range(0, rank2));
const MatrixTriSquare R2(QR2sup); const MatrixTriSquare R2(QR2sup);
......
...@@ -55,12 +55,12 @@ BOOST_PYTHON_MODULE(robot_utils_sot_py) { ...@@ -55,12 +55,12 @@ BOOST_PYTHON_MODULE(robot_utils_sot_py) {
//.def("get_id_from_name",&RobotUtil::get_id_from_name) //.def("get_id_from_name",&RobotUtil::get_id_from_name)
; ;
class_<std::map<Index, ForceLimits>>("IndexForceLimits") class_<std::map<Index, ForceLimits> >("IndexForceLimits")
.def(map_indexing_suite<std::map<Index, ForceLimits>>()); .def(map_indexing_suite<std::map<Index, ForceLimits> >());
class_<std::map<std::string, Index>>("stringIndex") class_<std::map<std::string, Index> >("stringIndex")
.def(map_indexing_suite<std::map<std::string, Index>>()); .def(map_indexing_suite<std::map<std::string, Index> >());
class_<std::map<Index, std::string>>("Indexstring") class_<std::map<Index, std::string> >("Indexstring")
.def(map_indexing_suite<std::map<Index, std::string>>()); .def(map_indexing_suite<std::map<Index, std::string> >());
} }
...@@ -273,7 +273,7 @@ typedef pinocchio::SE3 SE3; ...@@ -273,7 +273,7 @@ typedef pinocchio::SE3 SE3;
typedef pinocchio::SpecialEuclideanOperationTpl<3, double> SE3_t; typedef pinocchio::SpecialEuclideanOperationTpl<3, double> SE3_t;
typedef pinocchio::CartesianProductOperation< typedef pinocchio::CartesianProductOperation<
pinocchio::VectorSpaceOperationTpl<3, double>, pinocchio::VectorSpaceOperationTpl<3, double>,
pinocchio::SpecialOrthogonalOperationTpl<3, double>> pinocchio::SpecialOrthogonalOperationTpl<3, double> >
R3xSO3_t; R3xSO3_t;
template <Representation_t representation> struct LG_t { template <Representation_t representation> struct LG_t {
typedef typename boost::mpl::if_c<representation == SE3Representation, SE3_t, typedef typename boost::mpl::if_c<representation == SE3Representation, SE3_t,
......
...@@ -245,7 +245,8 @@ int main(int argc, char **argv) { ...@@ -245,7 +245,8 @@ int main(int argc, char **argv) {
if (!ib) { if (!ib) {
// sotDEBUG(15) << dynamicgraph::MATLAB <<"M = "<< M <<endl; // sotDEBUG(15) << dynamicgraph::MATLAB <<"M = "<< M <<endl;
// sotDEBUG(15) << dynamicgraph::MATLAB <<"Mcreuse = "<< Mcreuse // sotDEBUG(15) << dynamicgraph::MATLAB <<"Mcreuse = "<< Mcreuse
//<<endl; sotDEBUG(15) << dynamicgraph::MATLAB <<"Minvnc = "<< Minv //<<endl; sotDEBUG(15) << dynamicgraph::MATLAB <<"Minvnc = "<<
// Minv
//<<endl; //<<endl;