Hello,

I’m still kinda stuck on my CVX problem. What I wanna do is to optimize the trajectory given two main constraints (1 ensure spacing between each two points with respect to time and velocity, and 2nd ensure that the UAV has enough time to come back home). All the aforementioned, I was able to do, however, now that I wanna maximize/minimize acceleration at certain parts of the trajectory, hence from there I get the new value of velocity and based on which, I again do the same trajectory optimization problem. I’ve tried playing around with the code, but I keep getting Disciplined Convex Programming Error. Also, I’ve tried making all my variables non complex and just vectors of 2 dimensions, but it’s not working. Like you said before, I defined acceleration as an expression but still I seem to be getting some sort of CVX error.

Here’s my code with some comments to know what Im doing exactly

x0 = 100 + 200*1j;*

xB = 0;

xH = 100 -2001j;

p = 1;

for T = 111

cvx_begin quiet

variable x(T) complex

variable V(T) complex

expression a(T) complex

minimize(norm(x-xB)) %main cvx optimization

%Here I wanna define what V is before I put it in the constraints

for t = 1:T

if ((xB-x0)/2) - x(t) <= 0

cvx_begin quiet

variable x(T) complex

variable V(T) complex

expression a(T) complex %I guess expressions can’t be complex

V = (x(T)-x(T-1))/(T-(T-1));

a = (V(t)-V(t-1))/(t-(t-1));

maximize(a) %a>0

subject to

(x(T)-x(T-1))/(T-(T-1)) <= 5; %e.g.V<5

cvx_end

V = int(a,t); %from the maximization problem get me the new value for V

end

end

%Now I have V, hence I can apply my constraints to the main trajectory optimization problem

subject to

norm(x(1) - x0) <= V;

for t = 2:T

norm(x(t)-x(t-1)) <= V; %ensures correct spacing

norm(x(t) - xH) <= V*(T-t); %ensures enough time to get back home

%V = (x(T)-x(T-1))/(T-(T-1));

%a = (V(t)-V(t-1))/(t-(t-1));

end

```
cvx_end %End the main CVX optimization problem
Path(p).X = x;
p = p + 1;
plot(x,'.r','MarkerSize',16)
axis equal
axis([0 200 -200 200])
a = zeros(T);
```

end

I would really appreciate any kind of help with the code itself