Inverse Kinematics for Mobile Robots Using QP Solver

Inverse Kinematics for Mobile Robots Using QP Solver

Grégoire Passault

Grégoire Passault
Inverse Kinematics for Mobile Robots Using QP Solver

Introduction

Planning produces some trajectories to follow

Grégoire Passault
Inverse Kinematics for Mobile Robots Using QP Solver

Those trajectories are expressed naturally in the task-space.


We need a way to control the robot to actually follow those trajectories:
this is the whole-body control problem

Grégoire Passault
Inverse Kinematics for Mobile Robots Using QP Solver

Overview

  1. Robot modelling
  2. Defining tasks
  3. Inverse Kinematics
  4. Quadratic Programming
  5. In practice
Grégoire Passault
Robot modelling

Robot modelling

Grégoire Passault
Robot modelling

We model a robot with links and joints, and focus here only on serial robots.

Grégoire Passault
Robot modelling

Joint-space:

Joints velocity :

Forward kinematics is straightforward for serial robots.

Grégoire Passault
Robot modelling

Problem:
How to represent the fact that the robot can move around ?

Grégoire Passault
Robot modelling

Solution:

Adding 6 virtual degrees of freedom; we call them the floating-base.

⚠️ Those degrees of freedom are not actuated

Grégoire Passault
Robot modelling

In practice, robot geometry and dynamic properties can be represented in a robot description format.

Most popular are SDF and URDF.

Grégoire Passault
Defining tasks

Defining tasks

Grégoire Passault
Defining tasks

Task:
A task is an error that you want to take to .

Grégoire Passault
Defining tasks

Example: Position task

Grégoire Passault
Defining tasks

Example: Orientation task

Grégoire Passault
Defining tasks

Combining tasks

We can combine multiple tasks in one equation:

Grégoire Passault
Inverse Kinematics

Inverse Kinematics

Grégoire Passault
Inverse Kinematics

We want to solve for .

With a position task:


Need an expression for

Grégoire Passault
Inverse Kinematics

Numerical approach

Consider the (first-order) approximation of :

is here the so-called Jacobian matrix. Note that it depends on , even if we will omit it for simplicity.

Grégoire Passault
Inverse Kinematics

We can now solve the approximated:

🌈 Suppose is square and invertible, we have:

Grégoire Passault
Inverse Kinematics

This method is called the Newton-Raphson method

Grégoire Passault
Inverse Kinematics

What if is not square, or not invertible?

System can be:

  • not enough rows: Underconstrained
    There are infinite solutions to the equation,
  • too many rows: Overconstrained
    The equation can't be solved at all,
  • rank-deficient: Singular
    can be square, but not invertible.
Grégoire Passault
Inverse Kinematics

We need to replace equation solving with score minimization.

Instead of:

We will solve:

Grégoire Passault
Inverse Kinematics

This objective can be expanded to:

Grégoire Passault
Inverse Kinematics

is a quadratic, intuitively looks like

For minimizing, we need

(we need positive definite)

Grégoire Passault
Inverse Kinematics

We cancel its derivatives with respect to .



Instead of , we end up with : which is called the
Moore-Penrose (pseudo)-inverse

Grégoire Passault
Inverse Kinematics
Simplification alert:
This is not the proper and general way to compute the pseudo-inverse.

With numpy, you can use np.linalg.pinv

Grégoire Passault
Inverse Kinematics

The pseudo-inverse gives you the best solution in the sense of least-square errors.


Remaining problems:
  • Giving different "priorities" to different tasks?
  • How can we handle constraints?
    • Maximum joint velocities:
    • Joint limits:
Grégoire Passault
Quadratic Programming

Quadratic Programming

Grégoire Passault
Quadratic Programming
🪄 Quadratic Programming 🪄

Subject to:

ℹ️ Many solvers are available, you can try them using Python's qpsolvers

Grégoire Passault
Quadratic Programming

Remember the score we wanted to minimize is:

Since is here a constant, it is equivalent to minimizing:

and can then be computed to formulate the objective function of the QP problem.

Grégoire Passault
Quadratic Programming

It is exactly equivalent to computing the pseudo-inverse .


🎉 But, as a bonus, we can now add equality and inequality constraints!

Grégoire Passault
Quadratic Programming

Joint velocity limits


Joint limits

Grégoire Passault
Quadratic Programming

Tasks "soft" priorization

💡 Instead of having , let's go back to our stack of tasks . We can then compute:

Separately for each task .

Grégoire Passault
Quadratic Programming

The objective function is then the sum of weighted sub-objectives:

Grégoire Passault
Quadratic Programming

Tasks "hard" priorization

💡 Instead of adding a task in the objective function, we can add it the the equality constraints:

Grégoire Passault
Quadratic Programming

Under-constrained problem

QP formulation requires to be positive definite:
( should be non-zero for any non-zero )

If we don't have enough objectives, this will not be the case.

Grégoire Passault
Quadratic Programming

💡 We add the task with a very low weight . This is called regularization

It is equivalent to adding to .


💡 We can use any fallback task instead, for instance , where is a fallback posture.

Grégoire Passault
Quadratic Programming

QP problem

The problem can then be formulated as:

Where the superscript refers to the soft tasks, and to the hard tasks.

Grégoire Passault
Quadratic Programming

Kinematics tasks we implemented


  • Position task*,
  • Orientation task*,
  • Joint task,
  • Axis-align task,
  • Axis-plane task,
  • Distance task,
  • Center of mass task,
  • Centroidal mometum task,
  • Regularization task.

* Can be relative or absolute

Grégoire Passault
In practice

In practice

Grégoire Passault
In practice

Computing Jacobians can be done using Rigid Body algorithms library.


https://github.com/stack-of-tasks/pinocchio

Grégoire Passault
In practice

Let's make some squats!

Grégoire Passault
In practice

First, we can create the solver, and add two tasks:

solver = robot.make_solver()

T_world_trunk = np.eye(4)
trunk_task = solver.add_frame_task("trunk", T_world_trunk)
trunk_task.configure("trunk_task", "soft", 1.0, 1.0)

solver.add_regularization_task(1e-6)
  • trunk_task is a frame task (it packages both position and orientation task)
  • regularization_task is here to regularize the problem, because we have too many DoFs!
Grégoire Passault
In practice

Then, we can update the trunk_task target in the main loop:

T_world_trunk[2, 3] = 0.25 + np.sin(t)*0.05
trunk_task.T_world_frame = T_world_trunk
qd = solver.solve(True)
Grégoire Passault
In practice

We can now add a task for the left foot:

T_world_left = tf.translation((0., 0.055, 0.))
left_foot_task = solver.add_frame_task("left_foot", T_world_left)
left_foot_task.configure("left_foot_task", "soft", 1.0, 1.0)
Grégoire Passault
In practice

And do the same for the right foot:

T_world_right = tf.translation((0., -0.055, 0.))
right_foot_task = solver.add_frame_task("right_foot", T_world_right)
right_foot_task.configure("right_foot_task", "soft", 1.0, 1.0)
Grégoire Passault
In practice

Now, let's remove the trunk_task and add a com_task:

com_task = solver.add_com_task(np.array([0., 0., 0.]))
com_task.configure("com_task", "soft", 1.0)
com_task.target_world = np.array([0., 0., 0.3 + np.sin(t)*0.03])
Grégoire Passault
In practice

We can add a trunk_orientation task:

trunk_orientation_task = solver.add_orientation_task("trunk", np.eye(3))
trunk_orientation_task.configure("trunk_task", "soft", 1.0)
Grégoire Passault
In practice

We can now add a joints_task to impose target angles for the arms and the head:

joints_task = solver.add_joints_task()
joints_task.configure("joints", "soft", 1.0)
joints_task.set_joints({
    "head_yaw": 0.,
    "head_pitch": 0.,
    "left_shoulder_pitch": 0.,
    "left_shoulder_roll": 0.,
    "left_elbow": -2.,
    "right_shoulder_pitch": 0.,
    "right_shoulder_roll": 0.,
    "right_elbow": -2.,
    
})

Let's add some hand-made motion in the arms:

joints_task.set_joints({
    "left_shoulder_pitch":  np.sin(t*2.5)*0.5,
    "right_shoulder_pitch": np.sin(t*2.5)*0.5,
})
Grégoire Passault
In practice
Grégoire Passault
In practice

Kicking using cubic spline and frame tasks:

Grégoire Passault
In practice

Adding Centroidal Angular Momentum task to try to reduce the angular momentum:

Grégoire Passault
In practice

Highly recommended reading

Modern Robotics

  • Free PDF
  • Good YouTube channel
Grégoire Passault
Questions

Thanks!

🤔 Questions ?

Grégoire Passault