motionfiles
4 minute read
The motionfiles folder holds recorded trajectories. The motion player reads them and replays them on the machine, one file per motion.
└── motionfiles
├── 00_ExampleFile.csv
└── 01_ExampleFile.csv
The folder is named by the MotionPlayer block in config.json, and the feature is off until you enable it there:
"MotionPlayer": {
"Enable": false,
"Path": "motionfiles",
"Linking": "linking/motion-player.link.json"
}
How the motion player works
The player loads every file of the folder into memory. You pick one by its number, and while it plays, its output follows the file row by row. A link file passes the output on to the machine. Click a part to go to its section.
In the standard robot configuration, motion-player.link.json links root/MotionPlayer/output to root/MachineControl/hostInJointPosition1, so the player drives the machine control axes.
File names
A file name starts with its ID, a number, followed by an underscore: 00_ExampleFile.csv has ID 0, 12_Pick.csv has ID 12. Only files ending in .csv are read. The player skips, with a message in the log:
- a file with another extension,
- a file whose name does not start with a number and an underscore,
- a second file with an ID that is already taken.
File format
Despite the .csv extension, the columns are separated by spaces, not commas. A file has a loop line, a comment line naming the columns, and one row per sample:
loop = 0
# Time Axis1 Axis2 Axis3 Axis4 Axis5 Axis6
0 0.000113638411942 5.6819205971163E-05 -0.000106073529199 0.00113638411942 0.000568192059712 -0.00106073529199
0.01 0.000113638411942 5.6819205971163E-05 -0.000106073529199 0.00113638411942 0.000568192059712 -0.00106073529199
0.02 0.000113638411942 5.6819205971163E-05 -0.000106073529199 0.00113638411942 0.000568192059712 -0.00106073529199
| Line | What it does | Default |
|---|---|---|
loop = 0 |
0 plays the file once and stops. Any other number starts it again from the beginning when it ends |
0 |
# … |
A comment: the line is skipped | |
| Rows | The time in seconds, then one value for each output element, so output[0] is the second column. Up to 50 values per row |
The time starts at 0 and must go up. The rows do not have to be evenly spaced: the player takes the first row whose time is at or after its own time, so the output steps from row to row without interpolating. The two shipped example files step time in 0.01 s increments over 30.28 s, which is 3 029 samples at 100 Hz. Exponent notation (5.68E-05) is accepted.
Control the player
The player’s parameters are under root/MotionPlayer/:
| Parameter | What it does | Default |
|---|---|---|
profileID |
The ID of the file to play | 0 |
command |
Write 1 to play, 2 to pause, 3 to stop, 4 to reload the files from the folder |
|
timeScaleFactor |
The playback speed: 0.5 plays at half speed, 2 at double speed |
1.0 |
state |
0 stopped, 1 playing, 2 paused, 3 finished, 4 and 5 reloading |
|
error |
0 no error, 1 no file selected, 2 no file with the selected ID |
|
activeProfileID |
The ID of the file that is selected now | |
activeProfileTimestamp |
The time of the row on the output | |
activeProfileEndTime |
The time of the file’s last row | |
fractionComplete |
How far the file has played, from 0 to 1 |
|
numberOfProfiles |
How many files were loaded |
A new profileID takes effect when the player is stopped or at the end of a file. Set the next ID while one plays, and the player switches to it when the current file ends. It plays the new file straight away only if that file’s loop is not 0; otherwise it stops at the new file’s first row and waits for the next play command.
To add or change a file on a running controller, copy it into the folder and write 4 to command.
Warning
The output is never empty. While the player is stopped it holds the first row of the selected file, and while it plays it commands the machine through every row. Check the first row and the whole trajectory against your axis limits before you enable the motion player.