Problem:
How to represent the fact that the robot can move around ?
Solution:
Adding 6 virtual degrees of freedom; we call them the floating-base.
Those degrees of freedom are not actuated
In practice, robot geometry and dynamic properties can be represented in a robot description format.
Most popular are SDF and URDF.
Task:
A task is an errorthat you want to take to .
Example: Position task
Example: Orientation task
Combining tasks
We can combine multiple tasks in one equation:
We want to solve
for .
With a position task:
Need an expression for
Numerical approach
Consider the (first-order) approximation of
We can now solve the approximated:
Suppose
This method is called the Newton-Raphson method
What if
is not square, or not invertible?
System can be:
We need to replace equation solving with score minimization.
Instead of:
We will solve:
This objective can be expanded to:
For minimizing, we need
(we need
We cancel its derivatives with respect to
Instead of
Moore-Penrose (pseudo)-inverse
With numpy, you can use np.linalg.pinv
The pseudo-inverse gives you the best solution in the sense of least-square errors.
Subject to:
Many solvers are available, you can try them using Python's qpsolvers
Remember the score we wanted to minimize is:
Since
It is exactly equivalent to computing the pseudo-inverse
But, as a bonus, we can now add equality and inequality constraints!
Joint velocity limits
Joint limits
Tasks "soft" priorization
Instead of having
Separately for each task
The objective function is then the sum of weighted sub-objectives:
Tasks "hard" priorization
Instead of adding a task in the objective function, we can add it the the equality constraints:
Under-constrained problem
QP formulation requires
(
If we don't have enough objectives, this will not be the case.
We add the task
It is equivalent to adding
We can use any fallback task instead, for instance
QP problem
The problem can then be formulated as:
Where the superscript
Kinematics tasks we implemented
* Can be relative or absolute
Computing Jacobians can be done using Rigid Body algorithms library.
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!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)
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)
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)
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])
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)
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,
})
Kicking using cubic spline and frame tasks:
Adding Centroidal Angular Momentum task to try to reduce the angular momentum:
Highly recommended reading