从零上手机器人动力学库pinocchio(一)pinocchio简介

目录

一、安装

二、Pinocchio中实现的主要算法

三、官方指南

四、pinocchio与pybullet联调



GitHub - stack-of-tasks/pinocchio: A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivativesA fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives - GitHub - stack-of-tasks/pinocchio: A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivativesicon-default.png?t=N7T8https://github.com/stack-of-tasks/pinocchio

一、安装

github明确给出了安装步骤和指令,非常简单,根据需求二选一即可。

系统:ubutntu 20.04

安装指令:

conda安装:

conda install pinocchio -c conda-forge

pip 安装:

pip install pin  # 只适用于Linux

部署在ROS上,通过以下指令可以安装具有 HPP-FCL 支持和 Python 绑定的 Pinocchio:

sudo apt install ros-$ROS_DISTRO-pinocchio

详细步骤请参考上方github链接。

官方配套可视化工具:

pinocchio支持许多开源可视化工具,根据需求安装适合自己的即可,我装的是gepetto viewer。

可视化工具
Gepetto Viewer
conda安装指令:conda install gepetto-viewer gepetto-viewer-corba -c conda-forge

与pinocchio一起使用时需要先在终端打开gepetto:

gepetto-gui

基于FCL方法实现了运动树的碰撞和距离算法。

Panda3dpip安装:pip install panda3d_viewer
Meshcat
pip安装:pip install meshcat

跟Panda3d一样,通过嵌入式浏览器实现交互

RViz

可以与其他ROS包交互

二、Pinocchio中实现的主要算法

Pinocchio提供基于revisited Roy Featherstone's algorithms的多关节系统刚体算法,提供主要刚体算法的解析导数(例如:Recurisive Newton-Euler Algorithm或Articulated-Body Algorithm),详见官方论文。

The Pinocchio C++ library : A fast and flexible implementation of rigid body dynamics algorithms and their analytical derivatives | IEEE Conference Publication | IEEE Xploreicon-default.png?t=N7T8https://ieeexplore.ieee.org/abstract/document/8700380?casa_token=iavz9sD7eccAAAAA:Bo6MXDNsxCOKO6NxCX5SEn_8qpGNsYXhoO3GfYqGlfGOFkNE8j22aBf4J0PfLcQ1e0dBV9xX实现的主要算法:

  • 正向运动学(forward kinematics):给定机器人构型,计算每个关节的空间位置并将其存储为坐标变换。如果给定速度或加速度,将计算每个关节的空间速度(以局部坐标系表示)。
  • 运动学雅可比矩阵(kinematic jacobian):在机械臂运动学中用来计算机械臂末端执行器的速度与各个关节运动速度之间的关系。
  • 逆动力学(inverse dynamics):采用Recursive Newton-Euler Algorithm (RNEA) 计算逆动力学。即给定所需的机器人构型、速度、加速度,计算并存储执行该运动所需的扭矩。
  • 关节空间惯性矩阵(Joint space inertia matrix):采用Compostie rigid body algortihm (CRBA)算法,计算关节空间惯性矩阵。
  • 前向动力学(forward dynamics):采用Articulated Body Algorithm(ABA)计算无约束的前向动力学。即给定机器人构型、速度、扭矩和外力的情况下,可以计算出由此产生的关节加速度。
  • 其他算法:其他算法包括约束正运动学,脉冲动力学,逆关节空间惯性矩阵,向心动力学。

三、官方指南

pinocchio: Overviewicon-default.png?t=N7T8https://gepettoweb.laas.fr/doc/stack-of-tasks/pinocchio/master/doxygen-html/index.html#OverviewConclu

四、pinocchio与pybullet联调

参考项目:github repo:

 GitHub - KanishkNavale/Robot-Physics-Engine: This repository implements an optimization strategy for singularity free trajectory generation for the serial robots.This repository implements an optimization strategy for singularity free trajectory generation for the serial robots. - GitHub - KanishkNavale/Robot-Physics-Engine: This repository implements an optimization strategy for singularity free trajectory generation for the serial robots.icon-default.png?t=N7T8https://github.com/KanishkNavale/Robot-Physics-EngineGitHub - nyu-legged-group/pinocchio_bulletContribute to nyu-legged-group/pinocchio_bullet development by creating an account on GitHub.icon-default.png?t=N7T8https://github.com/nyu-legged-group/pinocchio_bullet

https://github.com/machines-in-motion/mim_robotsicon-default.png?t=N7T8https://github.com/machines-in-motion/mim_robots———————————————— 分割线 2023.12.18——————————————————

pinocchio运动学计算及参数更新机制:

1. 导入URDF模型,创建数据模型。注意,model为刚体的模型结构,data存储了刚体系统的数据结构,当调用forwardKinematics()函数计算正向运动学时,函数根据当前关节位置、速度和加速度,更新data中存储的关节位置、空间速度和空间加速度。

import pinocchio
from sys import argv
from os.path import dirname, join, abspath
 
# This path refers to Pinocchio source code but you can define your own directory here.
pinocchio_model_dir = join(dirname(dirname(str(abspath(__file__)))), "models")
 
# You should change here to set up your own URDF file or just pass it as an argument of this example.
urdf_filename = pinocchio_model_dir + '/example-robot-data/robots/ur_description/urdf/ur5_robot.urdf' if len(argv)<2 else argv[1]
 
# Load the urdf model
model = pinocchio.buildModelFromUrdf(urdf_filename)
print('model name: ' + model.name)
 
# Create data required by the algorithms
data = model.createData()
 
# Sample a random configuration
q = pinocchio.randomConfiguration(model)
print('q: %s' % q.T)
 
# Perform the forward kinematics over the kinematic tree
pinocchio.forwardKinematics(model,data,q)
 
# Print out the placement of each joint of the kinematic tree
for name, oMi in zip(model.names, data.oMi):
    print(("{:<24} : {: .2f} {: .2f} {: .2f}"
          .format( name, *oMi.translation.T.flat)))

——————————————————分割线 2023.12.23————————————————

2. Pinocchio与Pybullet联调:pinocchio_bullet_wrapper.py

这个python文件是纽约大学团队开发的,为需要pybullet物理引擎仿真和pinocchio库计算设计的,使用这个接口一是为了用pinocchio,另一个原因是bullet可以集成到OpenAI Gym框架中,方便开发和比较强化学习算法。

(仿真在 PyBullet中进行,动力学库 Pinocchio 用于更新机器人的动态项,如惯性矩阵和雅可比矩阵)

包中关键函数是根据bullet中状态更新pinocchio参数:

    def get_state_update_pinocchio(self):
        """Get state from pybullet and update pinocchio robot internals.
        This gets the state from the pybullet simulator and forwards
        the kinematics, jacobians, centroidal moments on the pinocchio robot
        (see forward_pinocchio for details on computed quantities). """
        q, dq, ef = self.get_state()
        self.update_pinocchio(q, dq)
        return q, dq, ef

cons_cost_func:增广奖励函数,在有约束的MPPI中使用

cost_func:奖励函数,在env中调用,用于step函数中获取 当前状态的reward,并且存储在mem中,用于NAF网络训练。

  • 20
    点赞
  • 53
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
人工基于 MuJoCo 动力学引擎与 pinocchio 机器人动力学搭建的多平台开源机器人仿真框架,主要用于机械臂的深度强化学习训练与控制算法验证。 【探索人工智能的宝藏之地】 无论您是计算机相关专业的在校学生、老师,还是企业界的探索者,这个项目都是为您量身打造的。无论您是初入此领域的小白,还是寻求更高层次进阶的资深人士,这里都有您需要的宝藏。不仅如此,它还可以作为毕设项目、课程设计、作业、甚至项目初期的立项演示。 【人工智能的深度探索】 人工智能——模拟人类智能的技术和理论,使其在计算机上展现出类似人类的思考、判断、决策、学习和交流能力。这不仅是一门技术,更是一种前沿的科学探索。 【实战项目与源码分享】 我们深入探讨了深度学习的基本原理、神经网络的应用、自然语言处理、语言模型、文本分类、信息检索等领域。更有深度学习、机器学习、自然语言处理和计算机视觉的实战项目源码,助您从理论走向实践,如果您已有一定基础,您可以基于这些源码进行修改和扩展,实现更多功能。 【期待与您同行】 我们真诚地邀请您下载并使用这些资源,与我们一起在人工智能的海洋中航行。同时,我们也期待与您的沟通交流,共同学习,共同进步。让我们在这个充满挑战和机遇的领域中共同探索未来!

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值