我的使用安装环境是Ubuntu20,使用vscode+cmake进行编译与调试。
安装KDL库前必须安装好Eigen库。
KDL库是机械臂的运动学、动力学、轨迹规划的开源第三方库,功能强大。

一、Eigen库安装

首先可以搜索一下

sudo apt search eigen3

然后就出来了这几个选择,选择一个安装,很多其他的库安装也可以先搜索一下,这个命令还挺好用的

sudo apt install libeigen3-dev

二、KDL库安装

首先将远程代码仓的代码拷贝到本地

git clone https://github.com/orocos/orocos_kinematics_dynamics.git

然后切换到对应的目录

cd orocos_kinematics_dynamics/
cd orocos_kdl

然后创建build文件夹

mkdir build

然后编译以及安装

cd build
cmake ..
make
sudo make install

正常来说到这里KDL库就已经安装好了。

三、KDL库使用

找个新的文件夹,打开命令行,执行(目的是运行vscode打开当前文件夹)

code .

然后创建CMakeLists.txt以及main.cc两个文件
CMakeLists.txt中内容为:

cmake_minimum_required(VERSION 3.10)
project(learn_kdl)
find_package(Eigen3 REQUIRED CONFIG)
find_package(orocos_kdl REQUIRED)
add_executable(main main.cc)
target_link_libraries(main Eigen3::Eigen orocos-kdl orocos-kdl-models)

main.cc中的内容参考的KDL源码下的examples文件夹下的trajectory_example.cpp
内容如下

/*** \file path_example.cpp* An example to demonstrate the use of trajectory generation* functions.** There are is a matlab/octave file in the examples directory to visualise the results* of this example program. (visualize_trajectory.m)**/#include <frames.hpp>
#include <frames_io.hpp>
#include <trajectory.hpp>
#include <trajectory_segment.hpp>
#include <trajectory_stationary.hpp>
#include <trajectory_composite.hpp>
#include <trajectory_composite.hpp>
#include <velocityprofile_trap.hpp>
#include <path_roundedcomposite.hpp>
#include <rotational_interpolation_sa.hpp>
#include <utilities/error.h>
#include <utilities/utility.h>
#include <trajectory_composite.hpp>int main(int argc,char* argv[]) {using namespace KDL;// Create the trajectory:// use try/catch to catch any exceptions thrown.// NOTE:  exceptions will become obsolete in a future version.try {// Path_RoundedComposite defines the geometric path along// which the robot will move.//Path_RoundedComposite* path = new Path_RoundedComposite(0.2,0.01,new RotationalInterpolation_SingleAxis());// The routines are now robust against segments that are parallel.// When the routines are parallel, no rounding is needed, and no attempt is made// add constructing a rounding arc.// (It is still not possible when the segments are on top of each other)// Note that you can only rotate in a deterministic way over an angle less then PI!// With an angle == PI, you cannot predict over which side will be rotated.// With an angle > PI, the routine will rotate over 2*PI-angle.// If you need to rotate over a larger angle, you need to introduce intermediate points.// So, there is a common use case for using parallel segments.path->Add(Frame(Rotation::RPY(PI,0,0), Vector(-1,0,0)));path->Add(Frame(Rotation::RPY(PI_2,0,0), Vector(-0.5,0,0)));path->Add(Frame(Rotation::RPY(0,0,0), Vector(0,0,0)));path->Add(Frame(Rotation::RPY(0.7,0.7,0.7), Vector(1,1,1)));path->Add(Frame(Rotation::RPY(0,0.7,0), Vector(1.5,0.3,0)));path->Add(Frame(Rotation::RPY(0.7,0.7,0), Vector(1,1,0)));// always call Finish() at the end, otherwise the last segment will not be added.path->Finish();// Trajectory defines a motion of the robot along a path.// This defines a trapezoidal velocity profile.VelocityProfile* velpref = new VelocityProfile_Trap(0.5,0.1);velpref->SetProfile(0,path->PathLength());  Trajectory* traject = new Trajectory_Segment(path, velpref);Trajectory_Composite* ctraject = new Trajectory_Composite();ctraject->Add(traject);ctraject->Add(new Trajectory_Stationary(1.0,Frame(Rotation::RPY(0.7,0.7,0), Vector(1,1,0))));// use the trajectorydouble dt=0.1;std::ofstream of("./trajectory.dat");for (double t=0.0; t <= traject->Duration(); t+= dt) {Frame current_pose;current_pose = traject->Pos(t);for (int i=0;i<4;++i)for (int j=0;j<4;++j)of << current_pose(i,j) << "\t";of << "\n";// also velocities and accelerations are available !//traject->Vel(t);//traject->Acc(t);}of.close();// you can get some meta-info on the path:for (int segmentnr=0;  segmentnr < path->GetNrOfSegments(); segmentnr++) {double starts,ends;Path::IdentifierType pathtype;if (segmentnr==0) {starts = 0.0;} else {starts = path->GetLengthToEndOfSegment(segmentnr-1);}ends = path->GetLengthToEndOfSegment(segmentnr);pathtype = path->GetSegment(segmentnr)->getIdentifier();std::cout << "segment " << segmentnr << " runs from s="<<starts << " to s=" <<ends;switch(pathtype) {case Path::ID_CIRCLE:std::cout << " circle";break;case Path::ID_LINE:std::cout << " line ";break;default:std::cout << " unknown ";break;}std::cout << std::endl;}std::cout << " trajectory written to the ./trajectory.dat file " << std::endl;delete ctraject;} catch(Error& error) {std::cout <<"I encountered this error : " << error.Description() << std::endl;std::cout << "with the following type " << error.GetType() << std::endl;}
}

然后在vscode的最底下这栏,设置好编译器,我用的是clang,也可以用其他的,比如gcc,如果没有需要自行安装。


还需要在vscode中安装好c++以及cmake的扩展


好了,一切就像,可以开始编译了,点击vscode的最底下这栏的build,然后开始编译

没有问题的话就可以运行编译出来的可执行文件了,

最底下这栏,可以设置是debug模式还是release模式,点击三角形或者虫子符号,就可以运行了,最右边的main是可执行文件名称,如果有多个可执行文件,可以执行哪个。

执行结果如上所示,结束。

[KDL库学习]KDL库安装与使用相关推荐

  1. Arduino开发-TFT_eSPI库学习

    TFT_eSPI库学习 文章目录 TFT_eSPI库学习 TFT_eSPI库安装以及配置 TFT_eSPI库文件目录 配置文件 1.User_Setup_.h 2. User_Setup_Select ...

  2. Golang常用库学习

    Golang常用库学习 标准库fmt 标准库log 标准库time 标准库strconv 标准库 testing 单元测试 简单测试 单元测试覆盖率统计 表格驱动测试 性能(基准)测试 标准库 os ...

  3. 安装gym库_强化学习Gym库学习实践(一)

    最近看了一篇研究方向相关的文章,介绍了一种DQN的应用,感觉还挺新鲜的.想着把这篇文章复现出来,就开始学习强化学习的相关知识,作为一名小白,这一路走的可是真的十分艰难(我太菜了啊!) 看了莫烦Pyth ...

  4. Python学习笔记011_模块_标准库_第三方库的安装

    容器 -> 数据的封装 函数 -> 语句的封装 类 -> 方法和属性的封装 模块 -> 模块就是程序 , 保存每个.py文件 # 创建了一个hello.py的文件,它的内容如下 ...

  5. pytorch深度学习之音频librosa库与torchaudio库的安装与使用(windows和ubuntu)

    pytorch深度学习之音频librosa库与torchaudio库的安装与使用 搭建pytorch 基本框架 与 anaconda pytorch虚拟环境创建,去看这里 导入librosa库与tor ...

  6. Python学习-8.2 库(第三方库介绍与下载安装)

    一.第三方库内容介绍 3.1.网络爬虫 网络爬虫是自动进行HTTP访问并捕获HTML页面的程序 requests库 是一个简洁且简单的处理HTTP请求的第三方库.优点:程序编写过程更接近正常URL访问 ...

  7. Boost库学习笔记(一)安装与配置

    Boost库学习笔记(一)安装与配置 1. 获取boost https://www.boost.org/users/history/version_1_79_0.html 任选其一 boost的目录结 ...

  8. poco库学习笔记(1) poco库的安装

    1.下载安装 到官网http://pocoproject.org/下载最新版本poco-1.4.4.tar.gz,解压tar -xzvf poco-1.4.4.tar.gz,然后./configure ...

  9. 强化学习环境库 Gym 发布首个社区发布版,全面兼容 Python 3.9

    作者:肖智清 来源:AI科技大本营 强化学习环境库Gym于2021年8月中旬迎来了首个社区志愿者维护的发布版Gym 0.19.该版本全面兼容Python 3.9,增加了多个新特性. 强化学习环境库的事 ...

最新文章

  1. Redis 4.0.X版本reshard出现错误的解决办法
  2. php-screw下载,php_screw安装和使用
  3. Spring Cloud实战小贴士:Zuul的饥饿加载(eager-load)使用
  4. 通过Nginx,Tomcat访问日志(access log)记录请求耗时
  5. android唤醒前台,Android将后台应用唤起到前台的方法 (SDK 4.0, ActivityLifecycleCallbacks)...
  6. 对tableView三种计算动态行高方法的分析
  7. HDU - 6598 Harmonious Army(最大流最小割)
  8. 学习Windows编程遇到的问题
  9. (二十)深入浅出TCPIP之epoll的一些思考
  10. 5.Docker之镜像的使用
  11. 计算机基础知识整理 世上最全,IT小白必看:计算机基础知识整理大全
  12. 计算机毕业设计 SSM+Vue音乐播放网站系统 云音乐播放系统 付费音乐播放系统Java Vue MySQL数据库 远程调试 代码讲解
  13. 前端关系图谱插件_前端拓扑图插件选型对比
  14. [Python]_ELVE_centos7安装Python3.7.1与Python2共存
  15. 操作系统动态分区分配方式C/C++语言(首次适应算法(FF)循环首次适应算法(NF)最best适应算法(BF)最坏适应算法(WF))
  16. [IDE]webstorm安装并配置sass踩坑(windwos)
  17. html网页制作,前端三剑客一
  18. 中国移动国际mCloud体验再次升级,助力企业远程协同数字化转型
  19. easyphp mysql_用EasyPHP本地搭建PHP环境 | Wopus
  20. 数字电视标准ATSC,DVB的比较

热门文章

  1. 码蹄集 - MT3029 - 新月轩就餐
  2. 数据库SQL实战 --43.将id=5以及emp_no=10001的行数据替换成id=5以及emp_no=10005
  3. 上楼梯的走法 ← 递归
  4. 海康摄像头检测摄像头是否处于在线状态
  5. 微信小程序提交上线时 定位接口提示未配置
  6. matlab2010 notebook,Matlab在Win10 64位下用notebook的问题
  7. java 传感器_JAVA串口采集传感器数据
  8. 【python】控制鼠标定时移动 防止屏幕锁定 并生成可执行文件exe
  9. 23、动画及视野拓展
  10. LayUI # 清空下拉框的值