Skip to content
Snippets Groups Projects
Forked from Stack Of Tasks / jrl-walkgen
192 commits behind the upstream repository.
TestRiccatiEquation.cpp 6.92 KiB
/*
 * Copyright 2009, 2010, 
 *
 * Francois Keith
 * Olivier  Stasse
 *
 * JRL, CNRS/AIST
 *
 * This file is part of walkGenJrl.
 * walkGenJrl is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * walkGenJrl is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License
 * along with walkGenJrl.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  Research carried out within the scope of the 
 *  Joint Japanese-French Robotics Laboratory (JRL)
 */
/*! \file TestRiccatiEquation.cpp
  \brief Example to solve the Riccati Equation for the preview control. */

#define NB_OF_FIELDS 1

#include <iostream>
#include <fstream>
#include <Debug.hh>
#include "PreviewControl/OptimalControllerSolver.hh"

using namespace std;

bool compareDebugFiles( string fileName )
{
  ifstream alif;
  unsigned max_nb_of_pbs=100;
  unsigned nb_of_pbs = 0;
  ODEBUG("Report : " << fileName);
  alif.open(fileName.c_str(),ifstream::in);
  if (!alif.is_open())
  {
    std::cerr << "Unable to open "<< fileName << std::endl;
    return -1;
  }

  ifstream arif;
  string refFileName = fileName + "ref" ;
  arif.open(refFileName.c_str(),ifstream::in);
  ODEBUG("ReportRef : " << refFileName);

  if (!arif.is_open())
  {
    std::cerr << "Unable to open "<< refFileName << std::endl;
    return -1;
  }


  ofstream areportof;
  string aFileName ;
  aFileName = fileName ;
  aFileName += ".report";
  areportof.open(aFileName.c_str(),ofstream::out);

  // Time
  double LocalInput[NB_OF_FIELDS], ReferenceInput[NB_OF_FIELDS];
  bool finalreport = true;