Migrating from Spatial_v1 to Spatial_v2

Spatial_v2 is not backward-compatible with spatial_v1.  Therefore, if you want to port code from one to the other then a certain amount of editing is required.  A detailed list of changes appears below; but first, here are the main differences between the two versions:

  1. planar-vector functions have been folded into their spatial-vector counterparts, and
  2. animation is now done within Matlab
In spatial_v1, there were separate functions for spatial and planar arithmetic.  For example, crfp was the planar version of crf, and IDp was the planar version of ID.  In spatial_v2, the planar functions no longer exist, and the spatial functions now implement both spatial and planar arithmetic.  Also, the planar version of the system-model data structure no longer exists, and a single data structure now caters for both types of arithmetic.

The old animation facility relied on a separate program, called SceneViewer, which was part of an old graphics package called OpenInventor.  A function called drawmodel would create a text file containing drawing instructions expressed in OpenInventor's language, and run SceneViewer to display them.  Spatial_v2 comes with a new animator, called showmotion, that uses Matlab's handle graphics to display animations directly, thereby eliminating the dependence on an external graphics program.  There have also been several changes to the format of drawing instructions.

Three more changes worth noting are that (1) non-default gravity must now be specified as a field in the system-model data structure, rather than as an argument to the dynamics functions; (2) external forces are now expressed in absolute coordinates (=fixed-base coordinates), rather than link coordinates; and (3) the floating-base functions now use a quaternion, rather than a spatial coordinate transform, to represent the orientation of the floating base.

Changes to Functions and Data Structures

The table below sets out the changes you will have to make in order to port your code from spatial_v1 to spatial_v2Note:  where a function is marked as 'no change', this does not mean that the function itself has not changed; rather, it means that you do not have to make any changes to your code.

Spatial Vector Arithmetic
crf no change
crm no change
mcI no change
Xrotx name changed to rotx
Xroty name changed to roty
Xrotz name changed to rotz
XtoV no change
Xtrans name changed to xlt
Dynamics Functions
fbKin replaced by fbkin which takes different arguments
FDab no gravity argument; f_ext now in absolute coordinates
FDcrb no gravity argument; f_ext now in absolute coordinates
FDf name changed to FDfb; return value afb replaced with xdfb; arguments Xfb and vfb replaced with xfb; no gravity argument; f_ext now in absolute coordinates
HandC no gravity argument; f_ext now in absolute coordinates
HD no gravity argument; f_ext now in absolute coordinates
ID no gravity argument; f_ext now in absolute coordinates
IDf name changed to IDfb; return value afb replaced with xdfb; arguments Xfb and vfb replaced with xfb; no gravity argument; f_ext now in absolute coordinates
jcalc pitch argument replaced with joint type descriptor
Model Constructors
autoTree no change
floatbase no change
planar2 withdrawn.  Use planar(2) for an equivalent model using planar arithmetic, or autoTree(2) for a model using spatial arithmetic but having slightly different inertias
planar3 withdrawn.  Use planar(3) for an equivalent model using planar arithmetic, or autoTree(3) for a model using spatial arithmetic but having slightly different inertias
planarN withdrawn.  Use planar(n) for an equivalent model using planar arithmetic, or autoTree(n) for a model using spatial arithmetic but having slightly different inertias
Planar Vector Arithmetic
crfp use crf instead
crmp use crm instead
mcIp use mcI instead
Xpln name changed to plnr
XtoVp use XtoV instead
 
Planar Vector Dynamics Functions
FDabp use FDab instead, but note that arguments differ
FDcrbp use FDcrb instead, but note that arguments differ
HandCp use HandC instead, but note that arguments differ
IDp use ID instead, but note that arguments differ
jcalcp use jcalc instead, but note that arguments differ
Planar Vector Model Constructors
autoTreep withdrawn
Graphics
drawmodel replaced by showmotion
Examples (demos)
planar2ctrl.mdl  replaced by example1.mdl
test_FD withdrawn
test_HD withdrawn
test_fb1 withdrawn
test_fb2 withdrawn
test_p withdrawn
Branch Induced Sparsity
expandLambda no change
LTDL no change
LTL no change
mpyH no change
mpyL no change
mpyLt no change
mpyLi no change
mpyLit no change
System Model Data Structure
NB no change
parent no change
pitch replaced by jtype
Xtree no change
I no change
appearance many changes — see below
[gravity] non-default gravity is now specified in the system model instead of as an argument to the dynamics functions
Planar System Model Data Structure
NB no change
parent no change
jcode replaced by jtype
Xtree no change
I no change
[gravity] non-default gravity is now specified in the system model instead of as an argument to the dynamics functions

Changes to Appearance Field

Changes to Drawing Instructions


Page last modified:  June 2012
Author:  Roy Featherstone