mi-lib / roki

RoKi - Robot Kinetics library
MIT License
12 stars 7 forks source link

a possibly big modification around rkIK #17

Closed zhidao closed 1 year ago

zhidao commented 2 years ago

As you know, in the current implementation, rkIK is an outerclass of rkChain, and a target instance of rkChain has to be attached to rkIK by rkIKCreate.

Now, I'm thinking of including rkIK as a member of rkChain so that programmers can solve the IK much more easily, for example, by calling rkChainIK() without any care about how it is internally solved. It is also nicer for dealing with parallel kinematic chains, where structural constrains should be automatically embedded in models.

It needs a big modification. Any opinions? @n-wakisaka @categoryik @kdaic @takanobuyamamoto

kdaic commented 2 years ago

Does it mean that each rkIK functions will have the in-out argument of a rkChain pointer whenever called?
I think it is nice for user to be able to give any rkChain pointer in anytime to rkIK functions.

categoryik commented 2 years ago

It is good the idea to make comprehensive access point for users! In practice, when I used rkChain and rkIK, I defined my class named rkRobot, and wrap some methods for this class. If we choose above course, I think rkABI should be poped out from rkChain. i.e)

typedef _rkRobot{ // some master class name
rkIK ik;
rkChain chain;
rkABI abi;
// ... the other component if I have
} rkRobot; 
zhidao commented 2 years ago

My idea is to redefine rkChain as

typedef struct{
  ...
  rkIK *_ik;
} rkChain;

and the API for the IK solver as

rkChainIK( chain, q, tol, iter );

instead of

rkIKSolve( ik, q, tol, iter );

by which I expect programmers may forget about rkIK.

zhidao commented 2 years ago

BTW what is rkABI? @categoryik

categoryik commented 2 years ago

I was wrong. I mean rkABIPrp. When I wrote above, I thought rkABIPrp is directly in rkChain.

zhidao commented 1 year ago

The specification of inverse kinematics has been modified. A standard process of the inverse kinematics is as follows:

rkChainCreateIK( &chain );
rkChainRegIKJointAll( &chain, 1, 0.001 );
rkChainRegIKCell( &chain, ... );
...
  rkChainDeactivateIK( &chain );
  rkChainBindIK( &chain );
  rkIKCellSetRef( &cell, ... );
  rkChainIK( &chain );

No longer need to access an instance of rkIK directly. The internal instance of rkIK is automatically destroyed in rkChainDestroy().

zhidao commented 1 year ago

Note that RoKi-GL was also modified because rk_pen uses the inverse kinematics solver. Update them together.