Description of the t..

advertisement
Description of the Transforms
Brian Lantz, Aug. 1, 2002
Each mechanical block in the model is defined with its own local coordinate system. To build the
system, the blocks are rotated and translated to the appropriate location in the ‘global coordinate
system’, then connected. This document describes how the coordinate transforms are performed. The
mechanical elements communicate using position and force; all the position and force connections in the
main Simulink model diagram are represented in the global coordinate system. The global coordinate
system is centered on the nominal center of mass of the stack support table. x is the beam direction, z is
vertical (+z is up). Positions are represented as a 12 element vector. The elements are, in order, motion
in x, y, z, rotation about x (right-handed), rotation about y, and rotation about z, velocity of x, y, and z,
and angular velocity about x, y, and z. The position information DOES NOT include the DC location in
global space, it only carries the information about displacements from the rest position of the mass
element. The position vector carries the derivative information because the velocity is necessary for the
hydraulic actuators, and it is also important for damping. The Matlab tools for creating velocity from
position don’t work very well (in fact the linearized model of the derivative operator doesn’t do anything
at all).
The force vector only contains 6 elements: force along x, y, and z, then torque about x, y, and z.
To move a local element into global space, first rotate the local coordinate space (about its center)
around the z direction (right-handed, or ccw when viewed from above), then translate it to the new
location. There is currently no implementation for rotations out of the x-y plane.
Figure 1: Definition of the transformed local coordinate system in the global coordinate system. The local
coordinates are xlocal and ylocal, shown as the dashed axes. The local coordinates are rotated by  and
translated by r.
The rotation and translation is the basis for the force transform.
Rotations are performed with a simple 3x3 matrix to rotate about the z axis.
cos( )  sin(  ) 0
rotmat ( )   sin(  ) cos( ) 0 .


0
1
 0
Rotations affect the force and the torque in the same way, so the true rotation matrix is a 6x6 block
diagonal with the upper left and lower right blocks defined as the same 3x3 rotation.
The translation is also calculated with a 6x6 matrix. Translation does not affect the force, but the
  
translation of a force results in a force and a torque, as   r  F .
Thus, the 6x6 translation transform is


F 
  0  F 
 
 
 
  translated r     


where we define the r  operation as a 3x3 matrix which operates on a vector. r  is calculated by
the crossTens.m function and returns a matrix
 0 z y 
crossTens ([ x, y, z ]' )   z
0  x .


0 
 y x
The dot product of this matrix with a vector returns the cross product of the two vectors.
To do the transform, we first rotate the local forces, then translate them. The code to transform a local
force and torque to a global force and torque is:
rot
= rotmat(rotation); % rotation about z, ccw, in degrees
RotationMatrix
= [rot, zeros(3); zeros(3), rot];
% 6x6 rotation matrix transforms all DOF
TranslationCross = crossTens(position);
TranslationMatrix =[eye(3), zeros(3);TranslationCross, eye(3)];
% force converts to a force and a torque, torque is unchanged
TransformTemp
= TranslationMatrix * RotationMatrix;
The transformation is a 6x6 matrix, called TransformTemp in the code above.
The conversion of the force from global to local coordinates in just the inverse of the matrix
TransformTemp.
Position Transformations
The position transforms are based on the transform from global to local coordinate space, because
that made more sense to me when I was doing it.
The transformation of motion in global space to the motion seen in the local space of the system is
done as a translation followed by a rotation. The translation moves you from the center of global space


to the center of the local space, at the location r . We denote the position coordinates as x and the 3

rotation coordinates with the vector  .



x
 I  r   x 

 
 
I    global
  translated 0
After translation to the center of the coordinate system, a rotation is used to transform into the local
space. The rotation is in the opposite direction as for the force output, since we are moving from global
to local space. This generates a 6x6 matrix. There are position variables; the 12 x 12 matrix is the block
diagonal of two of these 6x6 transforms. The code is:
rot
= rotmat(-rotation); % rotation about z, ccw, in degrees
RotationMatrix
= [rot, zeros(3); zeros(3), rot];
% 6x6 rotation matrix transforms all DOF
TranslationCross = crossTens(-position);
TranslationMatrix =[eye(3), TranslationCross; zeros(3), eye(3)];
% translationMatrix converts rotation about the global center to translation at the transform point
TransformTemp6x6 = RotationMatrix * TranslationMatrix;
TransformTemp
= [TransformTemp6x6, zeros(6);zeros(6),TransformTemp6x6];
Transform for the sensors
The sensors are defined with respect to the local space of the mass element on which they are
mounted. The sensors have two parameters to define the sensor transform – the location of the sensor in
local space, and the sensitive direction of the sensor in local space.
figure 2: Location of the sensor in local space. The sensor is defined using the sensor location, rl, and
the sensor direction, d.
The sensors are fed signals from global space, so the we need to define the transform from global to
sensor space.
To define the position in global space, we rotate local position vector and add it to the local
coordinate system position.
 

rs  r  rotmat ( )  rl
The direction also needs to be rotated by the .


d s  rotmat ( )  d l
Motion at the sensor location is, therefore, related to global motion by



x
 I  rs   x 

 
 
I    global
  sensor 0
code listing for Transform.m
function [TransformMatrix] = transform(position, rotation, ForP, INorOUT);
%Transform - the corrected function used to transform forces and positions between local and global
coords,
%
corrected version, July 18 2002
% [TransformMatrix] = transform[position, rotation, ForP, INorOUT];
% position is the 3 element position of the object in global coordinates. a Column vector
% rotation is the rotation in the x-y plane, in degrees. the actuators default in the +x direction
%
so a 45 degree rotation means they would push along [+x/rt(2) +y/rt(2)]
%
you can't rotate things into or out of z with this function
% ForP - either 'F' or 'P' for a force transform (6 x 6) or a position transform (12 x 12)
% INorOUT - either 'IN' or 'OUT' for transforms at the input or output of the block
% for an acuator at 1.5 meters in x and y, pushing ccw tangentially, use
%
% rot = 135;
% pos = [1.5 1.5 0]';
% ActTransOutH1 = transform[pos,rot,'F','OUT'];
% because the actuators have force outputs
%
% first you rotate the block by 'rotation' degrees righthanded about z (ccw when viewed from above)
% then you translate it to the location 'position'
%
% all the blocks use local coordinates inside the block and for their state representations
% the wires between the blocks are in global coordinates. +z is up.
% position coordinates are x, y, z, rx, ry, rz, sx, sy, sz, srx, sry, and srz.
% There are 12 positions to make damping easier. This is true except for the ground.
% There are only 6 force states, however, for forces aloong x, y, z, and torgues about tx, ty, and tz
% rx is a right handed rotation about the x axis, etc.
% tx is a right handed torque about the x axis, etc.
%
% the position transform does not track the absolute location in global coordinates,
% instead it tracks the motion in global coordinates. Thus, the DC location is not
% carried in the global position signals (too likely to cause rounding errors)
% BTL July 18 2002
%
% The position transforms have been completely rewritten. See pg 9-11 of BTL notebook 2 for examples
% July 18 2002
% we base the position transform on the input to the local coordinate system, not the output, as
% we do for the force transform. I find it easier to think about. Go figure.
%
%
%
%
look in first_sys_code for examples
BTL, June 27, 2002
made case insensitive
DC position not carried in global signals (and it never was)
% the force output matrix is the trans * rot, the input matrix is the inverse
% a force matrix is 6x6
%
% the position matrix is a block diagonal,
%
%
%
%
%
%
%
%
%
with 6x6 for positions and 6x6 more for the velocities
the blocks for the input are rotation * translation,
the translation converts rotation about the global center to
translation viewed at the new location
translationLocal = translationGlobal - position X rotationGlobal
rotationLocal
= rotationGlobal
the rotation of coordinates is then has a minus, since it is defined for local into global, not
global into local
if not(exist('INorOUT','var')) INorOUT='not defined'; end
not an error
if not(exist('ForP','var'))
ForP='not defined'; end
% this way it returns a repremand,
if strcmpi(ForP,'F')
rot
= rotmat(rotation); % rotation about z, ccw, in degrees
RotationMatrix
= [rot, zeros(3); zeros(3), rot];
% 6x6 rotation matrix transforms all
DOF
TranslationCross = crossTens(position);
TranslationMatrix =[eye(3), zeros(3);TranslationCross, eye(3)];
% force converts to a force and a torque, torque is unchanged
TransformTemp = TranslationMatrix * RotationMatrix;
if strcmpi(INorOUT,'IN')
TransformMatrix = inv(TransformTemp);
elseif strcmpi(INorOUT,'OUT')
TransformMatrix = TransformTemp;
else
disp('the INorOUT parameter must be either ''IN'' or ''OUT'' !')
TransformMatrix = [];
return
end
elseif strcmpi(ForP,'P')
rot
= rotmat(-rotation); % rotation about z, ccw, in degrees
RotationMatrix
= [rot, zeros(3); zeros(3), rot];
% 6x6 rotation matrix transforms all
DOF
TranslationCross = crossTens(-position);
TranslationMatrix =[eye(3), TranslationCross; zeros(3), eye(3)];
% translationMatrix converts rotation about the global center to translation at the transform
point
TransformTemp6x6 = RotationMatrix * TranslationMatrix;
TransformTemp
= [TransformTemp6x6, zeros(6);zeros(6),TransformTemp6x6];
if strcmpi(INorOUT,'IN')
TransformMatrix = TransformTemp;
elseif strcmpi(INorOUT,'OUT')
TransformMatrix = inv(TransformTemp);
else
disp('the INorOUT parameter must be either ''IN'' or ''OUT'' !')
TransformMatrix = [];
return
end
else
disp('the ForP parameter must be either ''F'' or ''P'' !')
TransformMatrix = [];
return
end
return
Download