how to solve a simplified 2D trajectory problem with defined points and derivatives
4 ビュー (過去 30 日間)
古いコメントを表示
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?
0 件のコメント
採用された回答
John D'Errico
2023 年 11 月 9 日
編集済み: John D'Errico
2023 年 11 月 9 日
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))
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)
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])
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)
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)
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)
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 件のコメント
John D'Errico
2023 年 11 月 9 日
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.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!