开源机器人库orocos KDL 学习笔记(一):win7VS2015环境搭建

orocos_kdl windows 环境搭建

牺牲了一个周末,总算是搞出来了,感觉这写代码原本是在linux上跑的,强行在windows上很费事,强烈建议在linux上玩。

orocos 项目是开源机器人控制软件,详见:http://www.orocos.org/

包含以下几个部分,这篇文章主要用于学习运动学与动力学库,简称KDL。

 

源码可以从github下载:

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

有源代码之后可以查看、运行demos,但首先需要搭建开发环境,搭建环境我也费了很大劲,由于全网都没有一个完整的教程,所以秉承开源精神将我搭建环境的方法分享出来。

 

平台:win7+visual studio 2015;

要在 CPP 中使用 Orocos KDLKDL Parser,需要先安装 Orocos KDL KDL Parser 。下面是安装步骤: 1. 安装 Orocos KDL : ``` sudo apt-get install liborocos-kdl-dev ``` 2. 安装 KDL Parser : ``` sudo apt-get install libkdl-parser-dev ``` 安装完成后,可以在 CPP 中使用这两个。使用 Orocos KDLKDL Parser 的示例代码如下: ```cpp #include <kdl/chain.hpp> #include <kdl/chainfksolver.hpp> #include <kdl/chainfksolverpos_recursive.hpp> #include <kdl/chainjnttojacsolver.hpp> #include <kdl_parser/kdl_parser.hpp> int main(int argc, char** argv) { // Load the robot description from the parameter server. std::string robot_description; ros::param::get("robot_description", robot_description); // Parse the robot description into a KDL tree. KDL::Tree robot_kdl; if (!kdl_parser::treeFromString(robot_description, robot_kdl)) { ROS_ERROR("Failed to construct KDL tree from robot description."); return 1; } // Create a solver for computing the forward kinematics of the robot. KDL::Chain robot_chain; robot_kdl.getChain("base_link", "end_effector_link", robot_chain); KDL::ChainFkSolverPos_recursive fk_solver(robot_chain); // Compute the forward kinematics of the robot for a given joint configuration. KDL::JntArray joint_positions(robot_chain.getNrOfJoints()); for (size_t i = 0; i < robot_chain.getNrOfJoints(); ++i) { joint_positions(i) = i * 0.1; } KDL::Frame end_effector_pose; fk_solver.JntToCart(joint_positions, end_effector_pose); // Create a solver for computing the Jacobian of the robot. KDL::ChainJntToJacSolver jac_solver(robot_chain); // Compute the Jacobian of the robot for a given joint configuration. KDL::Jacobian jacobian; jac_solver.JntToJac(joint_positions, jacobian); return 0; } ``` 这段代码演示了如何使用 Orocos KDLKDL Parser 实现机器人的正运动学和雅克比矩阵计算。需要注意的是,这段代码是在 ROS 中编写的,如果在其他环境中使用,需要根据需要进行修改。
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

巴普蒂斯塔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值