Skip to content

Instantly share code, notes, and snippets.

@mauricefallon
Created July 8, 2020 14:07
Show Gist options
  • Select an option

  • Save mauricefallon/f21037fe1bb37374dfecc91522249ceb to your computer and use it in GitHub Desktop.

Select an option

Save mauricefallon/f21037fe1bb37374dfecc91522249ceb to your computer and use it in GitHub Desktop.
close all
clear all
path ='/home/mfallon/logs/newer/01_short_experiment/ground_truth/';
r = importdata([path 'registered_poses.csv']);
s = importdata([path 'registered_poses_xyz_smoothed.csv']);
r = r.data;
s = s.data;
rt = r(:,1) + r(:,2)*1e-9;
rt = rt - rt(1);
st = s(:,1) + s(:,2)*1e-9;
st = st - st(1);
% dimension selector:
x=3
y=4
z=5
figure;
hold on
plot(r(:,x),r(:,y))
axis equal
% % long
% [a,idx] = min(abs(rt - 463.28));
% plot(r(idx,x),r(idx,y),'.r')
% [a,idx] = min(abs(rt - 597.38));
% plot(r(idx,x),r(idx,y),'.r')
% [a,idx] = min(abs(rt - 731.3));
% plot(r(idx,x),r(idx,y),'.r')
% [a,idx] = min(abs(rt - 858.4));
% plot(r(idx,x),r(idx,y),'.r')
% short
[a,idx] = min(abs(rt - 127.4));
plot(r(idx,x),r(idx,y),'.r')
[a,idx] = min(abs(rt - 758.8));
plot(r(idx,x),r(idx,y),'.r')
[a,idx] = min(abs(rt - 1074));
plot(r(idx,x),r(idx,y),'.r')
[a,idx] = min(abs(rt - 1454));
plot(r(idx,x),r(idx,y),'.r')
% tool to rotate the trajectory
if (1==0)
[th,rr] = cart2pol( r(:,x), r(:,y));
th =th+1.29;
[r(:,x), r(:,y)] = pol2cart( th, rr);
[th,rr] = cart2pol( s(:,x), s(:,y));
th =th+1.29;
[s(:,x), s(:,y)] = pol2cart( th, rr);
sec hg g
hold on
plot(r(:,x),r(:,y),'.k')
end
%
figure;
d=x;subplot(3,1,1);hold on; plot(rt, r(:,d)); plot(st, s(:,d),'.r');ylabel('x')
d=y;subplot(3,1,2);hold on; plot(rt, r(:,d)); plot(st, s(:,d),'.r');ylabel('y')
d=z;subplot(3,1,3);hold on; plot(rt, r(:,d)); plot(st, s(:,d),'.r');ylabel(' z')
xlabel('time [sec]')
delta = [vecnorm(diff(r(:,[3,4,5])),2,2)];
velocity= delta./diff(rt);
velocity_median = movmedian(velocity,40);
figure;
subplot(2,1,1); plot(rt(2:end),delta); xlabel('sec'); ylabel('delta in m')
subplot(2,1,2); plot(rt(2:end),velocity); xlabel('sec'); ylabel('velocity in m/sec')
hold on; plot(rt(2:end),velocity_median,'r');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment