This repository has been archived by the owner on Aug 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDataRecorderExample.java
42 lines (36 loc) · 1.64 KB
/
DataRecorderExample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
public class DataRecorderExample extends RoboticsAPIApplication {
private static DataRecorder createDataRecorder() {
// set fname
final String fmt = "yyyy-MM-dd_HH-mm-ss";
final String timestamp = new SimpleDateFormat(fmt).format(new Date());
final String fname = String.format("%s.log", timestamp);
// recorder intrinsic settings
final long timeout = 30; // s
final int sampleRate = 1; // ms
// data recorder builder
DataRecorder recorder = new DataRecorder(fname, timeout, TimeUnit.SECONDS, sampleRate) //
.addInternalJointTorque(lbr) //
.addExternalJointTorque(lbr) //
.addCartesianForce(lbr.getFlange(), null) //
.addCartesianTorque(lbr.getFlange(), null) //
.addCommandedJointPosition(lbr, AngleUnit.Degree) //
.addCurrentJointPosition(lbr, AngleUnit.Degree) //
.addCommandedCartesianPositionXYZ(tool.getDefaultMotionFrame(), lbr.getRootFrame()) //
.addCurrentCartesianPositionXYZ(tool.getDefaultMotionFrame(), lbr.getRootFrame());
recorder.enable();
return recorder;
}
public void run() {
// create recorder object
final DataRecorder recorder = initDataRecorder();
recorder.startRecording();
/**
* DO STUFF
*/
// fetch data from recorder
recorder.stopRecording();
recorder.awaitFileAvailable(3, TimeUnit.SECONDS);
// get log filename for logging, message queues, etc.
getLogger().info("Logged data filename: " + recorder.getFileName());
}
}