bug: correctly use sistema_discr instead of sistema
sistema internally recalc's the input, while sistema_discr takes it as argument This saves a lot of time when simulating in discrete-time
parent
ec8b2dcecb
commit
dd8066f75c
|
@ -1,3 +1,3 @@
|
|||
function q = sistema(t, q)
|
||||
q = unicycle(t, q, control_act(t, q));
|
||||
function dq = sistema(t, q)
|
||||
dq = unicycle(t, q, control_act(t, q));
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function x = sistema_discr(t, q)
|
||||
function dq = sistema_discr(t, q)
|
||||
global u_discr
|
||||
q = unicycle(t, q, u_discr);
|
||||
dq = unicycle(t, q, u_discr);
|
||||
end
|
||||
|
|
|
@ -78,7 +78,7 @@ function [t, q, ref_t, U] = simulate_discr(tfin)
|
|||
tspan = [(n-1)*tc n*tc];
|
||||
z0 = q(end, :);
|
||||
|
||||
[v, z] = ode45(@sistema, tspan, z0);
|
||||
[v, z] = ode45(@sistema_discr, tspan, z0);
|
||||
|
||||
q = [q; z];
|
||||
t = [t; v];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
function dx = unicycle(t, x, u)
|
||||
function dq = unicycle(t, q, u)
|
||||
% u is (v;w)
|
||||
% x is (x; y; theta)
|
||||
theta = x(3);
|
||||
G_x = [cos(theta), 0; sin(theta), 0; 0, 1];
|
||||
dx = G_x*u;
|
||||
theta = q(3);
|
||||
G_q = [cos(theta), 0; sin(theta), 0; 0, 1];
|
||||
dq = G_q*u;
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue