|
3.36 ServoDerived from Solid.
3.36.1 DescriptionA Servo node is used to add one (active or passive) degree of freedom (DOF) in a mechanical simulation. The DOF is created between the parent and child nodes (VRML hierarchy) of the servo and therefore allows moving the servo children with respect to the servo parent. The Servo can be of type rotational or linear. A rotational servo is used to simulate a rotating motion, like most electric motors and hinges. A linear servo is used to simulate a sliding motion, like linear motors, pistons, hydraulic/pneumatic cylinders, springs, or dampers. Rotational servos units are expressed in radians while linear servos units are expressed in meters. See table 3.2:
Table 3.2: Servo Units 3.36.2 Field Summary
3.36.3 Initial Transformation and PositionThe Servo node inherits the translation and rotation fields from the Transform node. These two fields represent the coordinate system transformation between the Servo parent and children. When the Servo is actuated, the values of these fields are automatically modified in order to reflect the current transformation. In a "rotational" Servo, these fields have the following meaning: The translation field specifies the translation of the axis of rotation. The rotation field specifies the orientation of the axis of rotation. See figure 3.17. ![]() Figure 3.17: Rotational servo In a "linear" Servo, these fields have the following meaning: The translation field specifies the translation of the sliding axis. The rotation field specifies the orientation of the sliding axis. See figure 3.18. ![]() Figure 3.18: Linear servo The values of the translation and rotation fields specified in the .wbt file (before the simulation is run) define the initial transformation of the servo. In the initial transformation, the value of the position field is always zero. Then, target positions passed to wb_servo_set_position() are specified with respect to the initial zero-position. The values of the minPosition, maxPosition, minStop and maxStop fields are also defined with respect to the initial zero-position. 3.36.4 Position and Velocity ControlThe standard way of operating a Servo is to control the position directly (position control). The user specifies a target position using the wb_servo_set_position() function, then the P-controller takes into account the desired velocity, acceleration and motor force in order to move the servo to the target position. See table 3.3. In Webots, position control is carried out in three stages, as depicted in figure 3.19. The first stage is performed by the user-specified controller (1) that decides which position, velocity, acceleration and motor force must be used. The second stage is performed by the servo P-controller (2) that computes the current velocity of the servo Vc. Finally, the third stage (3) is carried out by the physics simulator (ODE joint motors). ![]() Figure 3.19: Servo control At each simulation step, the P-controller (2) recomputes the current velocity Vc according to following algorithm:
Instead of specifying a target position (position control), it is also possible to choose the servo velocity directly. In order to obtain a specific velocity, the user should set the desired velocity with wb_servo_set_velocity(), then call wb_servo_set_position() with WB_SERVO_INFINITY or -WB_SERVO_INFINITY as the parameter. This will initiate a continuous servo motion at the desired speed, while taking into account the specified acceleration and motor force.
Table 3.3: Servo Control Summary 3.36.5 Force ControlThe position/velocity control described above is performed by the Webots P-controller and ODE's joint motor implementation (see ODE documentation). As an alternative to this mechanism, Webots allows the user to directly specify the amount of torque/force that must be applied by a servo. This is achieved through the wb_servo_set_force() function. See below for a detailed description of this function. 3.36.6 Servo LimitsThe position field is a scalar value that represents the current servo "rotational" or "linear" position. For a rotational servo, position represents the difference (in radians) between the initial and the current angle of its rotation field. For a linear servo, position represents the distance (in meters) between the servo's initial and current translation (translation field). The minPosition and maxPosition fields define the soft limits of the servo. Soft limits specify the software boundaries beyond which the P-controller will not attempt to move. If the controller calls wb_servo_set_position() with a target position that exceeds the soft limits, the desired target position will be clipped in order to fit into the soft limit range. Since the initial position of the servo is always zero, minPosition must always be negative or zero, and maxPosition must always be positive or zero. When both minPosition and maxPosition are zero (the default), the soft limits are deactivated. Note that the soft limits can be overstepped when an external force which exceeds the motor force is applied to the servo. For example, it is possible that the weight of a robot exceeds the motor force that is required to hold it up. The minStop and maxStop fields define the hard limits of the servo. Hard limits represent physical (or mechanical) bounds that cannot be overrun by any force. Hard limits can be used, for example, to simulate both end caps of a hydraulic or pneumatic piston or to restrict the range of rotation of a hinge. The value of minStop must be in the range [-pi, 0] and maxStop must be in the range [0, pi]. When both minStop and maxStop are zero (the default), the hard limits are deactivated. The servo hard limits use ODE joint stops (for more information see the ODE documentation on dParamLoStop and dParamHiStop). Finally, note that when both soft and hard limits are activated, the range of the soft limits must be included in the range of the hard limits, such that minStop <= minValue and maxStop >= maxValue. 3.36.7 Springs and DampersThe springConstant field specifies the value of the spring constant (or spring stiffness), usually denoted as K. The springConstant must be positive or zero. If 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 (e.g. motor force, damping force, weight). The spring force is calculated according to Hooke's law: F = -K*x, 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 applied 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 (e.g. motor force, spring force, weight). This damping torque/force is proportional to the effective servo velocity: F = -B*v, where B is the damping constant, and v = dx/dt is the effective servo velocity computed by the physics simulator. When simulating spring and dampers it is usually necessary to turn off the motor force by calling wb_servo_set_motor_force(servo, 0), or by setting a zero default motor force in the maxForce field. 3.36.8 Force CombinationAltogether, three different forces can be applied to a servo: the motor force (set by the P-controller or by wb_servo_set_force()), the spring force and the damping force (see table 3.4). The forces are applied in parallel and can be switched on or off independently (by default the P-controller is on). At each simulation step the three forces are recomputed and added to the two bodies of each servo. In a "linear" servo the force vectors are aligned with the servo sliding axis and are applied to the servo parent and children with equal magnitude but in opposite directions. In a "rotational" servo, the torques are applied to the servo parent and children with equal magnitude but in opposite directions around the servo rotation axis.
Table 3.4: Servo Forces 3.36.9 Servo FunctionsNAMEwb_servo_set_position, wb_servo_set_velocity, wb_servo_set_acceleration, wb_servo_set_motor_force, wb_servo_set_control_p - change the parameters of the P-controllerC SYNOPSIS#include <webots/servo.h>void wb_servo_set_position(WbDeviceTag servo, double position); void wb_servo_set_velocity(WbDeviceTag servo, double vel); void wb_servo_set_acceleration(WbDeviceTag servo, double acc); void wb_servo_set_motor_force(WbDeviceTag servo, double force); void wb_servo_set_control_p(WbDeviceTag servo, double p); C++ SYNOPSIS#include <webots/Servo.hpp>void Servo::setPosition(double position); void Servo::setVelocity(double vel); void Servo::setAcceleration(double acc); void Servo::setMotorForce(double force); void Servo::setControlP(double p); JAVA SYNOPSISimport com.cyberbotics.webots.controller.Servo;void Servo.setPosition(double position); void Servo.setVelocity(double vel); void Servo.setAcceleration(double acc); void Servo.setMotorForce(double force); void Servo.setControlP(double p); PYTHON SYNOPSISfrom controller import Servonone Servo.setPosition(float position) none Servo.setVelocity(float vel) none Servo.setAcceleration(float acc) none Servo.setMotorForce(float force) none Servo.setControlP(float p) DESCRIPTIONThe wb_servo_set_position() function gives a new target position that the P-controller will attempt to reach using the current velocity, acceleration and motor torque/force parameters. The requested motion will be carried out, provided that it is not blocked by soft or hard limits and not impeded by external forces or the servo's own spring and damping forces. The special values WB_SERVO_INFINITY and -WB_SERVO_INFINITY can be passed as the second argument to the wb_servo_set_position() function in order to enable an endless rotational or linear motion. The current values for velocity, acceleration and motor torque/force are taken into account. The motion may be interrupted by a call to wb_servo_set_position() with a different argument or by a call to wb_servo_set_force(). With WB_SERVO_INFINITY or -WB_SERVO_INFINITY, a linear servo will initiate an endlessly increasing translation between its parent and child nodes. The wb_servo_set_velocity() function specifies the velocity that servo should reach while moving to the target position. In other words, this means that the servo will accelerate (using the specified acceleration, see below) until the target velocity is reached. The velocity argument passed to this function cannot exceed the limit specified in the maxVelocity field. The wb_servo_set_acceleration() function specifies the acceleration that the P-controller should use when trying to reach the specified velocity. Note that an infinite acceleration is obtained by passing -1 as the acc argument to this function. The wb_servo_set_motor_force() function specifies the max torque/force that will be available to the motor to carry out the requested motion. The motor torque/force specified with this function cannot exceed the value specified in the maxForce field. The wb_servo_set_control_p() function changes the value of the P parameter in the P-controller. P is a parameter used to compute the current servo velocity Vc from the current position Pc and target position Pt, such that Vc = P * (Pt - Pc). With a small P, a long time is needed to reach the target position, while too large a P can make the system unstable. The default value of P is specified by the controlP field of the corresponding Servo node. Note: In the oriented-object APIs, the WB_SERVO_INFINITY constant is available as static double of the Servo class (Servo::INFINITY). NAMEwb_servo_enable_position, wb_servo_disable_position, wb_servo_get_position - get the effective position of a servoC SYNOPSIS#include <webots/servo.h>void servo_enable_position(WbDeviceTag servo, int ms); void servo_disable_position(WbDeviceTag servo); double servo_get_position(WbDeviceTag servo); C++ SYNOPSIS#include <webots/Servo.hpp>void Servo::enablePosition(int ms); void Servo::disablePosition(); double Servo::getPosition(); JAVA SYNOPSISimport com.cyberbotics.webots.controller.Servo;void Servo.enablePosition(int ms); void Servo.disablePosition(); double Servo.getPosition(); PYTHON SYNOPSISfrom controller import Servonone Servo.enablePosition(int ms) none Servo.disablePosition() float Servo.getPosition() DESCRIPTIONThe wb_servo_enable_position() function activates position measurements for the specified servo. A new position measurement will be performed each ms milliseconds; the result must be obtained with the wb_servo_get_position() function. The returned value corresponds to the most recent measurement of the servo position. The wb_servo_get_position() function measures the effective position of the servo which, under the effect of external forces, is usually different from the target position specified with wb_servo_set_position(). For a rotational servo, the returned value is expressed in radians, for a linear servo, the value is expressed in meters. The returned value is valid only if the corresponding measurement was previously enabled with wb_servo_enable_position(). The wb_servo_disable_position() function deactivates position measurements for the specified servo. After a call to wb_servo_disable_position(), wb_servo_get_position() will return undefined values. NAMEwb_servo_enable_motor_force_feedback, wb_servo_get_motor_force_feedback, wb_servo_disable_motor_force_feedback - get the motor force currently used by a servoC SYNOPSIS#include <webots/servo.h>void wb_servo_enable_motor_force_feedback(WbDeviceTag servo, int ms); void wb_servo_disable_motor_force_feedback(WbDeviceTag servo); double wb_servo_get_motor_force_feedback(WbDeviceTag servo); C++ SYNOPSIS#include <webots/Servo.hpp>void Servo::enableMotorForceFeedback(int ms); void Servo::disableMotorForceFeedback(); double Servo::getMotorForceFeedback(); JAVA SYNOPSISimport com.cyberbotics.webots.controller.Servo;void Servo.enableMotorForceFeedback(int ms); void Servo.disableMotorForceFeedback(); double Servo.getMotorForceFeedback(); PYTHON SYNOPSISfrom controller import Servonone Servo.enableMotorForceFeedback(int ms) none Servo.disableMotorForceFeedback() float Servo.getMotorForceFeedback() DESCRIPTIONThe wb_servo_enable_motor_force_feedback() function activates torque/force feedback measurements for the specified servo. A new measurement will be performed each ms milliseconds; the result must be retrieved with the wb_servo_get_motor_force_feedback() function. The wb_servo_get_motor_force_feedback() function returns the most recent motor force measurement. This function measures the amount of motor force that is currently being used by the servo in order to achieve the desired motion or hold the current position. For a "rotational" servo, the returned value is a torque [N*m]; for a "linear" servo, the value is a force [N]. The returned value is an approximation computed by the physics engine, and therefore it may be inaccurate. The returned value normally does not exceed the available motor force specified with wb_servo_set_motor_force() (the default being the value of the maxForce field). Note that this function measures the current motor force exclusively, all other external or internal forces that may apply to the servo are ignored. In particular, wb_servo_get_motor_force_feedback() does not measure:
Note that this function applies only to physics-based simulation. Therefore, the physics and boundingObject fields of the Servo node must be defined for this function to work properly. If wb_servo_get_motor_force_feedback() was not previously enabled, the return value is undefined. NAMEwb_servo_set_force - direct force controlC SYNOPSIS#include <webots/servo.h>void wb_servo_set_force(WbDeviceTag servo, double force); C++ SYNOPSIS#include <webots/Servo.hpp>void Servo::setForce(double force); JAVA SYNOPSISimport com.cyberbotics.webots.controller.Servo;void Servo.setForce(double force); PYTHON SYNOPSISfrom controller import Servonone Servo.setForce(float force) DESCRIPTIONAs an alternative to the P-controller, the wb_servo_set_force() function allows the user to directly specify the amount of torque/force that must be applied by a servo. This function bypasses the P-controller and ODE joint motors; it adds the force to the physics simulation directly. This allows the user to design a custom controller, for example a PID controller. Note that when wb_servo_set_force() is invoked, this automatically resets the force previously added by the P-controller. In a "rotational" servo, the force parameter specifies the amount of torque that will be applied around the servo rotation axis. In a "linear" servo, the parameter specifies the amount of force [N] that will be applied along the sliding axis. A positive torque/force will move the bodies in the positive direction, which corresponds to the direction of the servo when the position field increases. When invoking wb_servo_set_force(), the specified force parameter cannot exceed the current motor force of the servo (specified with wb_servo_set_motor_force() and defaulting to the value of the maxForce field). Note that this function applies only to physics-based simulation. Therefore, the physics and boundingObject fields of the Servo node must be defined for this function to work properly. It is also possible, for example, to use this function to implement springs or dampers with controllable properties. The example in projects/samples/howto/worlds/force_control.wbt demonstrates the usage of wb_servo_set_force() for creating a simple spring and damper system. ![]() ^ page top ^ |
| E-mail to webmaster | Last updated: | Copyright © 2008 Cyberbotics Ltd. |