ChainIkSolverPos_NR Examples

Hello all, this is my first post.

Could anybody gives me a ChainIkSolverPos_NR example?

Regards,
Rodrigo

Ruben Smits's picture

ChainIkSolverPos_NR Examples

On Friday May 30 2008 19:43:12 rodrigo wrote:
> Hello all, this is my first post.
>
> Could anybody gives me a ChainIkSolverPos_NR example?

Ok, first of all: be very carefull when using the ChainIkSolverPos_NR class,
it's just a Newton-Raphson method so be prepared to get stuck at local
minima.

the ChainIkSolverPos needs a forward position solver and an inverse velocity
solver.

You need to give a initial guess for the position solution (if you are doing
periodical control the previous position can be a good candidate):

From the examples page:

//Creation of the chain:
KDL::Chain chain;
chain.addSegment(Segment(Joint(Joint::RotZ),Frame(Vector(0.0,0.0,1.020))));
chain.addSegment(Segment(Joint(Joint::RotX),Frame(Vector(0.0,0.0,0.480))));
chain.addSegment(Segment(Joint(Joint::RotX),Frame(Vector(0.0,0.0,0.645))));
chain.addSegment(Segment(Joint(Joint::RotZ)));
chain.addSegment(Segment(Joint(Joint::RotX),Frame(Vector(0.0,0.0,0.120))));
chain.addSegment(Segment(Joint(Joint::RotZ)));
//Creation of the solvers:
ChainFkSolverPos_recursive fksolver1(chain1);//Forward position solver
ChainIkSolverVel_pinv iksolver1v(chain1);//Inverse velocity solver
ChainIkSolverPos_NR iksolver1(chain1,fksolver1,iksolver1v,100,1e-6);//Maximum
100 iterations, stop at accuracy 1e-6
//Creation of jntarrays:
JntArray q(chain.getNrOfJoints());
JntArray q_init(chain.getNrOfJoints());
//Set destination frame
Frame F_dest=...;
int ret = iksolverpos.CartToJnt(q_init,F_dest,q);

Ruben

> Regards,
> Rodrigo

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

ChainIkSolverPos_NR Examples

Thanks for the answer.

I'll try to employ this in the control of Robix Kit using 2 analog joysticks.

Rodrigo


On Mon, Jun 2, 2008 at 5:42 AM, Ruben Smits <Ruben [dot] Smits [..] ...> wrote:

On Friday May 30 2008 19:43:12 rodrigo wrote:

> Hello all, this is my first post.

>

> Could anybody gives me a ChainIkSolverPos_NR example?



Ok, first of all: be very carefull when using the ChainIkSolverPos_NR class,

it's just a Newton-Raphson method so be prepared to get stuck at local

minima.



the ChainIkSolverPos needs a forward position solver and an inverse velocity

solver.



You need to give a initial guess for the position solution (if you are doing

periodical control the previous position can be a good candidate):



>From the examples page:



//Creation of the chain:

 KDL::Chain chain;

 chain.addSegment(Segment(Joint(Joint::RotZ),Frame(Vector(0.0,0.0,1.020))));

 chain.addSegment(Segment(Joint(Joint::RotX),Frame(Vector(0.0,0.0,0.480))));

 chain.addSegment(Segment(Joint(Joint::RotX),Frame(Vector(0.0,0.0,0.645))));

 chain.addSegment(Segment(Joint(Joint::RotZ)));

 chain.addSegment(Segment(Joint(Joint::RotX),Frame(Vector(0.0,0.0,0.120))));

 chain.addSegment(Segment(Joint(Joint::RotZ)));

//Creation of the solvers:

 ChainFkSolverPos_recursive fksolver1(chain1);//Forward position solver

 ChainIkSolverVel_pinv iksolver1v(chain1);//Inverse velocity solver

 ChainIkSolverPos_NR iksolver1(chain1,fksolver1,iksolver1v,100,1e-6);//Maximum

100 iterations, stop at accuracy 1e-6

//Creation of jntarrays:

 JntArray q(chain.getNrOfJoints());

 JntArray q_init(chain.getNrOfJoints());

//Set destination frame

 Frame F_dest=...;

int ret = iksolverpos.CartToJnt(q_init,F_dest,q);



Ruben









> Regards,

> Rodrigo







Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm