PID Control in Robotics

PID control in robotics

PID Control in Robotics: From Joint Error to Useful Robot Motion

A robot can have perfectly healthy motors and still produce poor motion. The tool may cut a corner, an axis may vibrate only when the arm is fully extended, or positioning may deteriorate as soon as the robot picks up a heavy part. These problems cannot all be solved by increasing a PID gain.

Robotic motion combines several layers of control. A path must first be planned, the required robot pose must be converted into joint motion, and each joint must then follow its command through a closed-loop servo system. PID, PI or PD control may be used inside this structure, but PID is only one part of the complete robot controller.

For the wider motion-control side of the subject, see our servo and motion control section.

Start at the tool, not at the motor

When a robot program commands a gripper to move from one point to another, the controller does not simply send that XYZ coordinate to six motors.

The requested tool position and orientation must first be converted into suitable joint positions. A motion profile is then generated so that the axes move together while respecting velocity, acceleration and other limits.

A simplified control chain is:

Robot program → trajectory generation → inverse kinematics → joint commands → servo loops → motors → encoder feedback

The PID-related part is mainly concerned with reducing the difference between commanded and measured motion. The calculation that determines which joint angles are required to place the tool at a particular Cartesian coordinate belongs to robot kinematics, not to the PID controller.

Kinematics decides where the joints must go. Closed-loop control decides how accurately they get there.

Joint space and Cartesian space are not the same control problem

A robot operator usually thinks about the tool centre point: move 300 mm forward, approach a fixture vertically or rotate the gripper by 90 degrees.

The servo drive does not see the machine in those terms. It works with motor position, velocity, torque and feedback.

For this reason, it helps to separate two ideas:

Cartesian motion: describes the position and orientation of the robot tool in the working space.

Joint motion: describes the angular or linear position of each individual robot axis.

One Cartesian movement may require several joints to accelerate, decelerate and even reverse direction at different times. The robot controller is responsible for coordinating these axes so that the tool follows the required path.

The individual joint loops then perform the lower-level motion-control work. The relationship between servo components and feedback is described further in the basic components of a servo system.

Where does PID appear inside a robot?

There is no universal rule stating that every robot joint must contain one conventional PID controller with three editable Kp, Ki and Kd fields.

Depending on the robot and servo architecture, a joint may contain nested position, velocity and current loops. One loop may use P control, another PI control, while feedforward, model-based compensation, filters and proprietary servo algorithms operate around them.

PID control with servo motors deals with those motor-level loops in more detail.

For robotics, the more useful question is not “Does this robot use PID?” but:

Which variable is being controlled, which controller closes the loop and what feedback is being used?

Position, velocity and torque play different roles

Position control attempts to reduce the difference between commanded and measured joint position. See PID control for position.

Velocity control regulates joint speed and is normally faster than the outer position loop. It is especially important during acceleration and deceleration. The general principles are covered in PID control for speed.

Torque or current control deals with the effort produced by the motor. It is an inner and very fast part of many servo systems. PID control for torque should therefore not be confused with commanding a robot to a position.

These loops influence one another, which is one reason why randomly changing gains can make robot behaviour worse rather than better.

What do P, I and D mean at joint level?

Proportional action reacts to the current error. More proportional gain can make a joint follow its command more tightly, but too much may cause vibration, audible noise or instability.

Integral action responds to error that persists over time. It can help remove steady offset caused by load or friction, but it can also accumulate excessively when an actuator reaches a torque or output limit.

Derivative action responds to the rate of change of the relevant signal and can provide damping in suitable control structures. It should not be described as literally predicting the future motion of the robot.

The underlying principles are explained in the P, I and D components of a PID controller.

Why the same robot behaves differently with a payload

Consider a six-axis robot that has been tested with an empty gripper. It then picks up a heavy component and moves the arm fully forward.

The servo system has not simply gained extra weight. The payload changes the inertia seen by the joints, the torque required for acceleration and the gravitational load acting on different parts of the arm.

Even the same payload can affect the robot differently depending on where its centre of gravity is located.

This is why industrial robot commissioning normally requires correct payload, centre-of-gravity and sometimes inertia information.

A conventional fixed-gain PID controller does not automatically identify a new payload and redesign its own gains.

A controller may include adaptive functions or other algorithms capable of responding to changing dynamics, but those features should be distinguished from ordinary fixed PID control. See adaptive control in servo systems.

Gravity compensation reduces the work left for feedback

An interesting robot problem appears when the arm is held horizontally.

Even when the joint position error is almost zero, some joints must continuously generate torque simply to prevent the arm and payload from falling under gravity.

A controller can use a mathematical model of the robot to estimate this required torque in advance. Similar model-based terms can compensate for known inertial and dynamic effects during motion.

The feedback controller then corrects the remaining error caused by modelling error, friction, disturbances and other effects.

This is an important distinction: the controller does not always have to wait for position error before producing all of the required torque.

Feedforward and feedback work together

PID is feedback control: it responds to measured deviation.

Feedforward uses information about the commanded motion or system model to produce part of the required control effort before a large tracking error appears.

During rapid robot motion, velocity and acceleration feedforward can reduce following error. Gravity and dynamic compensation can reduce the burden on the joint feedback loops.

Neither method replaces the other. Feedforward is only as good as the model or command information available, while feedback corrects errors that cannot be perfectly predicted.

Six good servo axes do not automatically make a good six-axis robot

Imagine that every robot joint performs well during an individual axis test. The complete robot may still produce a poor path when all axes move together.

Why?

Because coordinated robotics introduces additional requirements:

• trajectory generation,
• interpolation,
• synchronized axis timing,
• kinematic transformation,
• dynamic coupling between joints,
• mechanical compliance and gearbox behaviour.

Multi-axis synchronization is therefore a separate part of the control problem. Our page on synchronization and coordination in multi-axis servo systems examines this subject in greater detail.

A path error is not always a servo error

Suppose a robot has to move its tool along a straight line between two process points.

If the trajectory generator commands an unsuitable motion profile, the result may be mechanically harsh even when every servo axis follows its command accurately.

Conversely, the trajectory may be perfectly reasonable while one joint falls behind because the motor reaches its torque limit.

These are different faults.

Do not use servo gain to repair a trajectory-planning problem, and do not rewrite the path to hide a weak or badly tuned servo axis.

Encoder feedback tells the controller what the joint did

Closed-loop robot control depends on reliable position feedback. Servo motors commonly use absolute or incremental encoders, resolvers or other supported feedback systems.

The fundamentals of this feedback chain are covered in encoder and resolver feedback in servo systems.

There is an important mechanical limitation, however. The motor encoder usually measures the motor side of the transmission.

If a gearbox has backlash or a robot link flexes under load, the motor position may be correct while the physical tool position is slightly wrong.

High robot accuracy therefore depends not only on encoder resolution but also on calibration, gearbox condition, mechanical stiffness and the quality of the kinematic model.

A 23-bit encoder cannot remove mechanical backlash.

Repeatability and absolute accuracy are different

A robot may repeatedly return to almost the same point and still be offset from the programmed world coordinate.

That distinction matters when diagnosing a positioning complaint.

Poor repeatability can point toward backlash, feedback problems, mechanical instability or changing process conditions.

Poor absolute accuracy may also involve robot calibration, tool data, base coordinates, mechanical geometry or load deflection.

Changing PID gains is therefore not a universal cure for every positioning error.

What happens when several joints interact?

A robot is a coupled mechanical system. Moving one axis can alter the forces seen by another.

When an upper arm accelerates, the torque required at the shoulder and neighbouring joints can change. At high dynamic performance, these interactions become increasingly important.

Simple independent joint controllers can work well in many systems, particularly when supported by good servo design and compensation. More demanding applications may use robot dynamic models, feedforward terms or other multivariable control techniques.

The key point is that joint PID values should not be interpreted as though every motor were operating on an isolated test bench.

Contact changes the control objective

Pick-and-place motion normally aims to control position accurately in free space. Grinding, polishing, insertion, assembly and surface-following operations introduce another requirement: contact force.

A robot pressing against a surface cannot always be treated as a normal position-control problem. It may use force/torque feedback together with force control, impedance control, admittance control or another strategy suited to the application.

For example, commanding an exact position against a rigid surface while ignoring contact force can create excessive mechanical load.

“Move to this position” and “maintain this contact force” are different control objectives.

Real-time timing matters in multi-axis motion

A robot trajectory only makes sense if the axes execute coordinated commands at predictable times.

If one joint receives or processes its command significantly later than another, the actual tool path can deviate even when each individual servo eventually reaches its target.

This is why real-time control systems, synchronized servo networks and deterministic task timing are important in high-performance robotics.

For a deeper look at controller timing, see real-time operating systems in high-performance servo systems and real-time PID control challenges.

Example: a robot picks up a component and suddenly becomes unstable

Consider a robot that moves smoothly during commissioning with an empty gripper. A production part is then introduced.

The robot picks it up, accelerates toward the next station and develops visible vibration near the end of the move.

It would be easy to blame the PID gains immediately. A better investigation asks several questions first:

• Is the payload value correct?
• Is the centre of gravity entered correctly?
• Does the vibration occur only in one robot posture?
• Is one joint reaching its torque limit?
• Is the requested acceleration too high?
• Is there gearbox play or mechanical looseness?
• Does the joint follow the command correctly before the payload is picked up?

If the behaviour changes only after the part is gripped, the payload and dynamics deserve attention before anyone starts changing every servo parameter.

What should be checked when robot motion looks wrong?

Vibration only at particular arm positions: investigate posture-dependent stiffness, mechanical resonance, payload data and joint loading.

Good slow motion but poor high-speed tracking: check requested acceleration, available motor torque, current limits, feedforward and payload inertia.

Oscillation after reaching the point: examine joint-loop tuning, mechanical compliance, gearbox behaviour and the settling requirements of the application.

Accurate joints but inaccurate TCP: inspect robot calibration, tool data, base coordinates, mechanical deflection and kinematic parameters.

Correct motion without a payload but poor motion with a part: verify payload mass, centre of gravity and inertia-related settings.

Good individual axes but a poor coordinated path: investigate trajectory generation, interpolation, axis synchronization and controller timing.

General control-loop symptoms are discussed further in common PID problems and troubleshooting.

What is the PLC doing while the robot controller handles motion?

In a production cell, a PLC often coordinates the equipment around the robot: conveyors, clamps, pneumatic cylinders, machine-ready signals, guarding and process sequences.

The robot controller typically runs the robot program and coordinated joint motion.

The PLC may request a program, identify a product, provide a permission signal or wait for a robot-complete signal. It does not necessarily calculate the robot's six joint servo loops itself.

Specialized motion PLCs and controllers can of course control coordinated servo axes directly, but an ordinary process PID block is not a substitute for robot kinematics and trajectory generation. The PLC-specific side is discussed in PID control with PLCs.

PID tuning and robot safety are separate subjects

A control-loop parameter change can alter how aggressively a joint responds. Poorly chosen values may cause oscillation, sudden movement or increased mechanical stress.

Robot tuning should therefore be carried out using the robot or servo manufacturer's prescribed procedure and under suitable controlled conditions.

More importantly, normal PID or servo control is not the robot safety system. Personnel protection, safe speed, safe position, emergency stopping and guarding must be handled using the required safety architecture for the machine.

Related Robotics, Servo and PID Topics

Robot motion and servo fundamentals: Motion Control · Servo System Components · Servo Drive and Motor

Feedback and coordinated axes: Encoder and Resolver Feedback · Multi-Axis Synchronization · Real-Time Servo Control

PID motion loops: PID with Servo Motors · Position Control · Speed Control · Torque Control

Advanced control and troubleshooting: Adaptive Servo Control · Real-Time PID · PID Troubleshooting

Industrial robot manufacturers use different internal control structures, and many joint-control parameters are intentionally hidden from normal users. Payload data, servo tuning, motion limits and safety-related settings should always be verified against the documentation for the actual robot and servo system.