add utility for reading and writing of minitaur quadruped robot log files.
Example usage:
const char* fileName = "D:/LOG00053.TXT";
btAlignedObjectArray<MinitaurLogRecord> logRecords;
btAlignedObjectArray<std::string> structNames;
std::string structTypes;
bool verbose = false;
//reading
int val = readMinitaurLogFile(fileName, structNames, structTypes,
logRecords, verbose);
//writing
const char* fileNameOut = "D:/LOG00100.TXT";
FILE* f = createMinitaurLogFile(fileNameOut,structNames,structTypes);
for (int i=0;i<logRecords.size();i++)
{
appendMinitaurLogData(f, structTypes, logRecords[i]);
}
closeMinitaurLogFile(f);
This commit is contained in:
54
examples/Utils/RobotLoggingUtil.h
Normal file
54
examples/Utils/RobotLoggingUtil.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef ROBOT_LOGGING_UTIL_H
|
||||
#define ROBOT_LOGGING_UTIL_H
|
||||
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
#include <string>
|
||||
|
||||
struct MinitaurLogValue
|
||||
{
|
||||
MinitaurLogValue()
|
||||
:m_intVal(0xcdcdcdcd)
|
||||
{
|
||||
}
|
||||
MinitaurLogValue(int iv)
|
||||
:m_intVal(iv)
|
||||
{
|
||||
}
|
||||
MinitaurLogValue(float fv)
|
||||
:m_floatVal(fv)
|
||||
{
|
||||
}
|
||||
MinitaurLogValue(char fv)
|
||||
:m_charVal(fv)
|
||||
{
|
||||
}
|
||||
|
||||
union
|
||||
{
|
||||
char m_charVal;
|
||||
int m_intVal;
|
||||
float m_floatVal;
|
||||
};
|
||||
};
|
||||
|
||||
struct MinitaurLogRecord
|
||||
{
|
||||
btAlignedObjectArray<MinitaurLogValue> m_values;
|
||||
};
|
||||
|
||||
enum MINITAUR_LOG_ERROR
|
||||
{
|
||||
eMinitaurFileNotFound = -1,
|
||||
eCorruptHeader = -2,
|
||||
eUnknownType = -3,
|
||||
eCorruptValue = -4,
|
||||
eInvalidAABBAlignCheck = -5,
|
||||
};
|
||||
|
||||
int readMinitaurLogFile(const char* fileName, btAlignedObjectArray<std::string>& structNames, std::string& structTypes, btAlignedObjectArray<MinitaurLogRecord>& logRecords, bool verbose);
|
||||
|
||||
FILE* createMinitaurLogFile(const char* fileName, btAlignedObjectArray<std::string>& structNames, std::string& structTypes);
|
||||
void appendMinitaurLogData(FILE* f, std::string& structTypes, const MinitaurLogRecord& logData);
|
||||
void closeMinitaurLogFile(FILE* f);
|
||||
|
||||
#endif //ROBOT_LOGGING_UTIL_H
|
||||
Reference in New Issue
Block a user