webots自学笔记(九)弹簧与阻尼添加

        原创文章,来自博客园,_阿龙clliu http://www.cnblogs.com/clliu/,转载请注明原文章出处。         

        昨天一个网友问我webots如何加一个弹簧,说是要做柔性机器人。说道理在ADAMS里面加弹簧就加一个spring就好了(在用webots之前我用的ADAMS),可是webots里面好像没有spring这个节点,查了参考资料发现webots里面还是有的,只是webots将弹簧阻尼整合到servo里去了。

        我们先看看官方参考文献怎么说的:

   Springs and Dampers

      The springConstant field specifies the value of the spring constant (or spring stiffness), usually denoted as K. The springConstant must be positive or zero. If the springConstant is zero (the default), no spring torque/force will be applied to the servo. If the springConstant is greater than zero, then a spring force will be computed and applied to the servo in addition to the other forces (i.e., motor force, damping force). The spring force is calculated according to Hooke's law: F = -Kx, where K is the springConstant and x is the current servo position as represented by the position field. Therefore, the spring force is computed so as to be proportional to the current servo position, and to move the servo back to its initial position. When designing a robot model that uses springs, it is important to remember that the spring's resting position for each servo will correspond to the initial position of the servo.

      The dampingConstant field specifies the value of the servo damping constant. The value of dampingConstant must be positive or zero. If dampingConstant is zero (the default), no damping torque/force will be added to the servo. If dampingConstant is greater than zero, a damping torque/force will be applied to the servo in addition to the other forces (i.e., motor force, spring force). This damping torque/force is proportional to the effective servo velocity: F = -Bv, where B is the damping constant, and v = dx/dt is the effective servo velocity computed by the physics simulator.

     servo_mechanics.png

         简单的说,就是servo节点可以输出电机力、弹簧、阻尼,而我们一般来说要单独的一个弹簧力或者阻尼力。这个时候需要把电机力去掉,这个不能使用ODE里面常用的方法,将servo的type属性设置成none。因为弹簧力和阻尼的方向矢量是依赖servo的方向矢量的,所以我们可以将电机力设为0,及maxfirce属性设置为0。

         下面写一个例子,一个重物在弹簧下振荡的演示,这个例子应该是比较经典的。

       模型画的比较粗糙,大家见谅,中间还空了一部分,但这个振荡的效果是实现了。

       这个设置起来也不是很复杂,需要设置充当弹簧的那个电机设置type为线性(linear),伺服轴要做对,GIF中的黑色线。设置maxfirce = 0,springConstant > 0 就可以,这个springConstant 就是弹簧的劲度系数k。

 

      下面给出源文件,没看明白具体看文件里的设置吧。

      源文件下载

原文地址:https://www.cnblogs.com/clliu/p/7182242.html