如何在OpenModelica中的等式部分中限定值?
我正在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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您在力量
f
之间的物理上正确关系,加速> der(v),speedv
和位置x
,我不会在那里改变任何东西。您可以考虑类似的事情:
这应该导致类似:
,
但我认为最好添加某种摩擦模型,这可能是:
使用
3
是线性摩擦的系数(选择获得一个不错的图)。请注意,以上是非常基本的,应该进行一些完善 - 目的只是为了提出一个想法。结果:
As you have physically correct relations between force
F
, accelerationder(v)
, speedv
and positionsx
, I wouldn't change anything there.You could think about something like:
which should result in something like:
But I think it would be better to add some kind of friction model, which could be something like:
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: