|
Fast Research Interface Library
Manual and Documentation
|
Provides logging/oscilloscope/data recording functionality for the KUKA Fast Research Interface. More...
#include <DataLogging.h>
Public Member Functions | |
| DataLogging (const char *RobotName, const char *LoggingPath, const char *LoggingFileName, const unsigned int &MaxNumberOfEntries) | |
| Constructor. | |
| ~DataLogging (void) | |
| Destructor. | |
| int | PrepareLogging (const unsigned int &ControlScheme, const char *FileIdentifier=NULL) |
| Creates the output file and initializes all required class attributes. | |
| void | AddEntry (const tFriMsrData &ReceivedFRIData, const tFriCmdData &SentFRIData) |
| Writes control data data to the heap memory. | |
| int | WriteToFile (void) |
| Writes the logged data from the heap memory to the output file and closes the file. | |
Protected Types | |
| enum | ObjectState { PrepareLoggingCalled = 1, WriteToFileCalled = 2 } |
| Describes the state of the object (i.e., whether a file is currently opened and in use) More... | |
Protected Attributes | |
| ObjectState | CurrentObjectState |
| Stores the current state of the object. | |
| char * | MachineName |
A pointer to an array of char values containing the name of the machine. | |
| char * | OutputPath |
A pointer to an array of char values containing the output directory. | |
| char * | OutputFileName |
A pointer to an array of char values containing the output file name and its extension. | |
| char * | CompleteOutputFileString |
A pointer to an array of char values containing the complete current output file (incl. date and time) name and its directory. | |
| unsigned int | MaximumNumberOfEntries |
| Specifies the maximum number of entries to be stored in DataLogging::LoggingMemory. | |
| unsigned int | OutputCounter |
| Specifies the total number of calls of DataLogging::AddEntry() | |
| unsigned int | CurrentControlScheme |
| Specifies the current control scheme. | |
| float ** | LoggingMemory |
A pointer to an array of pointers to arrays of float values containing the logged data. | |
| FILE * | OutputFileHandler |
| A pointer to the file handler of the output file described by DataLogging::CompleteOutputFileString. | |
Provides logging/oscilloscope/data recording functionality for the KUKA Fast Research Interface.
The class has been designed for the Fast Research Interface of the KUKA KUKA Light-Weight Robot IV. It offers the possibility of writing all relevant control data, which is exchanged between the KRC unit and the remote host, into a file that can be read by Matlab, Microsoft Excel, or other software programs.
The constructor DataLogging::DataLogging() allocates a (rather huge) amount of heap memory, to which all the data can be written in each communication (i.e., control) control cycle under real-time conditions. The user can specify the maximum number of entries that will logged. Before the scope functionality can be used, the method DataLogging::PrepareLogging() has to be called. If running with a period of one millisecond, and a maximum number of 60,000, up to one minute can be recorded by calling the method DataLogging::AddEntry() after each data exchange between the remote host and the KRC unit. DataLogging::AddEntry() is real-time capable. At a later time instant (e.g., when the robot was shut down or needs not to be controlled by the remote host anymore), the method DataLogging::WriteToFile() may be called. This method does not work in real-time and writes all entries that were stored in the heap memory into a file. This method can also be used in multi-robot robot environments as each robot arm may be addressed by a name (cf. DataLogging::MachineName).
The actual output file name is unambiguously generated as follows: Path/Date-Time-OptionalUserDefinedString-RobotName-FileName (e.g., /home/lwrcontrol/output/100729-104452-Test-980039-LWRScope.dat).
*Depending on the chosen controller, different control values are written to the log file:
Joint position controller
ActFJ[1,...,7]UDesJ[1,...,7]ActJ[1,...,7]KDesJ[1,...,7] Cartesian impedance controller
DesK[x,y,z,a,b,c]DesD[x,y,z,a,b,c]UDesF[x,y,z,a,b,c] Joint impedance controller
ActFJ[1,...,7]UDesJ[1,...,7]ActJ[1,...,7]KDesJ[1,...,7]DesKJ[1,...,7]DesDJ[1,...,7]UDesFJ[1,...,7]KOffP[1,...,7] Joint torque controller
ActFJ[1,...,7]ActJ[1,...,7]UDesFJ[1,...,7]This real-time logging/scope functionality on this low level may be an important tool for debugging and control prototyping purposes as they commonly are done by research and development institutions.
Definition at line 147 of file DataLogging.h.
enum DataLogging::ObjectState [protected] |
Describes the state of the object (i.e., whether a file is currently opened and in use)
Definition at line 319 of file DataLogging.h.
| DataLogging::DataLogging | ( | const char * | RobotName, |
| const char * | LoggingPath, | ||
| const char * | LoggingFileName, | ||
| const unsigned int & | MaxNumberOfEntries | ||
| ) |
Constructor.
The constructor initializes all class attributes and allocates the required amount of heap memory.
| RobotName | A pointer to an array of char containing the name of the robot (e.g., its serial number). This value will be used as part of the name of the file, in which the logged data is stored. |
| LoggingPath | A pointer to an array of char containing the directory, in which the logging file will be created (e.g. "/home/lwrcontrol/output"). |
| LoggingFileName | A pointer to an array of char containing the final part of the file name as well as the file extension (e.g. "-LWR-Scope.dat"). |
| MaxNumberOfEntries | The maximum number entries that are stored in the heap memory. One entry is required for each message received by the remote host from the KRC unit. To log control data for an amount of time of one minute, the values has to be 60000 if the the controllers run at rate of 1 KHz. |
Definition at line 88 of file DataLogging.cpp.
| DataLogging::~DataLogging | ( | void | ) |
Destructor.
The destructor free the memory that was allocated by the constructor DataLogging::DataLogging(). If DataLogging::PrepareLogging() was was called, and if DataLogging::WriteToFile() has not been called yet, the destructor calls DataLogging::WriteToFile() first in order to prevent the user from data loss.
Definition at line 127 of file DataLogging.cpp.
| void DataLogging::AddEntry | ( | const tFriMsrData & | ReceivedFRIData, |
| const tFriCmdData & | SentFRIData | ||
| ) |
Writes control data data to the heap memory.
Depending on the chosen controller (specified by DataLogging::CurrentControlScheme) respective data is extracted from ReceivedFRIData and SentFRIData. This data is copied to the heap memory DataLogging::LoggingMemory.
| ReceivedFRIData | The complete data package received by the remote host from the KRC unit. |
| SentFRIData | The complete data package sent by the remote host to the KRC unit. |
Definition at line 253 of file DataLogging.cpp.
| int DataLogging::PrepareLogging | ( | const unsigned int & | ControlScheme, |
| const char * | FileIdentifier = NULL |
||
| ) |
Creates the output file and initializes all required class attributes.
The file name for the logging file is generated, the file is opened (i.e., created) using the file handler DataLogging::OutputFileHandler, and all required class attributes are initializes, such that in the following, the DataLogging::AddEntry() can be called after each data exchange between the remote host and the KRC unit in order to perform the actual logging function.
| ControlScheme | This value has to equal one of the following set: |
Depending on this value, the logged control data is chosen (see also DataLogging).
| FileIdentifier | A pointer to an array of char values containing a string to identify the written log file. This parameter is optional. |
EBADF if the file could not be created.EINVAL if the parameter ControlScheme is invalid.EOK otherwise.Definition at line 149 of file DataLogging.cpp.
| int DataLogging::WriteToFile | ( | void | ) |
Writes the logged data from the heap memory to the output file and closes the file.
The data stored in the heap memory at DataLogging::LoggingMemory by the method DataLogging::AddEntry() is written to the file DataLogging::CompleteOutputFileString created and opened by DataLogging::PrepareLogging() and pointed to by the file handler DataLogging::OutputFileHandler.
Only necessary data is written to the output file, that is, if the number of entries in DataLogging::LoggingMemory, is less than DataLogging::MaximumNumberOfEntries, only DataLogging::OutputCounter entries are written to the output file.
EOF if the file could not be closed.EINVAL If the parameter ControlScheme is invalid.EOK otherwise.Definition at line 307 of file DataLogging.cpp.
DataLogging::CompleteOutputFileString [protected] |
A pointer to an array of char values containing the complete current output file (incl. date and time) name and its directory.
Definition at line 368 of file DataLogging.h.
DataLogging::CurrentControlScheme [protected] |
Specifies the current control scheme.
Definition at line 404 of file DataLogging.h.
DataLogging::CurrentObjectState [protected] |
Stores the current state of the object.
Definition at line 332 of file DataLogging.h.
DataLogging::LoggingMemory [protected] |
A pointer to an array of pointers to arrays of float values containing the logged data.
Definition at line 413 of file DataLogging.h.
DataLogging::MachineName [protected] |
A pointer to an array of char values containing the name of the machine.
Definition at line 341 of file DataLogging.h.
DataLogging::MaximumNumberOfEntries [protected] |
Specifies the maximum number of entries to be stored in DataLogging::LoggingMemory.
Definition at line 377 of file DataLogging.h.
DataLogging::OutputCounter [protected] |
Specifies the total number of calls of DataLogging::AddEntry()
Definition at line 392 of file DataLogging.h.
FILE * DataLogging::OutputFileHandler [protected] |
A pointer to the file handler of the output file described by DataLogging::CompleteOutputFileString.
Definition at line 422 of file DataLogging.h.
DataLogging::OutputFileName [protected] |
A pointer to an array of char values containing the output file name and its extension.
Definition at line 359 of file DataLogging.h.
DataLogging::OutputPath [protected] |
A pointer to an array of char values containing the output directory.
Definition at line 350 of file DataLogging.h.