thesis/set_trajectory.m

65 lines
1.6 KiB
Matlab
Raw Normal View History

function [ref, dref] = set_trajectory(i)
syms s
switch i
case 0
% a straigth line trajectory at v=0.5m/s
xref = 0.5*s;
yref = 0;
case 1
% a straigth line trajectory at v=10 m/s
xref = 10*s;
yref = 0;
case 2
2024-07-13 12:15:26 +02:00
% straight line, with initial error
xref = 5 + 0.5*s;
yref = 0;
case 3
% straight line, initial error, faster
xref = 5 + 10*s;
yref = 0;
case 4
xref = cos(s);
yref = sin(s);
2024-07-13 12:15:26 +02:00
case 5
2024-07-13 11:31:44 +02:00
xref = 15*cos(s);
yref = 15*sin(s);
2024-07-13 12:15:26 +02:00
case 6
2024-07-23 18:07:50 +02:00
xref = 0.4*s;
yref = cos(0.4*s);
%xref = 0.6*s;
%yref = cos(0.6*s);
2024-07-23 18:07:50 +02:00
case 7
xref = 5*cos(0.05*s);
yref = 5*sin(0.05*s);
case 8
xref = 0.5*s;
yref = 1;
case 9
xref = 0.9*s;
yref = 0.5*cos(0.65*s);
case 10
xref = cos(0.5*s);
yref = 0.5 * sin(s);
2024-07-28 12:58:36 +02:00
case 11
2024-07-29 15:22:49 +02:00
% cardioid
2024-07-28 12:58:36 +02:00
a = 0.5;
xref = 2*a*(1-cos(0.5*s))*sin(0.5*s);
2024-07-29 15:22:49 +02:00
%xref = 4*a*(0.2-cos(0.5*s))*sin(0.5*s);
2024-07-28 12:58:36 +02:00
yref = 2*a*(1-cos(0.5*s))*cos(0.5*s);
2024-07-29 15:22:49 +02:00
case 12
% square! in parametic form! https://math.stackexchange.com/questions/978486/parametric-form-of-square
%speed = 0.3;
speed = 0.18;
side = 2;
s_ = speed * s;
%xref = side * cos(s) / max(abs(cos(speed*s)), abs(sin(speed*s))) ;
%yref = side * sin(s) / max(abs(cos(speed*s)), abs(sin(speed+s))) ;
p = (sqrt(2) * (abs(sin(s_ + pi/4)) + abs(cos(s_ + pi/4))));
xref = side * cos(s_) / p;
yref = side * sin(s_) / p;
end
ref = [xref; yref];
dref = diff(ref, s);
end