Control Engineering

Introduction to Linear Control of Robots in C++

Markus Buchholz
Geek Culture
Published in
6 min readNov 1, 2022

--

The reason for the following article is to depict an intuitive approach to how to represent, and control the simplified physical model of the robot. It can be considered as a background to our discussion. On the other side, we are going to consider how to solve differential equations, which describe the motion of a simplified model of the robot.
Note: As the subject indicates this article has to be considered as an introduction,

Source code for all simulations discussed in this article you will find on my GitHub. You will need also the header file (for plotting) which has to be in the same folder as your cpp (a file you can clone from my repository).
Your program can be compiled as follows,

//compile
g++ my_prog.cpp -o my_prog -I/usr/include/python3.8 -lpython3.8//
//run
./my_prog
//folder tree
├── my_prog
├── my_prog.cpp
├── matplotlibcpp.h

In the following introduction, we will focus on the control method applicable to linear systems which can be formally described by linear differential equations.

When we consider the robot model, we use the describe the robot dynamics (dynamic model of the robot), which is associated with dynamic motion equations — a set of second-order differential equations
of the form (matrix equation).

Where τ ∈ R n is the actuator torques, M (q)q̈ is the torque contribution from joint-acceleration, C(q, q̇) q̇ is the torque contribution from Coriolis forces and g(q) is the torque contribution from gravity.

The above equation defined the inverse dynamics problem which is the process of calculating the motor (joint) torques required to achieve the desired joint acceleration given the current joint state (q, q̇).

Based on the following equation, the robot controller is able to compute the required motor torques to move the robot on the desired trajectory — see below figure.

Symplified robot control system (by author)

Generally, the robot (industry manipulator) is equipped with few sensors, which in practice are limited to encoders or resolvers that register the position of each motor axis. As you can see in the above figure, the robot works on a closed-loop control system. The Control system's main task is to compute the optimal control signal (torque) to minimize the error (difference) between the desired and the actual position and that between the desired and the actual velocity:

Ensuring that the resulting closed-loop system complies with predetermined performance requirements is the main challenge when building a robot control system. The stability of the system is the most fundamental requirement of this kind. We describe a system as stable for our purposes if the errors stay “small” when executing different planned trajectories even in the face of certain “substantial” disturbances. On the other hand, the performance of the control system can be also measured by the moving robot as fast as possible with max acceleration without decreases in robot path precision or repeatability.

In this article we discuss about the basics, therefore, our robot can be expressed as a mechanical system that consists of mass block m, coupled to a spring with stiffness k and susceptible to the damper with coefficient b. See figure

Dynamic system mass-damper-spring (by author)

We can consider that the second-order mechanical system’s default response is not what we want it to be. Further, we can say that the depicted mechanical system (robot) after performing the task never returns to x = 0. There is a deviation (error) that has to be eliminated. In our case, we are not able to change the mechanical parameters like the mass or value of the damper. In this case, the behavior of the system can be changed to a control system.

The equation of motion is obtained from a free-body diagram (this a “simplified” version of the equation which was given above).

Assume for the moment that we also have sensors that can track the block’s position and motion. We now put out a control law that determines the force the actuator should apply in relation to the sensed feedback:

where kp and kv are the coefficient gains of the control system see figure below.
Adjusting correctly the control gains we are able to control the mechanical system

Closed loop robot control system (by author)

Above equation, we can rewrite and

introducing,

we get two differential equations,

Using Runne Kutta's fourth-order method I solved specified derivative equations. Results can be depicted as follows. Please play with the dynamic parameters of the system and adjust the initial condition.

time response (blue poison of mass, orange speed of mass)

The below figure depicts the relation between poison and speed of a mass,

mass position vs speed

We can extend our simplified model to the model below (we can imagine this is a model of three-axis robot model).

Dynamic system mass-damper-spring (by author)

Here the most important is how we define the model and how we solve the differential equations, which in this case can be written as follows,

Similarly, we use Runne Kutta’s fourth-order method to solve equations. The result can be depicted as follows:

For mass nr 1.

time response (blue poison of mass, orange speed of mass nr 1)
mass1 position vs speed

Please note, in many cases, linear state-variable equations may not adequately capture the underlying physical behavior. Normally the manipulators are described by nonlinear differential equations which characterize the interaction between the various robot links.

To give you a simple example we can consider a classical nonlinear system: Van der Pol oscillator characterized by ( non-linear damping). The system can be described as follows,

Using Runne Kutta’s fourth-order method we solve the equations. The result can be depicted as follows:

time response (blue poison of mass, orange speed of mass)
mass position vs speed

Thank you for your reading.

--

--