动力学库-pinocchio的C++例程

本文详细介绍了Pinocchio动力学库的使用,通过C++实例展示了如何利用该库进行机器人动力学计算,涵盖了从基本概念到实际编程应用的全过程。
摘要由CSDN通过智能技术生成

动力学库-pinocchio的C++例程

#include "pinocchio/parsers/urdf.hpp"
#include "pinocchio/algorithm/joint-configuration.hpp"
#include "pinocchio/algorithm/kinematics.hpp"
#include "pinocchio/algorithm/jacobian.hpp"
#include "pinocchio/algorithm/rnea.hpp"
#include <iostream>
#include <ros/ros.h>
#include "eigen3/Eigen/Core"
#include "eigen3/Eigen/Dense"
// PINOCCHIO_MODEL_DIR is defined by the CMake but you can define your own directory here.
#ifndef PINOCCHIO_MODEL_DIR
  #define PINOCCHIO_MODEL_DIR "/home/xxx/workspace/xxx/src/xxxxx_urdf"
#endif
int main(int argc, char **argv)
{
   
  ros::init(argc, argv, "Pinocchio_test");
  ros::NodeHandle nh;
  using namespace pinocchio;

  // You should change here to set up your own URDF file or just pass it as an argument of this example.
  const std::string urdf_filename = (argc<=1) ? PINOCCHIO_MODEL_DIR + std::string("/urdf/xxx_urdf.urdf") : argv[1];

  // Load the urdf model
  Model model;
  pinocchio::urdf::buildModel(urdf_filename,model);
  std::cout << "model name: " << model.name << std::endl;

  // Create data required by the algorithms
  Data data(model);

  // Sample a random configuration
//  Eigen::VectorXd q= randomConfiguration(model);
  Eigen::VectorXd q(model.nq) ,v(model.nv),a(model.nv),tau(model.nq);
  Eigen::Matrix<double,6,4> J1,J2,dJ;//the model has 4 joints
  q<<0,0,0,0;
  v<<0,0.1,0.1,0;
  a<<0,0,0,0;
  J1<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
  J2=J1;
  dJ=J1;
  std::cout << "q: " << q.transpose() << std::endl;
  std::cout << "v: " << v.t
  • 10
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值