how to solve a simplified 2D trajectory problem with defined points and derivatives

6 views (last 30 days)
Hello,
how could i solve this.
Two Points are given, also the velocity and the direction
What is the simplest trajectory which satisfy these boundaries?
Are an analytic solution possible?
x1 = 1000;
y1 = 1000;
v1 = 100;
phi1 = 45/180*pi;
x2 = 3000;
y2 = 2000;
v2 = 150;
phi2 = 0/180*pi;
I had an idea splitting these problem in two 1D problems and force the time to be identical.
But i'm still missing one condition..
I used a linear variation of accerlation in both directions.
v_x = (a_2_x-a_1_x)/T*t^2/2 +a_1_x*t +v1*cos(phi1);
s_x = (a_2_x-a_1_x)/T*t^3/6 +a_1_x*t^2/2 +v1*cos(phi1)*t+x1;
v_y = (a_2_y-a_1_y)/T*t^2/2 +a_1_y*t +v1*sin(phi1);
s_y = (a_2_y-a_1_y)/T*t^3/6 +a_1_y*t^2/2 +v1*sin(phi1)*t+y1;
When setup the B.C.:
v1*cos(phi2)= (a_2_x-a_1_x)*T/2 +a_1_x*T +v1*cos(phi1);
x2 = (a_2_x-a_1_x)*T^2/6 +a_1_x*T^2/2 +v1*cos(phi1)*T+x1;
v1*sin(phi2)= (a_2_y-a_1_y)*T/2 +a_1_y*T +v1*sin(phi1);
y2 = (a_2_y-a_1_y)*T^2/6 +a_1_y*T^2/2 +v1*sin(phi1)*T+y1;
There are 5 unknowns but only four equations:
a_1_x
a_2_x
a_1_y
a_2_y
T
Is the problem as BVP solveable?

Accepted Answer

John D'Errico
John D'Errico on 9 Nov 2023
Edited: John D'Errico on 9 Nov 2023
I think what you are missing is the time required to perform this movement between points.
You have specified the start locations, and the end locations. As well, a start velocity (in a specified direction) and the end point velocity, and a direction for that.
The problem is, we don't know how long it will take to move between the two locations. I might set it up like this:
syms x(t) y(t)
dy = diff(y);
dx = diff(x);
ddy = diff(dy);
ddx = diff(dx);
syms ax0 ax1 ay0 ay1 % parameters of the unknown linear acceleration profile in x and y.
% The equations of motion are simple
Ex = ddx == ax0 + ax1*t;
Ey = ddy == ay0 + ay1*t;
xy0 = [1000 1000];
xyT = [3000 2000];
vel0 = 100*[cosd(45), sind(45)]; % using degrees, since that is how you have the directions
velT = 150*[cosd(0), sind(0)];
We have everything set up now, but we don't know how long it will take to move between the two locations. And that is the problem, as the acceleration profile needed will depend on that final time.
First, I'll write the initial value problem.
xytraject = dsolve(Ex,Ey,x(0) == xy0(1),y(0) == xy0(2),dx(0) == vel0(1),dy(0) == vel0(2))
xytraject = struct with fields:
y: (ay1*t^3)/6 + (ay0*t^2)/2 + 50*2^(1/2)*t + 1000 x: (ax1*t^3)/6 + (ax0*t^2)/2 + 50*2^(1/2)*t + 1000
Again, I don't know the acceleration parameters, at least not yet. But the issue is, we cannot decide them, UNTIL we know the time at which the particle is supposed to end up at that point. For example, suppose we knew the final time is 20 units? Or 10 units of time? Or 100? Each of those choices would impact the trajectory. Now I'll put in the end point.
syms Tfinal
ExT = subs(xytraject.x,Tfinal) == xyT(1)
ExT = 
EyT = subs(xytraject.y,Tfinal) == xyT(2);
VxT = subs(diff(xytraject.x,t),Tfinal)==velT(1);
VyT = subs(diff(xytraject.y,t),Tfinal)==velT(2);
accelprofile = solve([ExT,EyT,VxT,VyT],[ax0 ax1 ay0 ay1])
accelprofile = struct with fields:
ax0: -(100*(3*Tfinal + 2*2^(1/2)*Tfinal - 120))/Tfinal^2 ax1: (300*(3*Tfinal + 2^(1/2)*Tfinal - 80))/Tfinal^3 ay0: -(200*(2^(1/2)*Tfinal - 30))/Tfinal^2 ay1: (300*(2^(1/2)*Tfinal - 40))/Tfinal^3
That is the necessary acceleration profile, assuming the acceleration MUST be linear over the time from 0 to Tfinal. Now we can choose some time, and see what happens.
accel20 = subs(accelprofile,Tfinal,20)
accel20 = struct with fields:
ax0: 15 - 10*2^(1/2) ax1: (3*2^(1/2))/4 - 3/4 ay0: 15 - 10*2^(1/2) ay1: (3*2^(1/2))/4 - 3/2
So that describes the acceleration trajectory necessary, assuming a purely linear acceleration between points. Plug it back into the trajectory we established...
xytraject20 = subs(xytraject,accel20)
xytraject20 = struct with fields:
y: 50*2^(1/2)*t + (t^3*((3*2^(1/2))/4 - 3/2))/6 - (t^2*(10*2^(1/2) - 15))/2 + 1000 x: 50*2^(1/2)*t + (t^3*((3*2^(1/2))/4 - 3/4))/6 - (t^2*(10*2^(1/2) - 15))/2 + 1000
fplot(xytraject20.x,xytraject20.y,[0,20],'b')
hold on
plot([xy0(1),xyT(1)],[xy0(2),xyT(2)],'rx')
grid on
As you can see, the result is a smooth curve between the two locations. Had I chosen some different time, I would have a totally different trajectory.
accel30 = subs(accelprofile,Tfinal,30);
xytraject30 = subs(xytraject,accel30)
xytraject50 = struct with fields:
y: 50*2^(1/2)*t + (t^3*(2^(1/2)/3 - 4/9))/6 - (t^2*((20*2^(1/2))/3 - 20/3))/2 + 1000 x: 50*2^(1/2)*t + (t^3*(2^(1/2)/3 + 1/9))/6 - (t^2*((20*2^(1/2))/3 - 10/3))/2 + 1000
fplot(xytraject30.x,xytraject30.y,[0,30],'g')
With a little thought, I could have made all of this into a function, where you need do nothing more than pass it the final time.
Your final question was what is the "simplest" trajectory that can be achieved. For that, I think you need to define the word simplest, as without mathematical definition the question has no meaning. It might be the flattest possible trajectory, or something like that. Now we might decide to solve for the final time needed that minimizes an integral of the squared second derivative of those trajectories, or something like that.
  3 Comments
John D'Errico
John D'Errico on 9 Nov 2023
Then I would be looking at various times, seeing what acceleration profiles they imply. Often I feel a plot is a huge benefit. Plot many such trajectories associated with different times of flight. Get to the point where you understand what is happening, then decide what the next step would be.

Sign in to comment.

More Answers (0)

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!