#include "RobotLoggingUtil.h" #include #include "LinearMath/btAlignedObjectArray.h" #include "../Importers/ImportURDFDemo/urdfStringSplit.h" static bool readLine(FILE* file, btAlignedObjectArray& line) { int c = 0; for (c=fgetc(file);(c != EOF && c != '\n');c=fgetc(file)) { line.push_back(c); } line.push_back(0); return (c == EOF); } int readMinitaurLogFile(const char* fileName, btAlignedObjectArray& structNames, std::string& structTypes, btAlignedObjectArray& logRecords, bool verbose) { int retVal = 0; FILE* f = fopen(fileName,"rb"); if (f) { if (verbose) { printf("Opened file %s\n", fileName); } btAlignedObjectArray line0Buf; bool eof = readLine(f,line0Buf); btAlignedObjectArray line1Buf; eof |= readLine(f,line1Buf); std::string line0 = &line0Buf[0]; structTypes = &line1Buf[0]; btAlignedObjectArray separators; separators.push_back(","); urdfStringSplit(structNames,line0,separators); if (verbose) { printf("Num Fields = %d\n",structNames.size()); } btAssert(structTypes.size() == structNames.size()); if (structTypes.size() != structNames.size()) { retVal = eCorruptHeader; } int numStructsRead = 0; if (structTypes.size() == structNames.size()) { while (!eof) { unsigned char blaat[1024]; size_t s = fread(blaat,2,1,f); if (s!=1) { eof=true; retVal = eInvalidAABBAlignCheck; break; } if ((blaat[0] != 0xaa) || (blaat[1] != 0xbb)) { if (verbose) { printf("Expected 0xaa0xbb, terminating\n"); } } if (verbose) { printf("Reading structure %d\n",numStructsRead); } MinitaurLogRecord record; for (int i=0;i& structNames, std::string& structTypes) { FILE* f = fopen(fileName,"wb"); if (f) { for (int i=0;i