10_官方例子程序01

http://www.roboticslibrary.org/api

http://www.roboticslibrary.org/tutorials/first-steps-windows

RL的库是多个静态库组成,我们开发时就只需要指定好头文件路径,然后库路径,就可以建立QT或者VS程序了。

但是RL的源码中没有把头文件单独的放到一个目录,而都是放到src里面的,所以我们可以直接把src的路径当作头文件路径,或者我们用安装版本的头文件路径作为include的path:

    下图是源代码的截图:

clipboard

    下图是安装包的截图,他是有把include单独提出来的。

clipboard[1]

下面是基于QT的项目如下,这是一个纯C++的项目

TestTransform.promain.cpp

运行需要依赖动态库:libxml2.dll

TEMPLATE=app
CONFIG+=console
CONFIG-=app_bundle
CONFIG-=qt

PRJ_ROOT=..
LIB_DIR=$$quote(E:/ProgramFiles(x86)/rl-0.6.2/lib)
BIN=$$PRJ_ROOT/../../bin/

DESTDIR=$$BIN
SRC_ROOT=$$PRJ_ROOT/src/
INCLUDEPATH+=$$quote(E:/ProgramFiles(x86)/rl-0.6.2/include)
INCLUDEPATH+=$$quote(E:/ProgramFiles(x86)/rl-0.6.2/include/boost-1_52)


DEFINES+=COIN_DLL
DEFINES+=SOQT_DLL
DEFINES+=M_PI=3.14159265358979323846
#解决Eigenabort的问题
#参考:http://eigen.tuxfamily.org/dox-devel/TopicUnalignedArrayAssert.html
DEFINES+=EIGEN_DONT_ALIGN_STATICALLY

CONFIG(debug,debug|release){
LIBS+=-L$$LIB_DIR/-lrlmdld-lrlkind-lrlsgd-lrlxmld-lcoin3d-lsoqt1d-llibxml2
}else{
LIBS+=-L$$LIB_DIR/-lrlmdl-lrlkin-lrlsg-lrlxml-lcoin3-llibxml2
}



SOURCES+=$$SRC_ROOT/main.cpp

代码如下:
#include<iostream>
#include<rl/math/Transform.h>
#include<rl/math/Unit.h>
#include<rl/mdl/Kinematic.h>
#include<rl/mdl/Model.h>
#include<rl/mdl/XmlFactory.h>

int
main(intargc,char**argv)
{
rl::mdl::XmlFactoryfactory;
rl::mdl::Kinematic*kinematics=dynamic_cast<rl::mdl::Kinematic*>(factory.create("E:\\ProgramFiles(x86)\\rl-0.6.2\\share\\rl\\examples\\rlmdl\\unimation-puma560.xml"));
rl::math::Vectorq(6);
q<<10,10,-20,30,50,-10;
q*=rl::math::DEG2RAD;
kinematics->setPosition(q);
kinematics->forwardPosition();
rl::math::Transformt=kinematics->getOperationalPosition(0);
rl::math::Vector3position=t.translation();
rl::math::Vector3orientation=t.rotation().eulerAngles(2,1,0).reverse();
std::cout<<"Jointconfigurationindegrees:"<<q.transpose()*rl::math::RAD2DEG<<std::endl;
std::cout<<"End-effectorposition:[m]"<<position.transpose()<<"orientation[deg]"<<orientation.transpose()*rl::math::RAD2DEG<<std::endl;
return0;
}

posted @ 2016-07-05 13:09  Lee'sEngineer  阅读(566)  评论(0编辑  收藏  举报