<commit_before><commit_msg>Program to generate a maple model of a robot.<commit_after>/* @doc \file Object to generate a file following AMELIF format.

   Copyright (c) 2010
   @author <NAME>
   JRL-Japan, CNRS/AIST
 
   All rights reserved.

   Please refers to file License.txt for details on the license.

*/
#include <string>
#include <iostream>
#include <fstream>

#include <dynamicsJRLJapan/dynamicsJRLJapanFactory.h>
#include "GenerateRobotForMaple.h"

using namespace std;
using namespace dynamicsJRLJapan;

void ExportToMapple(CjrlHumanoidDynamicRobot *aHDR,
		   std::vector<BodyGeometricalData> &aVectorOfURLs,
		   std::string &Path,
		   std::string &RobotFileName)
{
  dynamicsJRLJapan::Tools::GenerateRobotForMaple aGenerateRobotForMaple;

  string aRobotVrml="ROBOT";
  aGenerateRobotForMaple.GenerateRobot(aRobotVrml,aHDR);
}


void RobotSetPosition(CjrlHumanoidDynamicRobot *aHDR,
		      std::string FileOfJointValues)
{
  unsigned int NbOfDofs = aHDR->numberDof();

  ifstream aif((char *)FileOfJointValues.c_str(),
		ifstream::in);

  MAL_VECTOR_DIM(aCurrentConf,double,NbOfDofs);
  int lindex=0;
  for(unsigned int i=0;i<6;i++)
      aCurrentConf[lindex++] = 0.0;

  if (!aif.is_open())
    for(unsigned int i=6;i<NbOfDofs;i++)
      aCurrentConf[lindex++] = 0.0;
  else
    {
      for(unsigned int i=6;i<NbOfDofs;i++)
	{
	  aif >> aCurrentConf[lindex] ;
	  aCurrentConf[lindex]= aCurrentConf[lindex] * M_PI/180.0; 
	  lindex++;
	}
      aif.close();
    }
  
  for(unsigned int i=0;i<NbOfDofs;i++)
    {
      cout << aCurrentConf[i] << endl;
    }
    
  aHDR->currentConfiguration(aCurrentConf);
  MAL_VECTOR_DIM(aCurrentVel,double,NbOfDofs);
  MAL_VECTOR_FILL(aCurrentVel,0.0);
  MAL_VECTOR_DIM(aCurrentAcc,double,NbOfDofs);
  MAL_VECTOR_FILL(aCurrentAcc,0.0);

  // This is mandatory for this implementation of computeForwardKinematics
  // to compute the derivative of the momentum.
  {
    string inProperty[4]={"TimeStep","ComputeAcceleration",
			  "ComputeBackwardDynamics", "ComputeZMP"};
    string inValue[4]={"0.005","false","false","true"};
    for(unsigned int i=0;i<4;i++)
      aHDR->setProperty(inProperty[i],inValue[i]);

  }
  
  aHDR->currentVelocity(aCurrentVel);
  aHDR->currentAcceleration(aCurrentAcc);
  aHDR->computeForwardKinematics();

}

int main(int argc, char *argv[])
{
  string aSpecificitiesFileName;
  string aPath;
  string aName;
  string aMapFromJointToRank;
  string aFileJointValue;

  ofstream tcout("output.txt",ofstream::out);

  if (argc!=6)
    {
      aPath="./";
      aName="sample.wrl";
      aSpecificitiesFileName = "sampleSpecificities.xml";
      aMapFromJointToRank = "sampleLinkJointRank.xml";
      aFileJointValue="position.articular";
    }
  else 
    {
      aSpecificitiesFileName = argv[3];
      aPath=argv[1];
      aName=argv[2];
      aMapFromJointToRank=argv[4];
      aFileJointValue = argv[5];
    }
  dynamicsJRLJapan::ObjectFactory aRobotDynamicsObjectConstructor;
  
  CjrlHumanoidDynamicRobot * aHDR = aRobotDynamicsObjectConstructor.createHumanoidDynamicRobot();

  if (aHDR==0)
    { 
      cerr<< "Dynamic cast on HDR failed " << endl;
      exit(-1);
    }
  string RobotFileName = aPath+aName;
  cout << "RobotFileNAme :" << RobotFileName << endl;
  vector<BodyGeometricalData> aVectorOfURLs;
  dynamicsJRLJapan::parseOpenHRPVRMLFile(*aHDR,RobotFileName,
					 aMapFromJointToRank,
					 aSpecificitiesFileName,
					 aVectorOfURLs);

  RobotSetPosition(aHDR,aFileJointValue);
  
  ExportToMapple(aHDR,aVectorOfURLs,aPath, RobotFileName);

  delete aHDR;
}
{'fraction_non_alphanumeric': 0.12250632200056195, 'fraction_numerical': 0.010677156504636133, 'mean_word_length': 4.353383458646617, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2105791', 'n_tokens_mistral': 1382, 'n_tokens_neox': 1289, 'n_words': 214}