gazebo机器人pid动态调节

2023-05-16

文章目录

  • 使用gazebo进行仿真的方法
    • 准备工作

使用gazebo进行仿真的方法

写此篇为了记录犯下的错误以及更正的办法,前路漫漫偶尔也要回头看看。

准备工作

首先要有一个urdf模型描述文件。生成的办法可以是手动添加也可以使用solidworks插件直接导出。针对导出的urdf文件进行简要的修改,包括邮件地址和作者信息。(可以不做)

  1. 使用$ roslaunch moveit_setup_assistant setup_assistant.launch打开moveit配置助手,按照步骤提示添加碰撞矩阵、虚拟关节(可选,如果要将模型固定在空中的某个位置要添加一个固定类型的关节child_link选择base_link,parent frame 选择world(自己命名,需要在urdf中添加这个link:<link name="world" /> <joint name="fixed" type="fixed" > <parent link="world" /> <child link="base_link"/> </joint>))、规划组、初始pose,等等。生成urdf并将绿色的部分更新到urdf文件。我的做法是将urdf备份并重命名为.xacro文件,方便后边更改然后把更新的部分在两边都添加(默认生成的文件有使用urdf的)
    以下为部分自动生成的部分(省略6个关节):
    <transmission name="trans_joint1"> <type>transmission_interface/SimpleTransmission</type> <joint name="joint1"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> </joint> <actuator name="joint1_motor"> <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission> <gazebo> <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so"> <robotNamespace>/</robotNamespace> </plugin> </gazebo>
  2. 关键点在于要使用的<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>我尝试使用了PositionJointInterface但是会有无法加载控制器pid的错误出现,使用这个接口问题就解决了。
  3. 建立控制器配置文件:controller.yaml,叫啥无所谓,只要包含时名字写对就行。文件内容如下:
/arm:
 # Publish all joint states -----------------------------------
 joint_state_controller:
   type: joint_state_controller/JointStateController
   publish_rate: 50  

 # Position Controllers ---------------------------------------
 joint1_position_controller:
   type: effort_controllers/JointPositionController
   joint: joint1
   pid: {p: 100.0, i: 0.01, d: 10.0}
 joint2_position_controller:
   type: effort_controllers/JointPositionController
   joint: joint2
   pid: {p: 100.0, i: 0.01, d: 10.0}

同样省略后续的关节控制器,这里要注意joint:指名的关节名字要和urdf/xacro文件中的关节名字一致。使用pid参数可以先随意指定后边可以动态调节。

type: effort_controllers/JointPositionController

指定的effort_controllers是输出类型是effort,输入类型为jointposition。输出类型要和urdf<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>中一样。目前测试这样的组合不报错。

  1. 建立控制器启动文件:controller.launch:其实就是包含一下刚才的yaml文件,使用controller_spawner把控制器启动参数就是yaml文件中的名字列表,启动robot_state_publisher完成坐标的广播。这里arm是我的模型名字。
<launch>

  <!-- Load joint controller configurations from YAML file to parameter server -->
  <rosparam file="$(find arm_control)/config/arm_control.yaml" command="load"/>
 
 <!--加载gazebo的控制器-->
<!--<rosparam file="$(find arm_moveit_config)/config/controllers_gazebo.yaml" command="load"/>-->

  <!-- load the controllers -->
  <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
    output="screen" ns="/arm" args="joint1_position_controller joint2_position_controller joint3_position_controller joint4_position_controller joint5_position_controller joint6_position_controller joint7_position_controller joint_state_controller"/>

  <!-- convert joint states to TF transforms for rviz, etc -->
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"
    respawn="false" output="screen" ns="/arm" >
    <remap from="/joint_states" to="/arm/joint_states" />
  </node>



  
</launch>
  1. 编写gazebo启动文件:
    启动一个空世界,加载模型到参数服务器,然后生成模型。注意检查包含的launch文件不要重复生成模型、控制器。
    urdf_spawner的参数可以指定模型生成的初始位置,如果模型和地面相交会出现鬼畜一样的抖动,此时请将 -z设置一个大于0的数值注意单位是m。
<launch>

  <!-- these are the arguments you can pass this launch file, for example paused:=true -->
  <arg name="paused" default="false"/>
  <arg name="use_sim_time" default="true"/>
  <arg name="gui" default="true"/>
  <arg name="headless" default="false"/>
  <arg name="debug" default="false"/>

  <!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <!-- <arg name="world_name" value="$(find arm_gazebo)/worlds/rrbot.world"/> -->
    <arg name="debug" value="$(arg debug)" />
    <arg name="gui" value="$(arg gui)" />
    <arg name="paused" value="$(arg paused)"/>
    <arg name="use_sim_time" value="$(arg use_sim_time)"/>
    <arg name="headless" value="$(arg headless)"/>
  </include>

  <!-- Load the URDF into the ROS Parameter Server -->
  <param name="robot_description"
    command="$(find xacro)/xacro --inorder '$(find arm_description)/urdf/arm_description.xacro'" />

  <!-- Run a python script to the send a service call to gazebo_ros to spawn a URDF robot -->
  <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
    args="-urdf -model arm -param robot_description -x 0 -y 0 -z 0.5"/>

   <!--ros_control arm launch file -->
  <!--<include file="$(find arm_control)/launch/arm_control.launch" />-->
<!--重复包含了arm_control.launch-->
</launch>
  1. 先启动gazebo,然后启动控制器。如果没有报错可以进入下一步pid动态调节。控制器偶尔会有启动失败可以尝试重新启动,没有指定pid_gain之类的错误请检查前边的配置。
  2. 使用rqt_gui后续步骤就和gazebo官网上的指导一样了。指定发布关节指令:/jointx_command然后打开动态调参插件,有pid选项可以使用就算是小小的成功。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

gazebo机器人pid动态调节 的相关文章

  • 对基于深度神经网络的Auto Encoder用于异常检测的一些思考

    一 前言 现实中 xff0c 大部分数据都是无标签的 xff0c 人和动物多数情况下都是通过无监督学习获取概念 xff0c 故而无监督学习拥有广阔的业务场景 举几个场景 xff1a 网络流量是正常流量还是攻击流量 视频中的人的行为是否正常
  • 阿里巴巴五轮面试经验分享

    拿到阿里实习offer xff0c 经历了5次面试 xff0c 其中4轮技术面 xff0c 1轮HR面试 在这里分享一下自己的面试经验和学习心得 希望能够帮助更多的小伙伴 我本科毕业于中南大学信管专业 xff0c 真正开始学习Java是在大
  • FishC笔记—20 讲 函数:内嵌函数和闭包

    本期内容详解 xff1a 1 内嵌函数 xff1a 函数内部新创建另一个函数 2 闭包 xff1a 函数式编程的重要语法 xff0c 如果在一个内部函数里 xff0c 对外部作用域 xff08 但不是在全局作用域的变量 xff09 进行引用
  • bash: setup.bash: No such file or directory和.bashrc文件的问题

    前段时间linux中打开终端时 xff0c 总是出现bash opt ros indig setup bash No such file or directory的问题 此问题跟每次终端打开时要加载的bash有关 xff0c 于是查bash
  • STL 容器、迭代器、算法归纳整理

    注 xff1a 文章由博主同步发布于 xff1a STL 容器 迭代器 算法小结 标准模板库 内容主要源自C 43 43 Standard Library 与 C 43 43 Primer STL是C 43 43 标准库的核心 xff0c
  • 对‘pthread_create’未定义的引用

    注 xff1a 本文由博主同步发布于 xff1a 对 pthread create 未定义的引用 问题 xff1a 使用CLion xff0c 在Linux下编写C 43 43 多线程程序 xff08 使用future和async xff0
  • 无人机4G数传一站多机模式

    随着4G的普及和5G技术的发展以及传统无人机数传距离的限制 xff0c 无人机联网的需求慢慢体现出来 xff0c 乐朴智能推出的无人机4G数传专为无人机应设计 xff0c 仅重49克方便无人机挂载 并且可以支持一站多机和多机互联的方式组网
  • 滑模原理框图

    这几天又重新复习了滑模控制原理 xff0c 借助相图来进行理解 xff0c 有了更深刻的认识 采用滑模控制要求系统是匹配条件下的 xff0c 更重要的是系统的扰动上界需要是已知的 xff0c 否则无法设置相应的切换增益用以抵抗干扰 xff0
  • 前端面试刷题网站汇总

    灵题库 http www lingtiku com 收集一线大厂面试真题 xff0c 还有专项训练 xff08 Promise 作用域 数据类型 React Vue 等等 xff09 以针对性提升 xff0c 每个题目有对应知识点的详细介绍
  • 大数据的感想

    1 大数据即全数据 xff08 即n 61 All xff0c 这里n为数据的大小 xff09 xff0c 其旨在收集和分析与某事物相关的 全部 数据 xff0c 而非仅分析 部分 数据 2 N 61 All xff08 所有 xff09
  • 完全搞懂shell脚本第一行:#!/bin/bash的含义

    shell脚本的第一行一般会写有以下字样 xff1a bin bash 或者 bin sh 或者 bin awk 比较常见的说法是 xff1a 第一行的内容指定了shell脚本解释器的路径 xff0c 而且这个指定路径只能放在文件的第一行
  • Python3 超好用的音频播放模块 playsound

    Python3 超好用的音频播放模块 playsound 前言playsound模块介绍一 模块安装二 使用三 使用中遇到大坑 xff1a 文件无法解除占用 xff01 前言 python2有个很好用的音频播放模块MP3player xff
  • ros中rviz查看激光雷达数据 hokuyo

    一开始没加tf会报错如下 WARN 1531227099 238940419 MessageFilter target 61 map Dropped 100 00 of messages so far 解决如下 启动传感器驱动 xff0c
  • ubuntu vscode 学习

    扩展 visual studio keymap 快捷键 Open the Command Palette View gt Command Palette Ctrl 43 Shift 43 P See an overview of the u
  • repo sync出现错误的解决方法

    1 xff1a 多次出现 fatal The remote end hung up unexpectedly fatal early EOF fatal index pack failed 网络不好 xff0c 挂VPN或使用其他的镜像源
  • python函数参数改不改变的问题

    python函数参数改不改变的问题 结论 xff1a python有可变对象和不可变对象之分 如果传入的参数是不可变对象 xff0c 则在函数体内对形参的修改不会导致实参被修改 xff0c 而如果传入的是可变对象 xff0c 实参有可能会变
  • Google 开源项目风格指南 (中文版)

    Google 开源项目风格指南 中文版 在线文档托管在 ReadTheDocs 在线阅读最新版本中文风格指南 GitHub 托管地址 xff1a zh google styleguide Note 声明 本项目并非 Google 官方项目
  • 富斯,迈克,天地飞4合1接收机说明书

    xff08 上图 xff0c 飞机用的接收机 xff09 xff08 上图 xff0c 车用的接收机 xff09 目录 1 如何和遥控器对码 xff1f 富斯FLLYSKY xff0c 天地飞 MC6C MC7C 2 如何切换对码另一个摇控
  • matlab: Unsupported shape type PolyLineZ

    参考 xff1a https gis stackexchange com questions 40613 importing shapefile in matlab Matlab使用shaperead读取shp文件时 xff0c 出现错误
  • 解决:mount: unknown filesystem type ‘ntfs’ 问题

    使用 mount dev sdb1 mnt usb 挂载U盘报错 mount unknown filesystem type ntfs 上网查询说是系统不支持ntfs文件 解决方法 xff1a 使用 ntfs 3g 来解决 打开ntfs 3

随机推荐