HOWTO make the simulation better

http://ode.org/wiki/index.php/HOWTO_make_the_simulation_better


Integrator accuracy and stability

  1. integrator will not give exact solution
  2. what is stabilty
  3. integrator types (exp & imp, order)
  4. tradeoff between accuracy, stability and work

Behavior may depend on step size

  1. smaller step = more accurate, more stable
  2. 10 * 0.1 not the same as 5*0.2
  3. tweak at final frame rate

Making things go faster

What factors does execution speed depend on? Each joint removes a number of degrees of freedom (DOFs) from the system. For example the ball and socket removes three, and the hinge removes five. For each separate group of bodies connected by joints, where:

  1. m1 is the number of joints in the group,
  2. m2 is the total number of DOFs removed by those joints, and
  3. n is the number of bodies in the group, then the computing time per step for the group is proportional to:
    k1 O(m1) + k2 O(m23) + k2 O(n)

ODE currently relies on factorization of a “system” matrix that has one row/column for each DOF removed (this is where the O(m23) comes from). In a 10 body chain that uses ball and socket joints, roughly 30-40% of the time is spent filling in this matrix, and 30-40% of the time is spent factorizing it.

Thus, to speed up your simulation you might consider:

  1. Using less joints - often small bodies and their associated joints can be replaced by purely kinematic “fakes” without harming physical realism.
  2. Replacing multiple joints with simpler alternatives. This will become easier as more specialized joint types are defined.
  3. Using less contacts.
  4. Preferring frictionless or viscous friction contacts (that remove one DOF) over Coulomb friction contacts (that remove three DOFs) where possible. In the future ODE will implement techniques that scale better with the number of joints.

Making things stable

  1. stiff springs / stiff forces are bad.
  2. hard constraints are good.
  3. dependence on integration timestep.
  4. Use powered joint, joint limits, built-in springs as much as possible, avoid explicit forces.
  5. if bodies move faster than is reasonable for the timestep
  6. inertias with long axes
  7. mass ratios - e.g. a whip. Joints that connect large and small masses together will have a harder time keeping their error low.
  8. object size ratios. If a sphere of size 1 has to roll over a polygon a 1000 units long, you might start to see the ball jitter slightly, or in some cases even start to suddenly bounce while it was lying still on the ground. This can easily be solved by subdividing the polygon into several smaller polygons.
  9. Increasing the global CFM will make the system more numerically robust and less susceptible to stability problems. It will also make the system look more “spongy”, so a tradeoff has to be found.
  10. Redundant constraints (two or more constraints that “try and do the same job”) will fight each other and cause stability problems. The numerical cause of this problem is singularity in the system matrix. One example of this is if two contacts joints connect the same pair of bodies at the same point. Another example is if a virtual hinge joint is created between two bodies by connecting them with two ball joints, spaced apart along the hinge axis (this is bad because the two ball joints try to remove six degrees of freedom from the system, but a real hinge joint would only remove five). Redundant constraints fight each other and generate strange forces in the system that can swamp the normal forces. For example, an affected body might fly around as though it has a life of its own, with complete disregard for gravity.

Using constraint force mixing (CFM)

  1. allow singular configurations
  2. effects: jitter or strange forces due to error amplification, LCP solver may go slow
  3. allow compliant joints (this may be unwanted also)

Avoiding singularities

  1. Singularity occurs when there are more joints than needed to constrain the bodies motions.
  2. Multiple (incompatible) joints between bodies, esp joint + contact (don’t collide objects that are joined together).
  3. increasing CFM
  4. unintentional - box chain on floor, other assemblies
  5. use minimum joints for correct behavior. use correct joints for desired behavior
  6. adding global CFM usually helps

Other stuff

  1. contact jitter when pushed out too far - soln: use softness
  2. keep lengths and masses around 1
  3. LCP solver takes a variable number of iterations (only non-deterministic part). if it takes too long, increase global CFM, prevent multiple contacts (or similar), and limit high ratio of force magnitudes (tree grabbing problem)
  4. hinge limits outside +/- pi
Verilog是一种硬件描述语言(HDL),用于模拟数字电路。在Verilog中,`always`块是用来描述组合逻辑和时序逻辑的主要方式。模拟`always`块通常涉及编写代码来模拟电路的行为,以验证其功能是否符合预期。 在模拟`always`块时,通常需要考虑几个关键点: 1. 时钟信号:在模拟时序逻辑时,通常会用一个`always`块来描述在时钟信号的上升沿或下降沿时应该发生什么。例如,在时钟的上升沿触发时,可以模拟触发器的行为。 2. 敏感列表:在非阻塞赋值(<=)的情况下,`always`块需要有一个敏感列表,这个列表列出了应该触发块执行的信号。敏感列表可以是边沿敏感的(例如,`@(posedge clk)`表示只有在`clk`的正边沿时才触发)或者电平敏感的(例如,`@(clk or reset)`表示在`clk`或`reset`信号变化时触发)。 3. 阻塞与非阻塞赋值:在`always`块内部,赋值可以是阻塞的(`=`)或非阻塞的(`<=`)。在描述时序逻辑时推荐使用非阻塞赋值,而在描述组合逻辑时使用阻塞赋值。 下面是一个简单的例子,演示了一个在时钟上升沿触发的`always`块,用于模拟一个D触发器: ```verilog module d_ff( input wire clk, // 时钟信号 input wire d, // 数据输入 output reg q // 输出 ); // 在时钟的上升沿触发always块,模拟D触发器的行为 always @(posedge clk) begin q <= d; // 使用非阻塞赋值 end endmodule ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值