如何在OpenModelica中的等式部分中限定值?

发布于 2025-01-24 03:10:52 字数 433 浏览 0 评论 0原文

我正在OpenModelica开发无人机模拟。在方程式块中,我正在计算速度和位置向量,但我想将速度限制为一定值。这是我的无人机块的简化示例。

block drone

 parameter Real mass =  0.985;
 constant Real g = 9.8;
 constant Real maxSpeed = 15.0;

 Input Real Fx,Fy,Fz;

 Real x,y,z;
 Real vX,vY,vZ;

equation
 der(vX) = Fx / mass;
 der(vY) = Fy / mass;
 der(vZ) = Fz / (mass*g);

 der(x) = vX;
 der(y) = vY;
 der(z) = vZ;

end drone;

编辑: 示例中的速度向量仅在无人机的速度超过Maxspeed值时才限制

I'm developing a drone simulation in OpenModelica. In an equation block I am calculating velocity and position vectors, but I want to cap the velocity to a certain value. This is a simplified example of my drone block.

block drone

 parameter Real mass =  0.985;
 constant Real g = 9.8;
 constant Real maxSpeed = 15.0;

 Input Real Fx,Fy,Fz;

 Real x,y,z;
 Real vX,vY,vZ;

equation
 der(vX) = Fx / mass;
 der(vY) = Fy / mass;
 der(vZ) = Fz / (mass*g);

 der(x) = vX;
 der(y) = vY;
 der(z) = vZ;

end drone;

EDIT:
The velocity vector in the example have to be capped only if the speed of the drone exceed the maxSpeed value

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雄赳赳气昂昂 2025-01-31 03:10:52

由于您在力量f之间的物理上正确关系,加速> der(v),speed v和位置x,我不会在那里改变任何东西。

您可以考虑类似的事情:

der(vZ) = if vZ >-1 then Fz / (mass*g) else 0;

这应该导致类似:

但我认为最好添加某种摩擦模型,这可能是:

 der(vZ) = (Fz-vZ*3) / (mass*g);

使用3是线性摩擦的系数(选择获得一个不错的图)。请注意,以上是非常基本的,应该进行一些完善 - 目的只是为了提出一个想法。
结果:

As you have physically correct relations between force F, acceleration der(v), speed v and positions x, I wouldn't change anything there.

You could think about something like:

der(vZ) = if vZ >-1 then Fz / (mass*g) else 0;

which should result in something like:
Velocity-limit

But I think it would be better to add some kind of friction model, which could be something like:

 der(vZ) = (Fz-vZ*3) / (mass*g);

with 3 being a coefficient for linear friction (chosen to get a nice plot). Note that the above is very rudimentary and should be refined quite a bit - the intention is just to give an idea.
The result:
Friction

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文