IK Solver for a robot
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?