ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

IK Solver for a robot

asked 2014-06-25 11:25:34 -0600

Dante gravatar image

updated 2014-06-25 11:33:02 -0600

include kdl/chain.hpp

include kdl/chainfksolver.hpp

include kdl/chainfksolverpos_recursive.hpp

include kdl/frames_io.hpp

include stdio.h

include iostream

include Eigen/Core

using namespace KDL;

int main( int argc, char **argv ) {

    Chain chain;

    chain.addSegment( Segment( Joint( Joint::None ), Frame( Vector( 0.0, 6.7, 0.0 ) ) ) );

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

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

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

    chain.addSegment( 
        Segment( 
            Joint( Joint::RotY ), 
            Frame( 
                Rotation( 
                    Vector( 0.0, 0.0, -1.0 ),
                    Vector( 1.0, 0.0, 0.0 ),
                    Vector( 0.0, -1.0, 0.0 ) ),
                Vector( 0.0, 6.1, 0.0 ) 
            ) 
        ) 
    );

    ChainFkSolverPos_recursive fkSolver = ChainFkSolverPos_recursive( chain );

    int jointCount = chain.getNrOfJoints();
    JntArray jointPositions = JntArray( jointCount );

    ChainIkSolverVel_pinv ikSolverVel = ChainIkSolverVel_pinv( chain, 0.0, 150 );
    ChainIkSolverPos_NR ikSolverPos = ChainIkSolverPos_NR( chain, fkSolver, ikSolverVel, 100, 0.000001 );

    JntArray resultJoints = JntArray( jointCount );

    Frame destFrame( 
        Rotation::Rotation( 
            Vector( 0.0, 0.0, -1.0 ),
            Vector( 0.0, 1.0, 0.0 ),
            Vector( 1.0, 0.0, 0.0 ) ),
        Vector( -30, 10.0, 0.0 ) );

    if( ikSolverPos.CartToJnt( jointPositions, destFrame, resultJoints ) < 0 )
        std::cerr << "[ERROR] solving IK failed" << std::endl;

    for( int i = 0; i < jointCount; i++ )
        std::cout << "joint #" << i << ": " << resultJoints( i ) << std::endl;
}

i try to compile this file, but when i run $ make kdltest.cpp I get this Error:

In file included from /opt/ros/groovy/include/kdl/jntarray.hpp:26:0,
                 from /opt/ros/groovy/include/kdl/chainfksolver.hpp:28,
                 from test.cpp:5:
/opt/ros/groovy/include/kdl/jacobian.hpp:26:22: serious error: Eigen/Core: file or index dont found

what i forget?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-06-25 11:33:59 -0600

Does your package state its dependcy on Eigen in package.xml?

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-06-25 11:25:34 -0600

Seen: 419 times

Last updated: Jun 25 '14