|
| 1 | + |
| 2 | +% Read and plot data from human-robot collaboration |
| 3 | +% taskProMP{1}: task 1 |
| 4 | +% taskProMP{2}: task 2 |
| 5 | +% taskProMP{3}: task 3 |
| 6 | +% |
| 7 | +% Trajectories of both human and robot are time aligned. |
| 8 | +% Each column is one degree of freedom. |
| 9 | +% Each row is a time step. |
| 10 | +% data{1}(:,1:3) xyz coordinates of the human wrist recorded via optical |
| 11 | +% marker traking |
| 12 | +% data{1}(:,4:10) joint angles of the KUKA lightweight arm, starting from |
| 13 | +% base towards the end effector |
| 14 | +% data{1}(:,11:13) xyz coordinates of the robot end-effector |
| 15 | + |
| 16 | +function main() |
| 17 | + |
| 18 | + clear; clc; close all; |
| 19 | + dbstop if error; |
| 20 | + |
| 21 | + |
| 22 | + load('taskProMP.mat'); |
| 23 | + |
| 24 | + number_of_tasks = numel(taskProMP); |
| 25 | + |
| 26 | + for j=1:number_of_tasks |
| 27 | + plot_data(taskProMP{j}); |
| 28 | + end |
| 29 | + |
| 30 | + for j=1:number_of_tasks |
| 31 | + gen_csv(taskProMP{j}, j); |
| 32 | + end |
| 33 | + |
| 34 | +end |
| 35 | + |
| 36 | + |
| 37 | +function plot_data(data) |
| 38 | + h1 = figure; axis equal; grid on; hold on; |
| 39 | + xlabel 'x (m)'; |
| 40 | + ylabel 'y (m)'; |
| 41 | + zlabel 'z (m)'; |
| 42 | + view([-1 1 1]) |
| 43 | + title('Blue: Human wrist. Red: robot hand') |
| 44 | + |
| 45 | + number_of_training_data = numel(data); |
| 46 | + for k=1:number_of_training_data |
| 47 | + plot3(data{k}(:,1), data{k}(:,2), data{k}(:,3), 'b' ); |
| 48 | + plot3(data{k}(:,11), data{k}(:,12), data{k}(:,13), 'r' ); |
| 49 | + end |
| 50 | +end |
| 51 | + |
| 52 | +% created by Longxin to output the csv file that can be read by python |
| 53 | +function gen_csv(data, task_idx) |
| 54 | + number_of_training_data = numel(data); |
| 55 | + for k=1:number_of_training_data |
| 56 | + data_temp = [data{k}(:,1), data{k}(:,2), data{k}(:,3), data{k}(:,11), data{k}(:,12), data{k}(:,13)]; |
| 57 | + file_name = ['./csv_datasets/', 'task', num2str(task_idx), '_', num2str(k)]; |
| 58 | + csvwrite(file_name, data_temp); |
| 59 | + end |
| 60 | +end |
0 commit comments