com.kuka.roboticsAPI.sensorModel
Class DataRecorder

java.lang.Object
  extended by com.kuka.roboticsAPI.sensorModel.DataRecorder
All Implemented Interfaces:
Runnable

public class DataRecorder
extends Object
implements Runnable

Class to record data in a file.

After generating the DataRecorder it can be parameterized, in order to define which data sources should be recorded. Parameterization is possible as long as the DataRecorder is not enabled. After having enabled the recorder the attempt to parameterize it will cause an exception.
If no values for timeout, sample interval and fileName are defined, default values are used (timeout = -1 which means no timeout, sample interval = 1ms, filename = "DataRecorder"+generated-ID+".log". Without a timeout the recording will stop as soon as the buffer size of 16MB is reached, or 30000 datasets are gathered.

After parameterization 2 options exist to use the DataRecorder:

1. In combination with a RobotMotion

sa Here, the recording will be started by a trigger ( StartRecordingAction), e.g. ".triggerWhen(ICondition, new StartRecordingAction(recorder))". Accordingly, it can be stopped by a trigger or after timeout ( StopRecordingAction ), e.g. ".triggerWhen(ICondition, new StopRecordingAction(recorder))".

2. As stand-alone recording

Here, the DataRecorder must be enabled before the recording can be started by startRecording(). The recording can be stopped by timeout or by stopRecoding().

The recorded file is text based (csv-file) and is formated as a table with rows and columns. The first row contains a header which describes the values in each column. For each sample of the defined sample interval a row will be written which contains the recorded values of the added data sources. In the first and the second column the time stamp in nanoseconds is stored. Each additional column contains the parameterized data to record as described in the header. For example " addCartesianForce(AbstractFrame, AbstractFrame)", the file contains eight columns, the first and the second column for the time stamps and six columns for each value of the Cartesian force vector.
The location of the file is defined in the getURL() method.

See Also:
enable(), startRecording(), stopRecording()

Nested Class Summary
static class DataRecorder.AngleUnit
          Enumeration to select the unit of an angle.
 
Constructor Summary
DataRecorder()
          Creates a default DataRecorder with default values.
DataRecorder(String fileName, long timeout, TimeUnit timeUnit, int sampleInterval)
          Creates a new DataRecorder.
 
Method Summary
 DataRecorder addCartesianForce(AbstractFrame measureFrame, AbstractFrame orientationFrame)
          Adds Cartesian forces (along axis x, y, z) in [N].
 DataRecorder addCartesianTorque(AbstractFrame measureFrame, AbstractFrame orientationFrame)
          Adds Cartesian torques (about axis x, y, z) in [Nm].
 DataRecorder addCommandedCartesianPositionXYZ(AbstractFrame measureFrame, AbstractFrame referenceFrame)
          Adds the the commanded Cartesian position of the specified frame.
 DataRecorder addCommandedJointPosition(Robot robot, DataRecorder.AngleUnit angleUnit)
          Adds the commanded positions of all joints of the robot.
 DataRecorder addCurrentCartesianPositionXYZ(AbstractFrame measureFrame, AbstractFrame referenceFrame)
          Adds the the current Cartesian position of the specified frame.
 DataRecorder addCurrentJointPosition(Robot robot, DataRecorder.AngleUnit angleUnit)
          Adds the current positions of all joints of the robot.
 DataRecorder addExternalJointTorque(Robot robot)
          Adds the external torques of all joints of the robot.
 DataRecorder addInternalJointTorque(Robot robot)
          Adds the internal torques of all joints of the robot.
 boolean awaitFileAvailable(long timeout, TimeUnit timeUnit)
          Blocks the calling thread until the recorded file is available or the timeout has elapsed.
 void enable()
          Enables the DataRecorder.
 Controller getController()
          Gets the controller where a DataRecorder was added.
 String getFileName()
          Gets the name of the data file.
 RecorderConfiguration getRecorderConfiguration()
          Gets the configuration of the data recorder.
 int getSampleInterval()
          Gets the sample interval of the recorded data in milliseconds.
 long getTimeoutMillisecs()
          Gets the timeout of the recorded data file in milliseconds.
 URL getURL()
          Gets the URL of the file where the data were recorded.
 boolean isEnabled()
          Gets the state of the DataRecorder.
 boolean isFileAvailable()
          Gets the status of the file where the data has been saved.
 boolean isRecording()
          Gets the state of the recording process.
 void run()
           
 void setFileName(String fileName)
          Sets the fileName where the recorded data will be saved.
 void setSampleInterval(int sampleInterval)
          Sets the sample interval.
 void setTimeout(long timeout, TimeUnit timeUnit)
          Sets the timeout of a given DataRecorder object.
 void startRecording()
          Starts recording data.
 void stopRecording()
          Stops recording data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataRecorder

public DataRecorder(String fileName,
                    long timeout,
                    TimeUnit timeUnit,
                    int sampleInterval)
Creates a new DataRecorder.

Parameters:
fileName - The name of the file to save the recording data. It only must contain the file name and not the path.
timeout - The time to record data. A negative value means that no timeout will be used and the recording process will be stopped when the file size reaches 16MB or 30000 datasets are gathered. A zero value is not possible.
timeUnit - The time unit of the timeout
sampleInterval - The sample interval in milliseconds to record data. The minimum value is 1 millisecond. Other values must be multiple of the minimum value. It must be non-negative.

DataRecorder

public DataRecorder()
Creates a default DataRecorder with default values.

The default values are:
fileName: DataRecorder[ID].log The ID will be generated at runtime.
timeout: -1 (No timeout. The recording will stop as soon as the buffer size of 16MB is reached or 30000 datasets are gathered.)
timeUnit: Milliseconds
SampleInterval: 1 millisecond

Method Detail

addCartesianForce

public DataRecorder addCartesianForce(AbstractFrame measureFrame,
                                      AbstractFrame orientationFrame)
Adds Cartesian forces (along axis x, y, z) in [N].

Parameters:
measureFrame - The frame where the force measurement will take place. This frame must be statically attached to a device which can measure forces (such as a LBR). null is not allowed.
orientationFrame - Optional frame that specifies the orientation where the force measurement will take place. As orientationFrame any frame for which a path from measureFrame can be calculated at runtime can be used; for example a frame connected to World. If orientationFrame is set to null, the orientation of measureFrame is used.
Returns:
DataRecorder object.

addCartesianTorque

public DataRecorder addCartesianTorque(AbstractFrame measureFrame,
                                       AbstractFrame orientationFrame)
Adds Cartesian torques (about axis x, y, z) in [Nm].

Parameters:
measureFrame - The frame where the torque measurement will take place. This frame must be statically attached to a device which can measure forces (such as a LBR). null is not allowed.
orientationFrame - Optional frame that specifies the orientation where the force measurement will take place. As orientationFrame any frame for which a path from measureFrame can be calculated at runtime can be used; for example a frame connected to World. If orientationFrame is set to null, the orientation of measureFrame is used.
Returns:
DataRecorder object.

addInternalJointTorque

public DataRecorder addInternalJointTorque(Robot robot)
Adds the internal torques of all joints of the robot.

Parameters:
robot - the robot whose internal joint torques are going to be added. null is not allowed.
Returns:
DataRecorder object.

addExternalJointTorque

public DataRecorder addExternalJointTorque(Robot robot)
Adds the external torques of all joints of the robot.

Parameters:
robot - the robot whose external joint torques are going to be added. null is not allowed.
Returns:
DataRecorder object.

addCurrentJointPosition

public DataRecorder addCurrentJointPosition(Robot robot,
                                            DataRecorder.AngleUnit angleUnit)
Adds the current positions of all joints of the robot.

Parameters:
robot - The robot whose current joint positions are going to be added. null is not allowed.
angleUnit - The angle unit of the recorded output (degree or radiant)
Returns:
DataRecorder object.

addCommandedJointPosition

public DataRecorder addCommandedJointPosition(Robot robot,
                                              DataRecorder.AngleUnit angleUnit)
Adds the commanded positions of all joints of the robot.

Parameters:
robot - The robot whose commanded joint positions are going to be added. null is not allowed
angleUnit - The angle unit of the recorded output (degree or radiant)
Returns:
DataRecorder object.

addCurrentCartesianPositionXYZ

public DataRecorder addCurrentCartesianPositionXYZ(AbstractFrame measureFrame,
                                                   AbstractFrame referenceFrame)
Adds the the current Cartesian position of the specified frame.

Parameters:
measureFrame - The frame below or equal to the flange of the robot where the measurement takes place. null is not allowed
referenceFrame - The positions are recorded in the coordinate system of this reference frame. null is not allowed.
Returns:
DataRecorder object.

addCommandedCartesianPositionXYZ

public DataRecorder addCommandedCartesianPositionXYZ(AbstractFrame measureFrame,
                                                     AbstractFrame referenceFrame)
Adds the the commanded Cartesian position of the specified frame.

Parameters:
measureFrame - The frame below or equal to the flange of the robot where the measurement takes place. null is not allowed
referenceFrame - The positions are recorded in the coordinate system of this reference frame. null is not allowed.
Returns:
DataRecorder object.

startRecording

public void startRecording()
Starts recording data.

The DataRecorder must be enabled in order to start the recording process. Enabled means that the data recorder is ready to start recording. A disable process occurs automatically when the data recorder stops. This means that the same DataRecorder must be enabled again in order to record data a second time.

See Also:
enable()

stopRecording

public void stopRecording()
Stops recording data.

A disable process occurs automatically when the DataRecorder stops. This means that the same DataRecorder must be enabled again in order to record data.

See Also:
enable(), startRecording()

isRecording

public boolean isRecording()
Gets the state of the recording process.

Returns:
True if the recording process is running, false otherwise.

getFileName

public String getFileName()
Gets the name of the data file. If the constructor of the DataRecorder was called with no parameters, the default file name will be known after the data recorder has been enabled.

Returns:
The name of the data file. Null if the DataRecorder has not been stopped.

getSampleInterval

public int getSampleInterval()
Gets the sample interval of the recorded data in milliseconds.

Returns:
The sample interval of the data file in milliseconds.

getTimeoutMillisecs

public long getTimeoutMillisecs()
Gets the timeout of the recorded data file in milliseconds. It describes the recording time of data. A negative value means that no timeout will be used.

Returns:
The timeout in milliseconds.

setTimeout

public void setTimeout(long timeout,
                       TimeUnit timeUnit)
Sets the timeout of a given DataRecorder object.

Parameters:
timeout - The time to record data. A negative value means that no timeout will be used and the recording process will be stopped when the file size reaches 16MB or 30000 datasets are gathered. A zero value is not possible.
timeUnit - The time unit of the timeout

setSampleInterval

public void setSampleInterval(int sampleInterval)
Sets the sample interval.

Parameters:
sampleInterval - The sample interval in milliseconds to record data. The minimum value is 1 millisecond. It must be non-negative.

setFileName

public void setFileName(String fileName)
Sets the fileName where the recorded data will be saved.

Parameters:
fileName - The name of the file to save the recording data. It only must contain the file name and not the path.

getController

public Controller getController()
Gets the controller where a DataRecorder was added.

Returns:
The controller.

getURL

public URL getURL()
Gets the URL of the file where the data were recorded.

If the data recording is invoked twice with the same file name the recording process overwrites the last file.

Returns:
The URL of the file where the data were recorded.
See Also:
isFileAvailable(), awaitFileAvailable(long, TimeUnit)

enable

public void enable()
Enables the DataRecorder.

It does not start the recording process. Enabled means that the DataRecorder is ready to start recording. A disable process occurs automatically when the DataRecorder stops. This means that the same DataRecorder must be enabled again in order to record data.

Note: Only one DataRecorder instance can be enabled at the same time.

See Also:
startRecording(), stopRecording()

isEnabled

public boolean isEnabled()
Gets the state of the DataRecorder.

Enabled means that the DataRecorder is ready to start recording. A disable process occurs automatically when the data recorder stops. This means that the same DataRecorder must be enabled again in order to record data.

Returns:
True if the DataRecorder is enabled, false otherwise.
See Also:
enable()

isFileAvailable

public boolean isFileAvailable()
Gets the status of the file where the data has been saved.

If the file is being written it is not available. If the data recording process is invoked twice with the same file name, the last file will be erased in the beginning of the recording process and therefore it will not be available.

Returns:
true if the file has been written and is ready to be read, false if the file is being written.

awaitFileAvailable

public boolean awaitFileAvailable(long timeout,
                                  TimeUnit timeUnit)
Blocks the calling thread until the recorded file is available or the timeout has elapsed.

If the file is already available when called, this method returns immediately.

Parameters:
timeout - The maximum time the calling thread is blocked. The execution of this method takes some milliseconds independently from the given timeout.
timeUnit - The unit of the timeout.
Returns:
true, if the recorded file becomes available during the configured timeout, false otherwise.
Even if the timeout is smaller than the execution time of this method, the condition state at the time of the method call will be returned.

run

public void run()
Specified by:
run in interface Runnable

getRecorderConfiguration

public RecorderConfiguration getRecorderConfiguration()
Gets the configuration of the data recorder.

Returns:
The RecorderConfiguration.
This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.


Copyright © 2019. All rights reserved.