Velocity Control in Practice: cmd_vel to Wheel Commands
Publishing cmd_vel is not controlling a robot — understanding the inner velocity control loop is what separates integration from mastery.
🎯 By the end you'll understand
Why cmd_vel is a velocity request, not a motor command, and what must happen inside the robot before that request becomes motion. The first-order lag model of a real motor and why it means your commanded velocity is never instantly achieved. How ros2_control's diff_drive_controller converts Twist messages to per-wheel velocity targets. Where steady-state error comes from in a P-only controller and why feed-forward from the kinematic model reduces it. And why a robot without inner-loop velocity control is torque-controlled — and therefore sensitive to load, battery voltage, and terrain.
KEY INSIGHTcmd_vel is a request to the inner loop, not a motor command
Publishing geometry_msgs/Twist on /cmd_vel is the equivalent of telling a driver "go 60 km/h." The driver still has to find the right throttle, compensate for the hill, and hold the speed steady. The motor controller is that driver. Skip the driver and you are holding a throttle, not commanding velocity.
Most ROS 2 tutorials show you how to publish a Twist message and watch the robot move. That works in simulation because Gazebo's differential-drive plugin implements the inner loop for you — it reads the commanded velocity, models motor dynamics, and applies appropriate torques. On a real robot, none of that is automatic. There must be a hardware-interfacing node — usually ros2_control with a diff_drive_controller — that receives your velocity command, compares it to the measured wheel velocities, runs a feedback controller, and outputs a PWM or torque command to the motor driver. Understanding this chain is the difference between being a ROS 2 integrator and a robotics engineer.
FollowBot runs two nested control loops. The outer loop — the DWA planner sending cmd_vel — operates at 10–20 Hz. It does geometry: given the robot's current pose and the target, what overall (v, ω) body velocity should the robot achieve? The inner loop — the diff_drive_controller inside ros2_control — operates at 50–200 Hz. It does physics: given the commanded wheel velocity and the encoder-measured actual velocity, what voltage drives the motor to close the gap? The outer loop treats velocity as a knob. The inner loop makes that knob real. If the inner loop is absent, slow, or poorly tuned, the outer loop is computing geometry on a robot that doesn't track velocity — and all the kinematic math from Lessons 2.1–2.5 breaks down.
CORE CONCEPTThe inner velocity control loop: why it exists
A brushless DC motor does not have a built-in velocity governor. Apply 12 V to the terminals and you get torque — specifically, a torque proportional to current, which is set by back-EMF minus applied voltage divided by winding resistance. What the motor actually does with that torque depends on load: the robot's mass, friction, terrain slope, and whether the person it's following just made it turn sharply. Without a feedback controller measuring and regulating velocity, the motor's response to a constant voltage command varies with every one of these factors.
The inner-loop velocity controller closes this gap. It reads wheel velocity from the encoder (typically a quadrature encoder giving 500–4000 ticks per revolution), computes the error between the commanded and measured velocity, and adjusts the PWM duty cycle to the motor driver accordingly. The loop runs at hardware speed — often 100–200 Hz on a dedicated microcontroller, or 50–100 Hz in software on a Jetson or NUC if the OS scheduler allows it.
The kinematic inverse model in the diagram is the bridge between Lesson 2.1 and this lesson. From Lesson 2.1, recall:
# Differential-drive inverse kinematics # v = forward body velocity [m/s] # w = angular velocity [rad/s] (positive = turn left) # b = wheel baseline (axle length) [m] # r = wheel radius [m] # Returns: left and right wheel angular velocities [rad/s] def diff_drive_ik(v: float, w: float, b: float, r: float): v_L = (v - w * b / 2.0) / r # left wheel [rad/s] v_R = (v + w * b / 2.0) / r # right wheel [rad/s] return v_L, v_R
These wheel targets are what the inner-loop PID controller tracks. The motor doesn't see v or ω — it sees ω_L and ω_R, each individually controlled.
HOW IT WORKSFirst-order motor lag: the physics the inner loop fights
A brushless DC motor with a 3-phase ESC does not jump instantly from 0 to its commanded velocity. The mechanical plant — motor inertia, wheel inertia, drivetrain friction — introduces a lag that is well-approximated as a first-order system:
First-order motor lag (frequency domain): G(s) = K_m / (τ·s + 1) K_m = motor gain (steady-state velocity per unit input) [rad/s per V] τ = time constant [s] — typically 50–150 ms for small mobile robots s = Laplace variable In the time domain, the step response is: ω(t) = ω_ss · (1 − e^(−t/τ)) ω_ss = K_m · V_applied [rad/s at steady state] FollowBot example: τ = 80 ms, K_m = 4.2 rad/s/V Command 3.0 rad/s → at t = 80 ms you have reached 63% (1.89 rad/s) → at t = 160 ms: 86% (2.58 rad/s) → at t = 240 ms: 95% (2.85 rad/s)
What does this mean in practice? If FollowBot's outer-loop planner sends a step cmd_vel at t=0, the robot does not immediately reach the commanded velocity. For the first 80 ms it is at 63% of target, for 160 ms at 86%, for 240 ms at 95%. Without an inner-loop controller, every velocity step command introduces a transient that your odometry integrates faithfully — producing position error that grows with each acceleration event. A P-controller with sufficient gain can reduce this lag; a feed-forward term can nearly eliminate it.
The time constant τ is not fixed hardware — it depends on the motor's electrical time constant (winding inductance / resistance), the mechanical time constant (rotor + wheel inertia / friction), and the ESC's current loop bandwidth. Heavier robots have higher inertia and longer τ. A robot climbing a ramp increases effective load torque and changes its effective τ dynamically. The inner-loop controller must be tuned with a representative load. A Kp you tuned on flat tile will be underdamped on carpet and oscillatory when climbing a 5° ramp, because the effective τ is different in all three cases.
The inner loop can be a pure P controller (simple, always stable if gain is not too high, but has steady-state error under load), a PI controller (eliminates steady-state error, risk of windup), or a full PID (adds derivative damping, but derivative of noisy encoder signal needs filtering). For most differential-drive mobile robots, PI with anti-windup is the practical sweet spot. ros2_control's built-in PID implementation handles this and is what FollowBot uses.
DEFINITIONcmd_vel in ROS 2: the Twist message and frame conventions
In ROS 2, velocity commands use the geometry_msgs/msg/Twist message type. It carries two 3-vectors: linear (x, y, z velocities in m/s) and angular (x, y, z angular rates in rad/s). For a differential-drive ground robot:
linear.x = forward velocity (positive = forward in the robot's body frame). angular.z = rotational rate around the vertical axis (positive = counterclockwise when viewed from above, i.e., turning left — REP-103 convention). All other components are zero and are ignored by the diff_drive_controller. The frame is base_link — velocities expressed in the robot body frame, not the world frame. This distinction matters the moment you integrate cmd_vel into odometry.
import rclpy from rclpy.node import Node from geometry_msgs.msg import Twist class CmdVelPublisher(Node): def __init__(self): super().__init__('cmd_vel_pub') self.pub = self.create_publisher(Twist, 'cmd_vel', 10) # 20 Hz timer — matches outer control loop rate self.create_timer(0.05, self.timer_cb) def timer_cb(self): msg = Twist() msg.linear.x = 0.4 # m/s forward msg.angular.z = 0.2 # rad/s left (REP-103: positive = CCW) # linear.y, linear.z, angular.x, angular.y = 0 (ignored for diff-drive) self.pub.publish(msg) def main(): rclpy.init() rclpy.spin(CmdVelPublisher()) rclpy.shutdown()
There is a common confusion here: the cmd_vel topic carries a velocity setpoint, not a trajectory. It says "I want to be moving at (0.4 m/s, 0.2 rad/s) right now." It does not say "accelerate smoothly to this velocity" — that is the job of either the planner (which ramps its own output) or a velocity smoother node sitting between the planner and the controller. If the planner issues a step change in cmd_vel, the inner loop receives a step setpoint, and the motor's first-order lag determines how long it takes to achieve it.
The diff_drive_controller stops the robot if it has not received a cmd_vel message within a configurable timeout (default 0.5 s in ros2_control). This is a safety feature. But it means your publisher must publish continuously at the control rate — not just when the velocity changes. A publisher that only publishes on change will leave the robot coasting at the last command when your node crashes. Always publish at a fixed rate; let the controller handle the "hold velocity" case by reading the last-received message.
IN PRACTICEros2_control and diff_drive_controller
The ros2_control framework is the standard way to implement the inner loop for real hardware in ROS 2. It separates the controller (what to do with velocity errors) from the hardware interface (how to talk to the actual motor driver). This separation means you can swap hardware (change from a Raspberry Pi GPIO motor driver to a USB-CAN ESC) without rewriting your controller.
controller_manager:
ros__parameters:
update_rate: 100 # inner loop rate [Hz]
diff_drive_controller:
ros__parameters:
left_wheel_names: ["left_wheel_joint"]
right_wheel_names: ["right_wheel_joint"]
wheel_separation: 0.300 # axle length [m]
wheel_radius: 0.0325 # wheel radius [m]
cmd_vel_timeout: 0.5 # stop if no cmd_vel within 0.5 s [s]
# PID gains for each wheel's velocity loop
left_wheel_pid:
p: 8.0
i: 2.0
d: 0.1
i_clamp: 5.0 # anti-windup: clamp integrator
right_wheel_pid:
p: 8.0
i: 2.0
d: 0.1
i_clamp: 5.0
publish_rate: 50.0 # odometry publish rate [Hz]
odom_frame_id: "odom"
base_frame_id: "base_link"
The controller reads the joint states (encoder positions, hence velocities by differentiation) from the hardware interface at 100 Hz, computes PID corrections for each wheel, and writes effort or velocity commands back to the hardware interface. It also integrates the wheel velocities using the diff-drive kinematic model to produce the odometry message on /odom.
Three numbers in this config deserve attention. wheel_separation and wheel_radius must be measured accurately — a 5% error in baseline directly translates to a 5% error in turning radius, which accumulates as heading error in the odometry. The i_clamp value is the anti-windup bound: it limits how large the integrator accumulation can grow when the robot is asked to move faster than it can (e.g., while held stationary or during startup). Without it, the integrator winds up to a huge value and the robot lurches when it first gets free.
SEE ITcmd_vel tracker: profile, lag, gain, and feed-forward
This widget simulates FollowBot's inner velocity control loop. You pick a velocity profile (step, ramp, or sinusoid), tune the P gain, and optionally add feed-forward from the kinematic model. The chart shows the commanded velocity (what the planner sent), the motor output (what first-order lag delivers), and the controller's actual wheel velocity (what the inner loop achieves). Observe where steady-state error appears, when the P-only loop oscillates, and how feed-forward collapses the error without raising gain.
The key lesson from this widget: with a step profile and no feed-forward, increasing Kp improves tracking speed but increases overshoot. At Kp above ~15 on a τ = 80 ms plant, the closed-loop starts oscillating. Adding feed-forward — which pre-emptively applies the known input needed to drive the motor to the target velocity, based on the inverse kinematic model — reduces the P controller's job to correcting residual errors only. The result: fast tracking, low overshoot, and much smaller steady-state error, at the same Kp.
Without feed-forward, the P controller must do all the work: it sees a large error and drives a large correction. This forces the gain up to get fast tracking, but high gain causes overshoot and oscillation. With feed-forward, the controller pre-applies the expected input (computed from the motor model: V = ω_target / K_m) and the P controller only corrects the residual mismatch due to model error, disturbances, and load variations. The P controller now operates on small errors at modest gains — stable, fast, accurate.
HOW IT WORKSFeed-forward from the kinematic model
The feed-forward term in the inner loop comes directly from the motor model. If the motor's steady-state gain is K_m (rad/s per volt), then to command a target wheel velocity ω_target, the feed-forward voltage is:
# Motor model parameters (identify on the real robot) K_m = 4.2 # steady-state gain [rad/s / V] tau = 0.080 # time constant [s] def feedforward_voltage(omega_target: float) -> float: """ Compute the feed-forward voltage to drive the motor to omega_target [rad/s]. This is the open-loop part of the controller; the PID corrects the residual. """ return omega_target / K_m # [V] — assumes linear motor model def inner_loop_command(omega_target, omega_actual, Kp, Ki, integral, dt) -> tuple: """Combined feed-forward + PI controller for one wheel.""" error = omega_target - omega_actual integral = integral + error * dt # time-scaled accumulation # Clamp integrator to prevent windup integral = max(min(integral, 5.0), -5.0) ff = feedforward_voltage(omega_target) pid = Kp * error + Ki * integral return ff + pid, integral
In practice, K_m and τ are identified from the real robot using a step-response test: command a known voltage, log the wheel encoder velocity over time, and fit the first-order model. This system identification step is often skipped in hobby projects and immediately regretted — a 20% error in K_m means the feed-forward is systematically wrong in the same direction, creating a persistent velocity offset that the integrator must eliminate.
Most motor drivers accept a PWM duty cycle (0–100%) rather than a voltage. The relationship is approximately linear for a fixed battery voltage: duty_cycle = V_command / V_battery. This matters because as the battery discharges (say, from 12.6 V to 10.8 V), the same duty cycle produces less torque and less velocity. A robust implementation either measures battery voltage and compensates the feed-forward gain accordingly, or uses current-mode control where the ESC closes a current loop internally. ros2_control hardware interfaces can expose effort or velocity command interfaces; the actual PWM translation is the hardware interface's job, not the controller's.
| Controller type | Steady-state error under load | Tracking speed | Stability risk | Typical use |
|---|---|---|---|---|
| Open-loop (voltage only) | High (load-dependent) | Limited by plant τ | None (no feedback) | Toy robots, demos only |
| P-only | Non-zero (persists) | Moderate | Oscillation at high Kp | Acceptable for non-critical following |
| PI | Zero (integrator eliminates it) | Moderate | Windup if no anti-windup | Standard for mobile robots |
| FF + P | Small (model-error only) | Fast | Low (P operates on small errors) | Good performance without tuning complexity |
| FF + PI | Near-zero | Fast | Low with anti-windup | Production-quality inner loop |
FOLLOWBOTWiring cmd_vel to FollowBot's wheels
FollowBot's Stage 2 milestone specifies that the differential-drive kinematic model is implemented in Python/ROS 2, producing both the forward model (wheel velocities → robot velocity) and the inverse model (desired cmd_vel → wheel commands). The inner velocity control loop is the mechanism that makes the inverse model physically real.
Here is the complete chain for FollowBot, from topic to motor:
DWA local planner → /cmd_vel
The Nav2 DWA planner publishes a geometry_msgs/Twist on /cmd_vel at 10–20 Hz. The message carries linear.x (forward velocity, m/s) and angular.z (yaw rate, rad/s). For FollowBot's person-following task, linear.x tracks the person's distance via a distance-to-velocity mapping, and angular.z tracks the person's bearing.
diff_drive_controller receives Twist, applies kinematic IK
The ros2_control diff_drive_controller subscribes to /cmd_vel. Using the configured wheel_separation (0.300 m) and wheel_radius (0.0325 m), it computes target wheel angular velocities via the inverse kinematics: ω_L = (v − ω·b/2) / r, ω_R = (v + ω·b/2) / r. These become the setpoints for the two independent wheel PID controllers.
Per-wheel PID + feed-forward → effort command
Each wheel's PI controller reads the encoder velocity at 100 Hz, computes the error to the target, and outputs an effort command (proportional to voltage). A feed-forward term proportional to the target velocity reduces the steady-state error without raising the integral gain. The effort command goes to the hardware interface — in FollowBot's case, a USB-serial interface to the Roboclaw motor controller.
Odometry from wheel velocities → /odom
The diff_drive_controller also integrates the encoder-measured wheel velocities using the forward kinematic model to produce nav_msgs/Odometry on /odom at 50 Hz. This is the odometry source for FollowBot's EKF localization (Lesson 2.5 / Stage 4). The accuracy of /odom depends on wheel_separation and wheel_radius being correct — errors here propagate into the state estimate and into every downstream decision.
from launch import LaunchDescription from launch_ros.actions import Node def generate_launch_description(): return LaunchDescription([ # Hardware interface node — talks to Roboclaw via USB serial Node(package='ros2_control_node', executable='ros2_control_node', parameters=[ 'config/followbot_robot.urdf.xacro', 'config/followbot_controllers.yaml' ]), # Spawner: activate the diff_drive_controller Node(package='controller_manager', executable='spawner', arguments=['diff_drive_controller']), # Spawner: activate the joint_state_broadcaster (feeds /joint_states) Node(package='controller_manager', executable='spawner', arguments=['joint_state_broadcaster']), ])
The Stage 2 milestone is complete for the velocity-control piece when: (1) ros2 topic echo /cmd_vel shows the planner's commands at 10–20 Hz, (2) ros2 topic echo /diff_drive_controller/cmd_vel_unstamped shows the controller receiving them, (3) ros2 topic echo /odom shows odometry updating at 50 Hz with consistent velocity, and (4) commanding a step cmd_vel and plotting the actual wheel velocities from /joint_states shows first-order tracking behavior with ≤ 5% steady-state error. If the steady-state error is larger, check battery voltage compensation and the i gain.
WEAKNESSWhere velocity control fails in practice
If your ros2_control URDF exposes only an effort interface (torque/PWM) without a velocity controller on top, publishing cmd_vel does nothing until you add a controller. Some hardware packages default to effort mode. The symptom: the robot either does nothing on cmd_vel, or — worse — runs a direct voltage-to-cmd_vel mapping that is load-dependent. On flat tile it looks fine. On carpet the effective wheel velocity is 20% lower for the same command; on a slope it slows further. Odometry integrates the commanded velocity, not the actual velocity, producing growing position error. The fix is always: add an inner velocity control loop and close it on encoder feedback, not on the command.
The diff_drive_controller uses wheel_separation and wheel_radius for two purposes: computing the IK (cmd_vel → wheel targets) and computing the FK (encoder ticks → /odom). A 3% error in wheel_separation produces a 3% error in turning radius in the IK, and the same error in the angular velocity in the odometry. These errors compound: the robot turns slightly more or less than commanded, and the odometry reports it turned by the correct amount, masking the real error. System identification of these parameters (rolling the robot a known distance and measuring actual displacement) is mandatory before tuning the PID — because PID tuning on top of geometric errors just hides the geometry problem under controller effort.
The DWA planner runs at 10–20 Hz; the inner velocity controller at 50–200 Hz. If the inner loop bandwidth is too low (because the P gain is too small, or the hardware interface has high latency), the actual wheel velocity lags the commanded velocity by more than one outer-loop period. The outer loop then computes its next velocity command based on a state estimate that reflects where the robot was, not where it is. This produces oscillatory following behavior — not because the planner is wrong, but because the inner loop cannot keep pace. The diagnostic: plot commanded vs. actual wheel velocity from /joint_states. If actual velocity is consistently lagging by more than 1 outer-loop period (50 ms at 20 Hz), raise the inner-loop gain or reduce the outer-loop rate before debugging the planner.
KEY INSIGHTHow it connects
- 2.1 · Differential Drive Kinematics: FollowBot's Motion Model — the forward and inverse kinematic models that this lesson puts to work inside the velocity controller. The IK equations v_L, v_R = f(v, ω) are the exact equations the diff_drive_controller uses to convert cmd_vel to wheel targets.
- 1.7 · Actuators and the Real-Time Constraint — the hardware side: brushless DC motors, ESCs, and the real-time scheduling requirements that make the inner loop viable at 100–200 Hz. The first-order lag model used in this lesson is introduced there from the electrical side.
- 2.8 · Trajectory Parameterization: Profiles, Splines, and Jerk → — the next lesson takes velocity further: instead of step cmd_vel commands, it generates smooth velocity profiles (trapezoidal, S-curve, spline) that limit acceleration and jerk. Those profiles are designed to be trackable by the inner loop — knowledge of the inner loop's bandwidth determines what ramp rates are achievable without overshoot.
The inner velocity control loop is the physical foundation that everything in Stage 3 (Dynamics Control) builds on. The PID you wire now, the feed-forward you add, and the bandwidth you achieve set the hard constraints for every trajectory-tracking, force-control, and compliance algorithm in Stage 3. Getting it right here is not premature optimization — it is the prerequisite.
GLOSSARYKey terms
- cmd_vel
- The ROS 2 topic (type
geometry_msgs/Twist) carrying velocity setpoints for a robot's body frame. Carries linear.x (forward velocity) and angular.z (yaw rate). A velocity request to the inner control loop, not a direct motor command. - Inner velocity control loop
- A feedback control loop (typically PI or FF+PI) that reads actual wheel velocity from encoders and adjusts motor effort to track a wheel velocity setpoint. Runs at 50–200 Hz; much faster than the outer (planner) loop.
- First-order motor lag
- The transfer function G(s) = K_m / (τs + 1) approximating a brushless DC motor's velocity response. τ is the time constant (typically 50–150 ms); K_m is the steady-state gain. The inner loop's goal is to fight this lag and make the effective plant appear faster to the outer loop.
- Steady-state error
- The persistent difference between the commanded and actual velocity that remains after transients die out. A P-only controller always has non-zero steady-state error under load. An integrator (PI controller) eliminates it by accumulating the error over time.
- Feed-forward
- An open-loop control term that applies the expected input required to drive the plant to the setpoint, computed from the motor model. Reduces the error that the feedback (PID) term must correct, allowing lower gains and better stability.
- Integrator windup
- Accumulation of a large integral term in a PI controller when the actuator cannot respond (e.g., when the robot is held stationary or commanded beyond its speed limit). Causes overshoot and oscillation when the constraint is released. Mitigated by clamping the integrator (i_clamp in ros2_control).
- diff_drive_controller
- The ros2_control plugin that converts cmd_vel (body-frame Twist) to per-wheel velocity setpoints using the diff-drive kinematic IK, runs a PID loop for each wheel, and publishes odometry by integrating the encoder-measured wheel velocities using the forward kinematic model.
- ros2_control
- The ROS 2 framework for real-time hardware control. Separates the controller (velocity PID logic) from the hardware interface (motor driver communication), enabling controller reuse across different hardware platforms.
ACTIVE RECALLCheck your understanding
Answer in your own words first, then reveal.
1Why does publishing cmd_vel not, by itself, control wheel velocity on a real robot?›
cmd_vel is a velocity setpoint delivered to a subscriber node — it specifies what body-frame velocity the robot should achieve, not what voltage to apply to the motors. On a real robot, a hardware interface and inner-loop controller must receive that setpoint, convert it to per-wheel targets via inverse kinematics, measure the actual wheel velocities from encoders, and actively close a feedback loop to drive the error to zero. Without this inner loop, applying a fixed voltage to the motors produces a velocity that varies with load, battery state, and terrain — the robot is effectively torque-controlled, and cmd_vel means nothing to it.
2A P-only inner-loop controller always has steady-state error under a constant disturbance load. Why, and what is the standard fix?›
A P-only controller outputs a correction proportional to the current error: u = Kp · e. At steady state, a constant load disturbance requires a non-zero control effort to overcome it. That means there must be a non-zero error (e = u / Kp) to produce that effort — which is the steady-state error. The only way to maintain non-zero effort with zero error is to add an integrator: the I term accumulates error over time until the integral term alone provides the needed effort, driving the error to zero. In practice this means using a PI controller (or a FF+P controller, where the feed-forward handles the steady-state effort and the P corrects model-error residuals). ros2_control's PID implementation supports both patterns via the p, i, d, and i_clamp parameters.
3FollowBot's odometry drifts: it reports a turning radius 4% smaller than the actual turning radius. Which config parameter is most likely miscalibrated, and how does this error propagate?›
The most likely cause is a miscalibrated wheel_separation (baseline). The diff_drive_controller uses wheel_separation in two places: in the inverse kinematics (cmd_vel → ω_L, ω_R) and in the forward kinematics (ω_L, ω_R encoder readings → /odom). A 4% error in wheel_separation makes the IK command 4% more differential (sharper turn) than the planner requested, and makes the forward kinematics report 4% less turning radius than actually occurred. The two errors partially mask each other — the robot turns slightly more than commanded, but the odometry also slightly underestimates the turn, so the mismatch propagates slowly. Fix: roll the robot in a full 360° circle and measure the actual heading change vs. the odometry-reported heading change. Adjust wheel_separation until they match.
4Explain the purpose of feed-forward in the inner velocity control loop and why it allows you to use a lower P gain for the same tracking performance.›
Feed-forward computes the expected control output needed to drive the motor to the target velocity using the known motor model (V_ff = ω_target / K_m), and applies it directly without waiting for an error to develop. This pre-emptively provides most of the effort the motor needs, so the feedback (P) term only needs to correct residual error due to model mismatch, disturbances, and noise. Because the feedback term is correcting small errors rather than doing all the work, you can achieve fast tracking with a moderate Kp that would be insufficient without feed-forward. High Kp is problematic because it amplifies noise and causes oscillation; keeping Kp low while adding feed-forward gives you fast tracking (from the FF) and disturbance rejection (from the P) without the stability cost of high gain.