Usually, what happens in practice is that you barely have access to the commanded torque. Instead, you can control electrical quantities, such as voltage and/or current, that in a electrical motor can be readily related to the torque applied to the shaft. This is to say that further dynamics appear in the response and thus the PID should be aware of them.

For example, a DC electrical motor is well described by the following transfer function:

$$F(s)=\frac{\theta(s)}{V(s)}=\frac{K}{s\cdot(1+\tau s)},$$

where $V$ is in the input voltage and $\theta$ is the measured angular position of the motor shaft. To a certain extent, by neglecting the elasticity of the gearbox, one can also apply the same plant model to a system where $\theta$ refers to the joint encoder measurements.

As you can see, there is still a pole in the origin, but this is not a real problem for the identification. So, before tuning the PID, it is always a good rule to understand what kind of system we are dealing with to then ground whatever approach we have in mind on the basis of the knowledge we have of such a system.

To come back to the point, the unknown parameters $K$ and $\tau$ account for the DC gain and the dynamical properties of the system, respectively. To find good values for $K$ and $\tau$ you can consider relying on a *least-squares* identification method (in its batch or recursive implementations) or even on the [*Extended-Kalman-Filter* estimator](http://control.ee.ethz.ch/~apnoco/Lectures/EKF.pdf) (EKF).

The EKF technique can be profitably applied to the state-space system whose transfer function is $F(s)$, augmented of two further states representing the evolution of $K$ and $\tau$ which is in turn implicitly assumed to be constant (i.e. with null derivatives).

Given the template $F(s)$ of your system, you can then inject proper input signals (e.g. step-wise, chirp, pulse trains), measure the output angular position, go through the identification methods and determine good representative values of the free parameters. Once done with that, put the model to test by assessing its performance when stimulated by signals you did not employ in identification (e.g. by varying both the input amplitude and input waveform).

Particular care should be taken for estimating the working area where the system behaves linearly and where your model is supposed to generate good response profiles (e.g. check if the actuator intrinsic nonlinearities have an impact or not). If you experience significant deviations between the measurements and the predictions, then you have to refine the model (e.g. increase model order, introduce dead-time ...).

What's the reason why we struggle to find a good representation of the plant? Because, of course, the model provides us with an easy way to tackle the PID tuning problem. You can resort to simulation, to well-established rules available in literature or even to simple considerations as below.

The *P* design may turn out from the requirement of tracking a reference signal whose frequency content is limited to the band $\omega_c$. Therefore, we have to equate $\left|F(j\omega_c)\right|$ to 1, hence:

$$\left|\frac{K_PK}{j\omega_c(1+j\tau \omega_c)}\right|=1,$$

from which we get:
$$K_P=\frac{\omega_c}{K}\sqrt{1+\left(\tau \omega_c\right)^2},$$

where $K_P$ is the proportional gain.

Since the system is already equipped with an integrator (i.e. the pole in the origin), we don't need the integral part of the PID, thanks to the so-called internal model principle. Nonetheless, for disturbance rejection purpose, one can design the *I* part under some mild conditions as:

$$K_I=\omega_{dr}K_P-\frac{\omega_{dr}^2\left(1-\tau \omega_{dr}\right)}{K},$$

where $K_I$ is the integral gain and $T_{dr}=3/\omega_{dr}$ is the time period wherein a step-wise disturbance is required to be canceled out.

For instance, the [scenario](https://robotics.stackexchange.com/a/4412/6941) described by [daweim0](https://robotics.stackexchange.com/users/1667/daweim0) will definitely require the integral gain to have zero steady-state error while counteracting the gravity component. The feed-forward term will be very helpful too.