/Controlling_the_KINOVA7DOF

Exercise 1 of the Robotics control course at University of Pisa

Primary LanguageMATLAB

The 7 DOF Franka Emika Panda robot

Table of Content

The robotic arm

This 7 DOF Franka Emika Panda robot is equipped with 7 revolute joints, each mounting a torque sensor, and it has a total weight of approximately 18kg, having the possibility to handle payloads up to 3kg.

Figure 1 shows the Franka Emika Panda robot, its geometrical parameters and the used DH convention.

drawing

Robot modelling

The first step was to model the robot using Matlab Robot Control toolbox.

The robot is defined according to the DH table and its parameter are defined and assigned. This is done in robot_gen.m

The model is saved as PANDA.

The following paramters are used:

The parameters are found in this online repository while the exact procedure is described here:

Dynamic Identification of the Franka Emika Panda Robot with Retrieval of Feasible Parameter Using Penalty-based Optimization

The resulting model is:

drawing drawing

Once we have the dynamical model properly set up, we can proceed to implement the controllers.

Overview of the Implemented Controllers

Non adaptive

Pick and Place Circumference Helix
PD ✔️
PD with gravity compensation ✔️
PID ✔️
Computed torque ✔️ ✔️ ✔️
Backstepping ✔️ ✔️

Adaptive Methods

Pick and Place Circumference Helix
Adaptive Computed Torque ✔️ ✔️ ✔️
Adaptive Backstepping ✔️ ✔️
Li Slotine ✔️ ✔️

Code Structure

Before I dive into the report, I would line to outline the code structure. In the repository, there are essentially three folders.

  • Pick and place: It contains every result for the pick and place simulation. Every controller will be found in
./pick_and_place_results/pickandplace_ (desired controller).m

like:

./pick_and_place_results/pickandplace_computedtorque.m

Most of the results are already stored as (desired controller)_results.mat

Comparative plots for the pick and place scenario can be found in

./pick_and_place_results/plot_results.m
  • Non adaptive control

All the results are found in:

./non_adaptive_results/non_adaptive_trajectory_tracking.m

In the file, the following sections are found:

  1. Choose Trajectory (Helix or Circumference)
  2. Setup
  3. Compute Reference Trajectory (Cartesian to joint space)
  4. Execute the computed trajectory with the robot
  5. Trajectory Tracking: Computed Torque Method
  6. Computed Torque Results
  7. Trajectory Tracking: Backstepping Method
  8. Backstepping Results
  9. Comparison
  • Adaptive control

All the results are found in:

./adaptive_results/adaptive_trajectory_tracking.m

In this file, another manipulator was chosen, as I encountered difficulties in the computation of the dynamic regressor for the Franka 7 DOF arm (and even for a 5 dof simplyfied version of it). Therefore, I switched to the arm implemented in the robotics toolbox, the KUKA 5 DOF robot.

This file has a similar structure: in the first section the trajectory is computed, then the Computed Torque and Backstepping controller are calculated exactly as before. At the end, the mass of the model is modified and the Adaptive Controllers are implemented.

Each implementation will be specifically addressed in the respective adaptive controller section.

Reference Trajectories

I defined three reference trajectories:

Pick and Place Circumference Helix
drawing drawing drawing

Each trajectory will now be discussed in details with the implemented controllers.

Pick and Place

Trajectory definition

Initial Conditions

Final Conditions

Dynamic simulation

Starting from the initial conditions I compute the following quantities in a for loop over a 10s period with time constant 1ms :

  • Error, derivate of the error, integral of the error
  • Dynamic matrices

  • Torque, depending on the controller (PD, PD with G compensation, PID)

And last, accelleration, velocity and displacement resulting from the compute torque applied for a delta t of 1ms.

Tustin integration:

Independent PD controller

The first and most simple solution to control the end effector to a desired pose is to apply standard independent PD controller to follow references.

The aim of using Proportional-Derivative (PD) controller is to increase the stability of the system by improving control since it has an ability to predict the future error of the system response. In order to avoid effects of the sudden change in the value of the error signal, the derivative is taken from the output response of the system variable instead of the error signal. Therefore, D mode is designed to be proportional to the change of the output variable to prevent the sudden changes occurring in the control output resulting from sudden changes in the error signal.

drawing

The error is defined as:

drawing

And the control law is defined as:

drawing

The Dynamic thus will be:

drawing

In order to verify the stability at the desired value Direct Lyapunov is used with the following candidate:

drawing

Deriving the equation we obtain the semi negative definite value:

drawing

Also we must verify that:

drawing

This implies that PD control the error converges to 0 if the following hypothesis are true:

The first hypotesis will be analyzed in the simulation, while the second means that only step reference function can be given as input. This is ideal for pick and place.

I start with the following gains and then proceed to tune them for each specific controller:

Case I: Robot gravity is ignored

If the remove the G term from the dynamic equation than both hypothesis are true and the error converges to 0.

drawing

Case II: Robot gravity is no longer ignored

If we reinsert gravity one hypothesis is no longer true and we have an error offset in the solution:

drawing

It is clear how gravity affects only some joints depending on the configuration of the robot.

Case III: Gravity Compensation

We can solve this by compensating the gravity term with the following law:

drawing

Independent PID controller

Proportional-Integral-Derivative (PID) controller has the optimum control dynamics including zero steady state error, fast response (short rise time), no oscillations and higher stability. The necessity of using a derivative gain component in addition to the PI controller is to eliminate the overshoot and the oscillations occurring in the output response of the system.

drawing

PID Without gravity compensation

The initial offset slowly converges back to the right value (null steady state error). This PID doesn't require any knowledge of the gravity load for the manipulator.

It is worth mentioning that tuning the PID to achieve stability is much more difficult than tuning just the P and D components.

PID With gravity compensation

We don't have anymore the big error offset on the second and sixth configuration variable. However it doesn't have the big advantage of the PID (zero knowledge about gravity load )

Computed Torque

In order to achieve perfect reference tracking, the system should have an in built inner dynamical model that can be used to compute a feedforward action that complements the feedback action seen previously. A control that does this is the following:

drawing

Substituting this in the dynamics we obtain:

drawing

Which means that the error dynamics will be:

drawing

drawing

Essentially, the perfect knowledge of the dynamical model allows for complete linearization and desired pole placement. The trajectory tracking can be solved with arbitrarly fast convergence.

Computed torque Robustness and errors in the dynamical model

When Noise in dynamical parameters knowledge or friction or other sources of error are introduced It is much more difficult to have stability guarantees for the Computed Torque controller. In the following results, it is clear how deeply even a random error $<5%$ in the mass estimation affects the performances.

A more formal and correct approach would be to apply a control law with estimated M, G and C:

Substituting the dynamics:

Where $\eta$ depends non linearly from q.

Pick and Place Results Overview

The image shows the PD, compensated PD, PID, Computed Torque, and reference signals for the pick and place task.

The integral component can compensate for some of the limits of the PD independent controller, however it was extremely difficult to achieve a good tuning.

The Computed Torque method allows desired pole placement and performances, however requires the exact dynamical model to linearize the dynamic.

The computer Torque method is only robust up to a certain error margin in the estimation of the dynamical parameters.

Trajectory Tracking

Given a trajectory in the cartesian space, I compute the references in the joint space with the following block:

I use the non weighted pseudoinverse, therefore the solution will minimize the norm of the q.

Now I will proceed to define the used trajectories and the results for each controller.

  • Trajectory tracking I: Circumference

drawing

Trajectory Visualization

drawing

Desired Joint Trajectories

drawing

Computed Torque Controller

drawing

Backstepping Controller

drawing

Performance comparison between CT and BS

drawing

  • Trajectory Trackin II: Helix

drawing

Trajectory Visualization

drawing

Desired Joint Trajectories

drawing

Computed Torque Controller

drawing

Backstepping Controller

drawing

Performance comparison between CT and BS

drawing

|

The Backstepping Control

Considering a system written in the form:

The backstepping controller assumes that a controller exists for the higher level system in the form of a stabilizing feedback law:

The control for the second variable is computed so that it tends to track u’. This is done

For a completely actuated system the backstepping controller is reviewd in the follwing scheme:

Backstepping controller implementation

First, the necessary quantities are defined (reference velocity, tracking error). Then, the torque is defined as:

drawing

drawing drawing

Response to different trajectories speed and amplitude

I will now investigate what happens if the speed of the reference trajectory is increased. The equation now is:

Which correpsonds to the following joint trajectory:

drawing drawing

With the computed torque method, it is really simple to find a good set of paramteres to have really good controller performances:

Parameters for CT control:

Parameters for Backstepping: ![](./images/2020-06-10-19-36-31.png)

drawing |

The controllers provide very good performances despite of the speed of the reference trajectory.

Perturbations of Dynamical parameters and Adaptive strategies

We have demonstrated that most of these controllers are based on a strong assumption, perfect knowledge. This is never the case. In the next example it is clear how just introducing a light friction in the robotic arm causes troubles for the computed torque controller:

Usually, a perfect knowledge of the dynamical matrices is not known, and the controllers must rely on estimates. In such a case,

In the following section some dynamical parameters (the masses) are increased up to 2.5%.

for j = 1:num_of_joints % for each joint/link
    KUKAmodel.links(j).m = KUKAmodel.links(j).m .* (1+randi(5,1)/100); %masse [1x1]
end

Central to every adaptive controller is the Dynamic Regressor formulation that allows for a formulation that groups all the uncertainties in the estimation of the dynamic parameters.

Dynamic Regressor

The dynamic regressor is a matrix function employed to write the dynamics linearly in the inertial parameters:

drawing

The Dynamic regressor an be computed in closed form from the Lagrangian formulation. The lagrangian of a serial chain is defined as:

drawing

The equations of motion will be:

drawing

Reformulating the dynamics with the regressor gives:

drawing

Rerranging the terms:

drawing

The regressor has been computed in Wolfram Mathematica 12, using the Screw Calclus Package. The computation of the regressor for the Kinova 7DOF manipulator revealed to be too expensive, therefore I proceeded to compute the regressor for a simplyfied version of the robot (removing the last two links). The computation for the 5 DOF arm infact was the limit in terms of the sheer size of the output that mathematica could handle.

From now on I will refer to this simplyfied model.

New Trajectories for the adaptive control

  • Trajectory I

THe first trajectory is not expected to be sufficiently rich (eg. to excite all the joints ) to be able to estimate all dynamical parameters correctly. (The first joint remains constant)

drawing

drawing

The second trajectory will excite all the joints. Further experiment must be conducted to understand if it is "sufficiently rich"

  • Trajectory II

drawing

drawing

Adaptive Computed Torque

If there is parameters uncertainties, the torque will be:

drawing

Where the dynamic matrices represented above are the estimates based on the uncertainties in the dynamical system. Substituting the torque in the dynamics gives:

drawing

The estimated M matrix is considered inverible. As anticipated in the traditional computed torque section, the error dynamics is:

drawing

A proper dynamic of the dynamical estimation parameters must be chosen in order to grant the convergence to zero. If we write the error dynamics in normal form:

drawing

and the Lyapunov Function will be:

drawing

The derivative of the Lyapunov function will be:

drawing

and the dynamics of the parameters that makes it n.d is:

drawing

The convergence of the error dynamics is not guaranteed unless the Persistent Excitation condition is met:

drawing

In this case:

drawing

The problems for this control are the invertibility of the estimated Mass matrix and the need for joint accelleration measurements.

Adaptive computed torque implementation:

drawing

Adaptive computed torque results

drawing

drawing

This controller has a lot of margin for improvements by tuning the gains for both the error and the dynamic parameters dynamics.

Adaptive computed torque limits

The Adaptive computed torque method was the first adaptive method to be used on robotics manipulator. It is surely an important mileston but suffers some limits:

  • The Estimated Mass matrix is not always invertible.

  • It is usually very difficult to get clean acceleration measurements.

This problems will be solved in the Li-Slotine and Backstepping controllers.

Li Slotine Controller

The Li Slotine control uses the reference velocity:

drawing

where:

drawing

The control torque is:

drawing

Deriving the Lyapunov Function:

drawing

and substituting the torque we have:

drawing

Choosing the following dynamics for the dynamical paremeters estimation:

drawing

A s.n.d derivative is obtained:

drawing

Using the Barbalat Lemma the asymptotic stability is achieved.

Li Slotine Implementation

Li Slotine Results

Dynamical parameters estimation is decent: for joints 3,4,5 the mass seems to converge to the right value, while for joints 1 and 2 it doesn't. This could depend from the trajectory which has not sufficient information to make the parameters estimation converges for each joint. The R matrix can surely be tuned more to achieve better estimation, but the simulation are computationally expensive so limited trials were made.

Adaptive Backstepping Control

Adaptive Backstepping Implementation

Adaptive Backstepping Results

Overview of the Results

All the results are stored in:

adaptive_backstepping.mat
adaptive_backstepping_dyn_pars.mat
computed_torque.mat
computed_torque_dyn_pars.mat
li-slotine.mat
li-slotine_dyn_pars.mat

We have shown how adaptive controllers are fundamentals for robust control of the robotics manipulator in the presence of uncertainties in the dynamical or friction parameters. These are examples of how fast the computed torque performances degragadates in the presence of noise in the knowledge of the system parameters.

drawing drawing

The adaptive computed torque approach is based on complete linearization of the system but suffers some problems such as the need of acceleration estimation which is usually very noisy and the inverse of the Estimated Mass Matrix must be computed and it doesn't necessarly exists.

The Li Slotine and the Backstepping Adaptive Controller solve this issues, help to estimate the dynamical parameters and are able to control the system even with significative uncertainties.

In terms of performances all the adpative controllers provide very good tracking error if tuned properly. The dynamical estimation of the parameters is where they differ the most. The following comparison is provided:

drawing drawing drawing

The adaptive computed torque has the fastest dynamics and is the most precise if tuned properly (In the figure joint 2 and 3 were not tuned properly) The Backstepping controller is more precise than the Li-Slotine controller, with less oscillation and more steady behaviour. Both however have quite similar performances relative to the computed torque approach.

Final remarks

Adaptive controllers computation required significantly more computational burden than non adpative simulations. This is a hint on how difficult it can be to robustly control manipulators in real time in the presence of uncertanties in the dynamical model.

However, very good parameteric estimation can be made and Symbolic regressors can be built by performing experiments where the required quantities are measured (torques and control inputs). Doing an offline parametric identification can lead to the creation of an accurate model. The main limitation for such techniques is that accurate torque measurements are not always available. This is why the Kinova 7 DOF arm, with its force torque sensors at the joints, provides superior capabilities and allows for high performance control, and this is why it is being widely adopted in the industry.