You've got to open the functions you're trying to use and look through them if you're getting errors. You said you are trying to get the forward kinematics of your robot, and that it's a non-floatbase, and that you've got a 3x1 vector of joint values q
.
Yet you're using fbkin
which, if you type help fbkin
into the console, will state (added bold for things relevant to you):
>> help fbkin
fbkin Forward and Inverse Kinematics of Floating Base
[x,xd]=fbkin(q,qd,qdd) calculates the forward kinematics, and [q,qd,qdd]=fbkin(x,xd) calculates the inverse kinematics, of a spatial floating base constructed by floatbase
.
So, right away, if you didn't use floatbase
to make your base, then you're using the wrong function. The rest of the help
message continues:
The vectors q, qd and qdd are the joint position, velocity and acceleration variables for the six joints forming the floating base; x is the 13-element singularity-free state vector used by FDfb and IDfb; and xd is its derivative.
And here it says it's a floating base, so naturally it's got six degrees of freedom, so if you're going to do anything with it then you can imagine the base as having six joints (x/y/z roll/pitch/yaw) and that's what this function is looking for when it uses q
as an input. It is not saying that this is for use with a robot arm or a kinematic tree or anything else. Just the floating base.
Continuing:
The component parts of x are: a unit quaternion specifying the orientation of the floating-base frame relative to the fixed base, a 3D vector giving the position of the origin of the floating-base frame, and the spatial velocity of the floating base expressed in fixed-base coordinates.
That is the output for the forward kinematics code - quaternion orientation and x/y/z position, and spatial velocity, which is angular and linear velocities. The remainder of the help
comment talks about different ways to call the function and things to look out for with regards to singularities.
This is not the code that's going to do forward kinematics for a robot arm. It's doing kinematics for a base.
You need to go to the \dyanmics
folder and look at some of the FD__
functions; those are the F
orward D
ynamics functions. Actually I was going to suggest you try FDab
and I remembered that was at the core of your other question, so I'm wondering why you're not using it.
Actually, in re-reading your question, it seems like you're not actually trying to do any dynamics simulations, rather you just seem to want to plug in a vector of joint values and get positions. In that case, I think the command you're looking for is jcalc
. This function takes a joint type and joint value q
and returns the spatial transform Xj
(which is a 6x6 matrix and not a 4x4 homogenous transform!).
Function like FDab
call jcalc
to build a chain of transforms, as in:
for i = 1:model.NB
[ XJ, S{i} ] = jcalc( model.jtype{i}, q(i) );
vJ = S{i}*qd(i);
Xup{i} = XJ * model.Xtree{i};
But I don't think there's any one function that's going to take your q
vector and spit out a series of positions. You'll have to build your own with jcalc
and work from there.