This file is part of scl, a control and simulation library for robots and biomechanical models.scl is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License,or (at your option) any later version.
Alternatively, you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation;either version 2 of the License,or (at your option) any later version.scl is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the
GNU Lesser General Public License and a copy of the GNU General Public License along with scl. If not, see <http://www.gnu.org/licenses/>.

     \file   Math_R6Bot.nb
Created on : July 24,2012
   Author  : Samir Menon<smenon@stanford.edu>

Control tutorial :  R6Bot

The R6 robot has 6 revolute degrees of freedom, and can position and orient its hand in 3D space (xyz).

Here, we will develop control equations for the R6Bot. The equations will allow joint space dynamic control as well as operational space dynamic control.

Helper Functions

In[127]:=

MathTutorial_02_R6Bot_1.gif

Computing Kinematics and Dynamics

The generalized coordinates : q

The gen coords are one possible minimal set of variables that are necessary and sufficient to describe the configuration of the robot. By
convention, we shall call these 'q'. The generalized velocities, and accelerations as a consequence, are dq and ddq.

For R6Bot, a suitable set of generalized coordinates is one joint angle and two joint positions.

In[224]:=

MathTutorial_02_R6Bot_2.gif

The Forward Transformation Matrices

The first step to compute the control equations is to figure out coordinate transformations from a universal, stationary "origin" frame to the robot' s links. These transformations are functions of the generalized coordinates and are updated as the robot moves. They allow us to compute the position of different points on its links (like the link centers of mass), and are used extensively in any controller.

In[226]:=

MathTutorial_02_R6Bot_3.gif

MathTutorial_02_R6Bot_4.gif

Out[166]//MatrixForm=

MathTutorial_02_R6Bot_5.gif

Out[167]//MatrixForm=

MathTutorial_02_R6Bot_6.gif

Out[168]//MatrixForm=

MathTutorial_02_R6Bot_7.gif

Out[169]//MatrixForm=

MathTutorial_02_R6Bot_8.gif

Out[170]//MatrixForm=

MathTutorial_02_R6Bot_9.gif

Out[171]//MatrixForm=

MathTutorial_02_R6Bot_10.gif

Center of Mass Positions

COM Mass/Inertias For R6 - Bot wrt. their respective link frames. We will compute Jacobians in the origin' s frame, and so will move these vectors to the origin' s frame.

In[269]:=

MathTutorial_02_R6Bot_11.gif

MathTutorial_02_R6Bot_12.gif

Out[180]//MatrixForm=

MathTutorial_02_R6Bot_13.gif

Out[181]//MatrixForm=

MathTutorial_02_R6Bot_14.gif

Out[182]//MatrixForm=

MathTutorial_02_R6Bot_15.gif

Out[183]//MatrixForm=

MathTutorial_02_R6Bot_16.gif

Out[184]//MatrixForm=

MathTutorial_02_R6Bot_17.gif

Out[185]//MatrixForm=

MathTutorial_02_R6Bot_18.gif

Center of Mass Jacobians

Ok. So we have the frame positions. But if you recall rigid body dynamics, the configuration of a rigid body also requires the orientation. But a Jacobian must relate the generalized velocities to position and rotational velocities.

This is where things get hairy. Though a rigid body has three rotational degrees of freedom, there are no three variables that can completely describe the set of its rotations as well as their inverses. Storing the orientation position "requires" four variables with their vector norm constrained to 1 (ie. a vector on the surface of a 4D hypersphere).

However, storing the orientation rotational velocities require only three variables. We shall use this fact to compute the rotational part of the Jacobian by directly
computing the linear map from end-effector rotations to generalized coordinates. Basically, each joint adds some rotational velocity to all its children. So the Jacobian builds up.

In[292]:=

MathTutorial_02_R6Bot_19.gif

MathTutorial_02_R6Bot_20.gif

Out[194]//MatrixForm=

MathTutorial_02_R6Bot_21.gif

Out[195]//MatrixForm=

MathTutorial_02_R6Bot_22.gif

Out[196]//MatrixForm=

MathTutorial_02_R6Bot_23.gif

Out[197]//MatrixForm=

MathTutorial_02_R6Bot_24.gif

Out[198]//MatrixForm=

MathTutorial_02_R6Bot_25.gif

Out[199]//MatrixForm=

Using Energy Equivalence to Determine Mass In Arbitrary Coordinates

MathTutorial_02_R6Bot_27.gif

In[300]:=

MathTutorial_02_R6Bot_28.gif

Mass in the Generalized Coordinates

Using the earlier equations we shall project mass into the generalized coordinates. Doing so will help us build our generalized coordinate controller.

Since dx = J dq, we can use our earlier energy equivalence equations, to get a notion of mass in the generalized coordinates :
   1/2 dq' Mgc dq = 1/2 MathTutorial_02_R6Bot_29.gif

We use this relationship to derive Mgc from the M_i of the links at their centers of mass.  dq is arbitrary. So for the equations to hold, we must have :
   Mgc = MathTutorial_02_R6Bot_30.gif

In[301]:=

MathTutorial_02_R6Bot_31.gif

In[202]:=

MathTutorial_02_R6Bot_32.gif

In[203]:=

MathTutorial_02_R6Bot_34.gif

Out[203]=

MathTutorial_02_R6Bot_35.gif

Potential Energy Equivalence and Generalized Gravity

The next step is to model the gravitational field :
   The work done against gravity is the same in all coordinate systems,
and we shall use this to project the gravitational field into our generalized
coordinates.
    MathTutorial_02_R6Bot_36.gif . δq = MathTutorial_02_R6Bot_37.gif
    MathTutorial_02_R6Bot_38.gif . δq = MathTutorial_02_R6Bot_39.gif ....[δx = J δq]
       MathTutorial_02_R6Bot_40.gif = MathTutorial_02_R6Bot_41.gif    ....[δq is arbitrary]

In[302]:=

MathTutorial_02_R6Bot_42.gif

MathTutorial_02_R6Bot_43.gif

Out[217]//MatrixForm=

MathTutorial_02_R6Bot_44.gif

Computing Joint Space Dynamic Control

Dynamic control equations in the generalized coordinates

MathTutorial_02_R6Bot_45.gif

In[322]:=

MathTutorial_02_R6Bot_46.gif

In[321]:=

MathTutorial_02_R6Bot_47.gif

NOTE : To derive the dynamics equations, please go on to read the tutorial on computing dynamic models.  Alternatively, refer to Khatib’ s Operational Space papers. To really really derive them from scratch, also read about the Lagrangian dynamics formulation. Mechanics by Landau and Lifschitz is a good text.

Computing Operational Space Dynamic Control

The joint space dynamic control formulation delineated the joint space motion and joint space inertial changes between the joints, making the gains independent of the robot’s configuration. Each joint was then modeled/controlled independently, making the overall control quite simple.

That said, generating trajectories still was a hard problem since we aren't really interested in moving the generalized coordinates. Instead, it would be nice to generate trajectories at
the operational point. Let us pick the operational point to be the hand.

Before we proceed, I would like to point out that the hand coordinates are also an acceptable set of generalized coordinates for this robot. As such, one could repeat the above joint space dynamic control derivation for hand-space control. Since this is a turorial, however, we shall solve the operational control equations in a manner that generalizes to redundant robots whose hand coordinates might not be generalized coordinates.

In[324]:=

MathTutorial_02_R6Bot_49.gif

Jacobian at Operational Point : Hand

Let us start by computing the kinematics at the hand.

In[325]:=

MathTutorial_02_R6Bot_50.gif

In[330]:=

MathTutorial_02_R6Bot_51.gif

Out[330]//MatrixForm=

MathTutorial_02_R6Bot_52.gif

Out[331]//MatrixForm=

Note, however, that the Jacobian has a null space under certain angles corresponding to the robot’s physical limits. These are called singularities, and remove one or more degrees of freedom from the robot’s control space.

In[334]:=

MathTutorial_02_R6Bot_54.gif

For the remaining tutorial, we shall pick the xyz position controller. You may experiment with the other types yourself.

In[336]:=

MathTutorial_02_R6Bot_55.gif

Out[336]//MatrixForm=

Energy Equivalence and Operational Dynamics : Hand

MathTutorial_02_R6Bot_57.gif

In[338]:=

MathTutorial_02_R6Bot_58.gif

Out[338]=

MathTutorial_02_R6Bot_59.gif

Out[339]=

MathTutorial_02_R6Bot_60.gif

MathTutorial_02_R6Bot_61.gif

MathTutorial_02_R6Bot_62.gif

Reduced dynamic control equations in the operational coordinates

MathTutorial_02_R6Bot_63.gif

In[340]:=

MathTutorial_02_R6Bot_64.gif

MathTutorial_02_R6Bot_65.gif

In[341]:=

MathTutorial_02_R6Bot_66.gif

MathTutorial_02_R6Bot_67.gif

Spikey Created with Wolfram Mathematica 8.0