Commit 91fd6c3c authored by Olivier Stasse's avatar Olivier Stasse
Browse files

Format code according to Google style.

parent 30c6a415
......@@ -34,99 +34,72 @@
Please see license.txt for more information on license.
*/
#include <iostream>
#include <fstream>
#include <Clock.hh>
#include <fstream>
#include <iostream>
using namespace PatternGeneratorJRL;
Clock::Clock()
{
Clock::Clock() {
Reset();
m_DataBuffer.resize(300000);
struct timeval startingtime;
gettimeofday(&startingtime,0);
gettimeofday(&startingtime, 0);
m_StartingTime = startingtime.tv_sec + 0.000001 * startingtime.tv_usec;
}
Clock::~Clock() {}
Clock::~Clock()
{
}
void Clock::Reset()
{
void Clock::Reset() {
m_NbOfIterations = 0;
m_MaximumTime = 0.0;
m_TotalTime=0.0;
m_TotalTime = 0.0;
struct timeval startingtime;
gettimeofday(&startingtime,0);
gettimeofday(&startingtime, 0);
m_StartingTime = startingtime.tv_sec + 0.000001 * startingtime.tv_usec;
}
void Clock::StartTiming()
{
gettimeofday(&m_BeginTimeStamp,0);
void Clock::StartTiming() { gettimeofday(&m_BeginTimeStamp, 0); }
}
void Clock::StopTiming()
{
gettimeofday(&m_EndTimeStamp,0);
void Clock::StopTiming() {
gettimeofday(&m_EndTimeStamp, 0);
double ltime = m_EndTimeStamp.tv_sec - m_BeginTimeStamp.tv_sec +
0.000001 * (m_EndTimeStamp.tv_usec - m_BeginTimeStamp.tv_usec);
0.000001 * (m_EndTimeStamp.tv_usec - m_BeginTimeStamp.tv_usec);
m_MaximumTime = m_MaximumTime < ltime ? ltime : m_MaximumTime;
m_TotalTime += ltime;
m_DataBuffer[(m_NbOfIterations*2)%3000000]=
m_BeginTimeStamp.tv_sec +
0.000001 * m_BeginTimeStamp.tv_usec -
m_StartingTime;
m_DataBuffer[(m_NbOfIterations*2+1)%3000000]=ltime;
m_DataBuffer[(m_NbOfIterations * 2) % 3000000] =
m_BeginTimeStamp.tv_sec + 0.000001 * m_BeginTimeStamp.tv_usec -
m_StartingTime;
m_DataBuffer[(m_NbOfIterations * 2 + 1) % 3000000] = ltime;
}
void Clock::IncIteration(int lNbOfIts)
{
m_NbOfIterations += lNbOfIts;
}
void Clock::IncIteration(int lNbOfIts) { m_NbOfIterations += lNbOfIts; }
void Clock::RecordDataBuffer(std::string filename)
{
void Clock::RecordDataBuffer(std::string filename) {
std::ofstream aof(filename.c_str());
for(unsigned int i=0; i<2*m_NbOfIterations%300000; i+=2)
aof << m_DataBuffer[i]<< " " << m_DataBuffer[i+1] << std::endl;
for (unsigned int i = 0; i < 2 * m_NbOfIterations % 300000; i += 2)
aof << m_DataBuffer[i] << " " << m_DataBuffer[i + 1] << std::endl;
aof.close();
}
unsigned long int Clock::NbOfIterations()
{
return m_NbOfIterations;
}
unsigned long int Clock::NbOfIterations() { return m_NbOfIterations; }
double Clock::MaxTime()
{
return m_MaximumTime;
}
double Clock::MaxTime() { return m_MaximumTime; }
double Clock::TotalTime()
{
return m_TotalTime;
}
double Clock::TotalTime() { return m_TotalTime; }
double Clock::AverageTime()
{
if (m_NbOfIterations!=0)
return m_TotalTime/(double)m_NbOfIterations;
double Clock::AverageTime() {
if (m_NbOfIterations != 0)
return m_TotalTime / (double)m_NbOfIterations;
return 0.0;
}
void Clock::Display()
{
void Clock::Display() {
std::cout << "Average Time : " << AverageTime() << std::endl;
std::cout << "Total Time : " << TotalTime() << std::endl;
std::cout << "Max Time : " << MaxTime() << std::endl;
std::cout << "Nb of iterations: " << NbOfIterations() << std::endl;
}
......@@ -48,6 +48,8 @@
DebugFile.close();}
#define ODEBUG5(x,y) { std::ofstream DebugFile; \
DebugFile.open(y,ofstream::app); \
DebugFile.precision(8); \
DebugFile.setf(ios::scientific,ios::floatfield); \
DebugFile << __FILE__ << ":" \
<< __FUNCTION__ << "(#" \
<< __LINE__ << "):" << x << std::endl; \
......
......@@ -29,17 +29,14 @@
@ingroup foottrajectorygeneration
*/
#include <Debug.hh>
#include "FootTrajectoryGeneration/FootTrajectoryGenerationAbstract.hh"
#include <Debug.hh>
using namespace PatternGeneratorJRL;
FootTrajectoryGenerationAbstract::
FootTrajectoryGenerationAbstract
(SimplePluginManager *lSPM,
PRFoot * aFoot)
: SimplePlugin(lSPM),m_Foot(aFoot)
{
FootTrajectoryGenerationAbstract::FootTrajectoryGenerationAbstract(
SimplePluginManager *lSPM, PRFoot *aFoot)
: SimplePlugin(lSPM), m_Foot(aFoot) {
m_Omega = 0.0;
m_SamplingPeriod = 0.005;
m_isStepStairOn = 1;
......@@ -48,82 +45,59 @@ FootTrajectoryGenerationAbstract
// Define here the curving during the Step (ray defined along Y axis)
m_StepCurving = 0.2;
std::string aMethodName[5] = {":omega", ":stepheight", ":singlesupporttime",
":doublesupporttime",
":samplingperiod"
":stepstairon"};
std::string aMethodName[5] =
{
":omega",
":stepheight",
":singlesupporttime",
":doublesupporttime",
":samplingperiod"
":stepstairon"
};
for (int i=0; i<5; i++)
{
if (!RegisterMethod(aMethodName[i]))
{
std::cerr << "Unable to register " << aMethodName << std::endl;
}
for (int i = 0; i < 5; i++) {
if (!RegisterMethod(aMethodName[i])) {
std::cerr << "Unable to register " << aMethodName << std::endl;
}
}
}
void FootTrajectoryGenerationAbstract::CallMethod(std::string &Method,
std::istringstream &strm)
{
if (Method==":omega")
{
strm >> m_Omega;
}
else if (Method==":omega2")
{
strm >> m_Omega2;
}
else if (Method==":singlesupporttime")
{
strm >> m_TSingle;
}
else if (Method==":doublesupporttime")
{
strm >> m_TDouble;
}
else if (Method==":samplingperiod")
{
strm >> m_SamplingPeriod;
ODEBUG("Sampling period: " << m_SamplingPeriod);
}
else if (Method==":stepheight")
{
strm >> m_StepHeight;
ODEBUG(":stepheight " << m_StepHeight);
}
std::istringstream &strm) {
if (Method == ":omega") {
strm >> m_Omega;
} else if (Method == ":omega2") {
strm >> m_Omega2;
} else if (Method == ":singlesupporttime") {
strm >> m_TSingle;
} else if (Method == ":doublesupporttime") {
strm >> m_TDouble;
} else if (Method == ":samplingperiod") {
strm >> m_SamplingPeriod;
ODEBUG("Sampling period: " << m_SamplingPeriod);
} else if (Method == ":stepheight") {
strm >> m_StepHeight;
ODEBUG(":stepheight " << m_StepHeight);
}
}
void FootTrajectoryGenerationAbstract::
UpdateFootPosition
(std::deque<FootAbsolutePosition> &, //SupportFootAbsolutePositions,
std::deque<FootAbsolutePosition> &, //NoneSupportFootAbsolutePositions,
int, //CurrentAbsoluteIndex,
int, //IndexInitial,
double, //ModulatedSingleSupportTime,
int, //StepType,
int ) //LeftOrRight)
void FootTrajectoryGenerationAbstract::UpdateFootPosition(
std::deque<FootAbsolutePosition> &, // SupportFootAbsolutePositions,
std::deque<FootAbsolutePosition> &, // NoneSupportFootAbsolutePositions,
int, // CurrentAbsoluteIndex,
int, // IndexInitial,
double, // ModulatedSingleSupportTime,
int, // StepType,
int) // LeftOrRight)
{
LTHROW("FootTrajectoryGenerationAbstract::UpdateFootPosition-1: \
To be implemented ");
}
void FootTrajectoryGenerationAbstract::
UpdateFootPosition
(std::deque<FootAbsolutePosition> &, //SupportFootAbsolutePositions,
std::deque<FootAbsolutePosition> &, //NoneSupportFootAbsolutePositions,
int, // StartIndex,
int, //k,
double, //LocalInterpolationStartTime,
double, //ModulatedSingleSupportTime,
int, //StepType,
int ) //LeftOrRight)
void FootTrajectoryGenerationAbstract::UpdateFootPosition(
std::deque<FootAbsolutePosition> &, // SupportFootAbsolutePositions,
std::deque<FootAbsolutePosition> &, // NoneSupportFootAbsolutePositions,
int, // StartIndex,
int, // k,
double, // LocalInterpolationStartTime,
double, // ModulatedSingleSupportTime,
int, // StepType,
int) // LeftOrRight)
{
LTHROW("FootTrajectoryGenerationAbstract::UpdateFootPosition-2: \
To be implemented ");
......
......@@ -22,32 +22,24 @@
* Joint Japanese-French Robotics Laboratory (JRL)
*/
/*! \file GlobalStrategyManager.cpp
\brief This object defines a global strategy abstract object to generate
\brief This object defines a global strategy abstract object to generate
an output handled by the PatternGeneratorInterface object.
*/
#include <Debug.hh>
#include <deque>
#include <GlobalStrategyManagers/GlobalStrategyManager.hh>
#include <deque>
using namespace PatternGeneratorJRL;
GlobalStrategyManager::
GlobalStrategyManager
(SimplePluginManager *aPluginManager):
SimplePlugin(aPluginManager)
{
}
GlobalStrategyManager::GlobalStrategyManager(
SimplePluginManager *aPluginManager)
: SimplePlugin(aPluginManager) {}
void GlobalStrategyManager::
SetBufferPositions
(deque<ZMPPosition> * aZMPPositions,
deque<COMState> * aCOMBuffer,
deque<FootAbsolutePosition> *aLeftFootAbsolutePositions,
deque<FootAbsolutePosition> *aRightFootAbsolutePositions )
{
void GlobalStrategyManager::SetBufferPositions(
deque<ZMPPosition> *aZMPPositions, deque<COMState> *aCOMBuffer,
deque<FootAbsolutePosition> *aLeftFootAbsolutePositions,
deque<FootAbsolutePosition> *aRightFootAbsolutePositions) {
m_ZMPPositions = aZMPPositions;
m_COMBuffer = aCOMBuffer;
m_LeftFootPositions = aLeftFootAbsolutePositions;
......
This diff is collapsed.
This diff is collapsed.
......@@ -29,8 +29,7 @@ using namespace PatternGeneratorJRL;
#include <iostream>
using namespace std;
FootHalfSize::FootHalfSize()
{
FootHalfSize::FootHalfSize() {
m_HalfWidth = -1.0;
m_HalfHeight = -1.0;
m_Width = -1.0;
......@@ -44,14 +43,10 @@ FootHalfSize::FootHalfSize()
m_ConstraintsOnY = 0.02;
}
FootHalfSize::~FootHalfSize()
{
}
FootHalfSize::~FootHalfSize() {}
void FootHalfSize::setSize(double lWidth,
double lHeight,
double DSFeetDistance)
{
void FootHalfSize::setSize(double lWidth, double lHeight,
double DSFeetDistance) {
m_Height = lHeight;
m_Width = lWidth;
......@@ -59,8 +54,7 @@ void FootHalfSize::setSize(double lWidth,
updateHalfHeightDS(DSFeetDistance);
}
void FootHalfSize::updateHalfSize()
{
void FootHalfSize::updateHalfSize() {
m_HalfWidth = 0.5 * m_Width;
m_HalfHeight = 0.5 * m_Height;
......@@ -68,33 +62,21 @@ void FootHalfSize::updateHalfSize()
m_HalfHeight -= m_ConstraintsOnY;
}
void FootHalfSize::updateHalfHeightDS(double DSFeetDistance)
{
m_HalfHeightDS = m_HalfHeight+DSFeetDistance/2.0;
void FootHalfSize::updateHalfHeightDS(double DSFeetDistance) {
m_HalfHeightDS = m_HalfHeight + DSFeetDistance / 2.0;
}
void FootHalfSize::setConstraints(double OnX, double OnY, double DSFeetDistance)
{
void FootHalfSize::setConstraints(double OnX, double OnY,
double DSFeetDistance) {
m_ConstraintsOnX = OnX;
m_ConstraintsOnY = OnY;
updateHalfSize();
updateHalfHeightDS(DSFeetDistance);
}
double FootHalfSize::getHalfHeight() const
{
return m_HalfHeight;
}
double FootHalfSize::getHalfWidth() const
{
return m_HalfWidth;
}
double FootHalfSize::getHalfHeight() const { return m_HalfHeight; }
double FootHalfSize::getHalfHeightDS() const
{
return m_HalfHeightDS;
}
double FootHalfSize::getHalfWidth() const { return m_HalfWidth; }
double FootHalfSize::getHalfHeightDS() const { return m_HalfHeightDS; }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -24,81 +24,65 @@
*/
/* Polynomes object for trajectories. */
#include <iostream>
#include <Mathematics/Polynome.hh>
#include <iostream>
using namespace::PatternGeneratorJRL;
using namespace ::PatternGeneratorJRL;
Polynome::Polynome(int Degree)
{
Polynome::Polynome(int Degree) {
m_Coefficients.clear();
m_Coefficients.resize(Degree+1);
m_Coefficients.resize(Degree + 1);
m_Degree = Degree;
}
Polynome::~Polynome()
{
}
Polynome::~Polynome() {}
double Polynome::Compute(double t)
{
double r=0.0,pt=1.0;
for(unsigned int i=0; i<m_Coefficients.size(); i++)
{
r += m_Coefficients[i]*pt;
pt *=t;
}
double Polynome::Compute(double t) {
double r = 0.0, pt = 1.0;
for (unsigned int i = 0; i < m_Coefficients.size(); i++) {
r += m_Coefficients[i] * pt;
pt *= t;
}
return r;
}
double Polynome::ComputeDerivative(double t)
{
double r=0,pt=1;
for(unsigned int i=1; i<m_Coefficients.size(); i++)
{
r += i*m_Coefficients[i]*pt;
pt *=t;
}
double Polynome::ComputeDerivative(double t) {
double r = 0, pt = 1;
for (unsigned int i = 1; i < m_Coefficients.size(); i++) {
r += i * m_Coefficients[i] * pt;
pt *= t;
}
return r;
}
double Polynome::ComputeSecDerivative(double t)
{
double r=0,pt=1;
for(unsigned int i=2; i<m_Coefficients.size(); i++)
{
r += i*(i-1)*m_Coefficients[i]*pt;
pt *=t;
}
double Polynome::ComputeSecDerivative(double t) {
double r = 0, pt = 1;
for (unsigned int i = 2; i < m_Coefficients.size(); i++) {
r += i * (i - 1) * m_Coefficients[i] * pt;
pt *= t;
}
return r;
}
double Polynome::ComputeJerk(double t)
{
double r=0,pt=1;
for(unsigned int i=3; i<m_Coefficients.size(); i++)
{
r += i*(i-1)*(i-2)*m_Coefficients[i]*pt;
pt *=t;
}
double Polynome::ComputeJerk(double t) {
double r = 0, pt = 1;
for (unsigned int i = 3; i < m_Coefficients.size(); i++) {
r += i * (i - 1) * (i - 2) * m_Coefficients[i] * pt;
pt *= t;
}
return r;
}
void Polynome::GetCoefficients(vector<double> &lCoefficients) const
{
void Polynome::GetCoefficients(vector<double> &lCoefficients) const {
lCoefficients = m_Coefficients;
}
void Polynome::SetCoefficients(const vector<double> &lCoefficients)
{
void Polynome::SetCoefficients(const vector<double> &lCoefficients) {
m_Coefficients = lCoefficients;
}
void Polynome::print() const
{
for(unsigned int i=0; i<m_Coefficients.size(); i++)
cout << m_Coefficients[i] << " " ;
void Polynome::print() const {
for (unsigned int i = 0; i < m_Coefficients.size(); i++)
cout << m_Coefficients[i] << " ";
cout << endl;
}
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment