MoveIT Rviz和Gazebo联合仿真
文章目录
- 环境
- 安装
- 概述
- ros_control框架
- ros_control数据流
- 文件配置
- 附加工具
- 故障问题解决
- 参考
接前两篇:
ROS MoveIT1(Noetic)安装总结
Solidworks导出为URDF用于MoveIT总结(带prismatic)
MoveIT1 Assistant 总结
环境
- Ubuntu20.04;
- ROS1 Noetic;
- VMware
安装
sudo apt-get install ros-noetic-joint-state-controller
sudo apt-get install ros-noetic-effort-controllers
sudo apt-get install ros-noetic-position-controllers
sudo apt-get install ros-noetic-joint-trajectory-controller
sudo apt-get install ros-noetic-controller-manager
sudo apt-get install ros-noetic-gazebo-ros-control
sudo apt-get install ros-noetic-ros-controllers
概述
URDF 用于创建机器人模型、Rviz 可以显示机器人感知到的环境信息,Gazebo 用于物理环境仿真。
先在Moveit!端配置关节和传感器接口yaml文件,将其加载到rviz端;再在机器人端配置ros_control和接口yaml文件,将机器人加载到Gazebo。
最后同时启动加载有ros_control的Gazebo和加载有Moveit的rviz,达到联合仿真的目的。
ros_control框架
ros_control包由以下几部分:
-
combined_robot_hw(硬件包):一个允许将多个RobotHW组合成一个“RobotHW”的软件包。
-
controller_interface(controller接口)
-
controller_manager(controller管理器):提供了一个近乎实时的controller管理器,用于管理(加载、卸载、启停)controllers。
-
controller_manager_msg(controller管理器的消息类型):定义了controller的状态消息类型msg,以及调用controller_manager的服务类型srv。
-
hardware_interface(硬件底层的接口):向硬件发送(write())命令并从硬件接收(read())联合状态。
https://github.com/ros-controls/ros_control/wiki/hardware_interface
-
joint_limits_interface(joints限制接口):根据URDF中的limit标签,将joint limit载入到硬件层中。
-
transmission_interface(传动接口):根据URDF中的transmission标签将该关系载入到硬件层中。
-
realtime_tools(实时控制工具):包含一组可以从硬实时线程中使用的工具,而不会破坏实时行为。
ros_control数据流
-
Controller Manager:每个机器人可能有多个controller,所以这里有一个控制器管理器的概念,提供一种通用的接口来管理不同的controller。controller manager的输入就是ROS上层应用的输出。
-
Controller:controller可以完成每个joint的控制,请求下层的硬件资源,并且提供了PID控制器,读取硬件资源接口中的状态,在发布控制命令。
-
Hardware Rescource:为上下两层提供硬件资源的接口。
-
RobotHW:硬件抽象层和硬件直接打交道,通过write和read方法来完成硬件的操作,这一层也包含关节限位、力矩转换、状态转换等功能。
-
Real Robot:实际的机器人上也需要有自己的嵌入式控制器,接收到命令后需要反映到执行器上,比如接收到位置1的命令后,那就需要让执行器快速、稳定的到达位置1。
【控制流】
ROS中的Controller manager接收load_controller、unload_controller等命令来加载和运行不同类型的controller(例如joint_position),这些controller通过Hardware Resource接口向硬件抽象层RobotHW读取和发布控制命令,这些命令再输入到机器人上的嵌入控制器上,然后有执行器执行。
文件配置
/home/gw2/ws_moveit/src/assis_1/config/robot_controller.yaml中定义的是"position_controllers/JointTrajectoryController",则URDF中定义的transmission中如果使用的是PositionJointInterface必须要对应,否则会提示找不到controller。
<transmission name="trans_Joint1"><type>transmission_interface/SimpleTransmission</type><joint name="Joint1"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface></joint><actuator name="Joint1_motor"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface><mechanicalReduction>1</mechanicalReduction></actuator></transmission><transmission name="trans_Joint2"><type>transmission_interface/SimpleTransmission</type><joint name="Joint2"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface></joint><actuator name="Joint2_motor"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface><mechanicalReduction>1</mechanicalReduction></actuator></transmission><transmission name="trans_Joint3"><type>transmission_interface/SimpleTransmission</type><joint name="Joint3"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface></joint><actuator name="Joint3_motor"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface><mechanicalReduction>1</mechanicalReduction></actuator></transmission><transmission name="trans_Joint4"><type>transmission_interface/SimpleTransmission</type><joint name="Joint4"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface></joint><actuator name="Joint4_motor"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface><mechanicalReduction>1</mechanicalReduction></actuator></transmission><transmission name="trans_Joint5"><type>transmission_interface/SimpleTransmission</type><joint name="Joint5"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface></joint><actuator name="Joint5_motor"><hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface><mechanicalReduction>1</mechanicalReduction></actuator></transmission>
在urdf中加入gazebo的ros_control插件,如果不加,运行gazebo会显示机械臂都耷拉在地上,仿佛电机没有使能一样。
<gazebo><plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so"><plugin name="joint_state_publisher" filename="libgazebo_ros_joint_state_publisher.so"><jointName>Joint1,Joint2,Joint3,Joint4,Joint5</jointName></plugin><robotNamespace>/</robotNamespace></plugin></gazebo>
检查ros_controllers.launch的args="control"不要有空格。
修改ros_controllers.yaml:
control:type: position_controllers/JointTrajectoryControllerjoints:- Joint1- Joint2- Joint3- Joint4- Joint5gains:Joint1: { p: 12000, d: 50, i: 0.0, i_clamp: 10000 }Joint2: { p: 12000, d: 50, i: 0.0, i_clamp: 10000 }Joint3: { p: 12000, d: 50, i: 0.0, i_clamp: 10000 }Joint4: { p: 12000, d: 50, i: 0.0, i_clamp: 10000 }Joint5: { p: 12000, d: 50, i: 0.0, i_clamp: 10000 }
运行rviz和gazebo:
source ~/ws_moveit/devel/setup.bash
roslaunch assis_1 demo_gazebo.launch
可以看到Rviz中的运动在Gazebo中可以同步运动。
附加工具
rqt_graph
创建一个显示当前系统ROS程序运行情况的动态图形
安装:
sudo apt install ros-noetic-rqt
sudo apt install ros-noetic-rqt-common-plugins
运行:
rosrun rqt_graph rqt_graph
可以看到结果:
通过这个图可以看到:
/move_group发送/control/follow_joint_trajectory/goal【目标位置】到机器人,机器人发送/joint_states【轴状态】到/move_group和/robot_state_publisher
rqt_joint_trajectory_controller
安装:
sudo apt-get install ros-noetic-rqt-joint-trajectory-controller
运行:
roslaunch assis_1 demo_gazebo.launch 或 roslaunch assis_1 gazebo.launch
rosrun rqt_joint_trajectory_controller rqt_joint_trajectory_controller
效果:拖动进度条可以在Gazebo实现各个关节的运动。
rqt_controller_manager
rqt插件,该插件以图形化方式加载,卸载,启动和停止控制器;同时用来显示加载的控制器的信息。
安装:
sudo apt-get install ros-noetic-rqt-controller-manager
运行:可以看到control和joint_state_controller两个控制器。
rosrun rqt_controller_manager rqt_controller_manager
故障问题解决
Spawn service failed. Exiting.
cmd /opt/ros/noetic/lib/gazebo_ros/gzserver -e ode worlds/empty.world
parse as old deprecated model file failed.
这三个错误往往一起出现,最后通过在urdf文件中添加解决:
filename=“libgazebo_ros_control.so”
https://blog.csdn.net/qq_60018807/article/details/128543981
ERROR: cannot launch node of type [controller_manager/spawner]: controller_manager接着一堆错误。
sudo apt-get install ros-kinetic-controller-manager
https://blog.csdn.net/weixin_45839124/article/details/106589576
模型自己转动,乱跑
sudo apt-get install ros-noetic-gazebo-ros-control
[ERROR] [1675950367.646886773, 0.307000000]: Failed to initialize the controller
[ERROR] [1675950367.649888591, 0.308000000]: Initializing controller ‘control’ failed
[ERROR] [1675950368.653177, 0.650000]: Failed to load control
在ros_controllers.yaml中添加前述代码。
[ERROR] [1675950605.984213275]: No p gain specified for pid. Namespace: /gazebo_ros_control/pid_gains/Joint1
[ERROR] [1675950605.988813331]: No p gain specified for pid. Namespace: /gazebo_ros_control/pid_gains/Joint2
[ERROR] [1675950605.991700327]: No p gain specified for pid. Namespace: /gazebo_ros_control/pid_gains/Joint3
[ERROR] [1675950605.995635439]: No p gain specified for pid. Namespace: /gazebo_ros_control/pid_gains/Joint4
[ERROR] [1675950605.999769977]: No p gain specified for pid. Namespace: /gazebo_ros_control/pid_gains/Joint5
添加修改ros_controllers.yaml文件:
/gazebo_ros_control:
pid_gains:
control:type: position_controllers/JointTrajectoryControllerjoints:- Joint1- Joint2- Joint3- Joint4- Joint5/gazebo_ros_control:pid_gains:Joint1: {p: 12000, d: 50, i: 0.0, i_clamp: 10000 }Joint2: {p: 12000, d: 50, i: 0.0, i_clamp: 10000 }Joint3: {p: 12000, d: 50, i: 0.0, i_clamp: 10000 }Joint4: {p: 12000, d: 50, i: 0.0, i_clamp: 10000 }Joint5: {p: 12000, d: 50, i: 0.0, i_clamp: 10000 }
但是加上以后发现Gazebo模型开始扭动起来,没眼看。最终无视这个错误即可。
https://blog.csdn.net/qq_32896521/article/details/111143282?spm=1001.2014.3001.5501
https://zhuanlan.zhihu.com/p/392635284
参考
https://blog.csdn.net/qq_34935373/article/details/95886151
https://ros-planning.github.io/moveit_tutorials/doc/gazebo_simulation/gazebo_simulation.html
http://www.guyuehome.com/890
https://blog.csdn.net/qq_41035283/article/details/120572465
http://wiki.ros.org/ros_control?distro=noetic
相关文章:

MoveIT Rviz和Gazebo联合仿真
文章目录环境安装概述ros_control框架ros_control数据流文件配置附加工具故障问题解决参考接前两篇:ROS MoveIT1(Noetic)安装总结 Solidworks导出为URDF用于MoveIT总结(带prismatic) MoveIT1 Assistant 总结 环境 Ubu…...
ESP32S2(12K)-DS18B20数码管显示温度
一、物料清单: NODEMCU-32-S2 (ESP32-12K)四段数码管(共阴)DS18B20(VCC/DQ/GND)Arduino-IDE 2.0.3二、实现方法及效果图: 2.1 引用库 // #include <OneWire.h> //可以不引入,因为DallasTemperature.h中已经引入了OneWire.h #include <DallasTemperature.h>#…...
linux栈溢出定位
一、编译选项定位堆栈溢出 来源:堆栈溢出检测机制 - SkrSky - 博客园 1、栈溢出可能打印 unhandled level 1 translation fault (11) at 0x7f8d0347, esr 0x92000005 2、栈溢出保护机制 gcc提供了栈保护机制stack-protector(编译选项-fstack-protec…...

CSS基础:选择器和声明样式
CSS概念 CSS(Cascading Style Sheets)层叠样式表,又叫级联样式表,简称样式表 CSS用于HTML文档中元素样式的定义 使用css让网页具有美观一致的页面 语法 CSS 规则由两个主要的部分构成:选择器和声明样式 选择器通常…...

VS中安装gismo库
文章目录前言一、下载安装paraview直接下载压缩包安装就可以了解压后按步骤安装即可二、gismo库的安装gismo库网址第一种方法:第二种方法第三种方法:用Cmake软件直接安装首先下载cmake软件[网址](https://cmake.org/download/)安装gismo库三、gismo库的使…...

元学习方法解决CDFSL以及两篇SOTA论文讲解
来源:投稿 作者:橡皮 编辑:学姐 带你学习跨域小样本系列1-简介篇 跨域小样本系列2-常用数据集与任务设定详解 跨域小样本系列3:元学习方法解决CDFSL以及两篇SOTA论文讲解(本篇) 跨域小样本系列4…...

大数据之------------数据中台
一、什么是数据中台 **数据中台是指通过数据技术,对海量数据进行采集、计算、存储、加工,同时统一标准和口径。**数据中台的目标是让数据持续用起来,通过数据中台提供的工具、方法和运行机制,把数据变为一种服务能力,…...
Python 中 字符串是什么?
字符串是 Python 中最常用的数据类型。我们可以使用引号 ( ’ 或 " ) 来创建字符串。 创建字符串很简单,只要为变量分配一个值即可。例如: var1 ‘Hello World!’ var2 “Python Runoob” Python 访问字符串中的值 Python 不支持单字符类型&…...
OJ刷题Day1 · 一维数组的动态和 · 将数字变成 0 的操作次数 · 最富有的客户资产总量 · Fizz Buzz · 链表的中间结点 · 赎金信
一、一维数组的动态和二、将数字变成 0 的操作次数三、最富有的客户资产总量四、Fizz Buzz五、链表的中间结点六、赎金信一、一维数组的动态和 给你一个数组 nums 。数组「动态和」的计算公式为:runningSum[i] sum(nums[0]…nums[i]) 。 请返回 nums 的动态和。 示…...
【数据结构】栈——必做题
逆波兰表达式后缀表达式的出现是为了方便计算机处理,它的运算符是按照一定的顺序出现,所以求值过程中并不需要使用括号来指定运算顺序,也不需要考虑运算符号(比如加减乘除)的优先级。先介绍中简单的人工转化方法&#…...

LearnOpenGL 笔记 - 入门 04 你好,三角形
系列文章目录 LearnOpenGL 笔记 - 入门 01 OpenGLLearnOpenGL 笔记 - 入门 02 创建窗口LearnOpenGL 笔记 - 入门 03 你好,窗口 文章目录系列文章目录前言你好,三角形顶点输入顶点着色器(Vertex Shader)编译着色器片段着色器&…...

keepalived+mysql高可用
一.设置mysql同步信息两节点安装msyql略#配置节点11.配置权限允许远程访问mysql -u root -p grant all on *.* to root% identified by Root1212# with grant option; flush privileges;2.修改my.cnf#作为主节点配置(节点1)#作为主节点配置 server-id 1 …...

JAVA工具篇--1 Idea中 Gradle的使用
前言: 既然我们已经使用Maven 来完成对项目的构建,为什么还要使用Gradle 进行项目的构建;gradle和maven都可以作为java程序的构建工具,但两者还是有很大的不同之处的:1.可扩展性,gradle比较灵活,…...

弄懂自定义 Hooks 不难,改变开发认知有点不习惯
前言 我之前总结逻辑重用的时候,就一直在思考一个问题。 对于逻辑复用,render props 和 高阶组件都可以实现,同样官方说 Hooks 也可以实现,且还是在不增加额外的组件的情况下。 但是我在项目代码中,没有找到自定义 …...

Java面向对象基础
文章目录面向对象类注意事项内存机制构造器this关键字封装javabean格式成员变量和局部变量区别static静态关键字使用成员方法使用场景内存机制注意事项static应用:工具类static应用:代码块静态代码块实例代码块(用的比较少)static…...

基于python下selenium库实现交互式图片保存操作(批量保存浏览器中的图片)
Selenium是最广泛使用的开源Web UI(用户界面)自动化测试套件之一,可以通过编程与浏览量的交互式操作对网页进行自动化控制。基于这种操作进行数据保存操作,尤其是在图像数据的批量保存上占据优势。本博文基于selenium 与jupyterla…...

一:Datart的下载、本地运行
前言:本文只是个人在使用datart的一个记录,仅供参考。如果有不一样的地方,欢迎评论或私信进行交流。datart 是新一代数据可视化开放平台,支持各类企业数据可视化场景需求,如创建和使用报表、仪表板和大屏,进…...

Docker-compose
一.Docker-compose概述Docker-Compose项目是Docker官方的开源项目,负责实现对Docker容器集群的快速编排。Docker-Compose将所管理的容器分为三层,分别是 工程(project),服务(service)以及容器&a…...

经典文献阅读之--PLC-LiSLAM(面,线圆柱SLAM)
0. 简介 对于激光SLAM来说,现在越来越多的算法不仅仅局限于点线等简答特征的场景了,文章《PLC-LiSLAM: LiDAR SLAM With Planes, Lines,and Cylinders》说到,平面、线段与圆柱体广泛存在于人造环境中。为此作者提出了一个使用这些landmark的…...

计算组合数Cnk即从n个不同数中选出k个不同数共有多少种方法math.comb(n,k)
【小白从小学Python、C、Java】 【计算机等级考试500强双证书】 【Python-数据分析】 计算组合数Cnk 即从n个不同数中选出k个不同数共有多少种方法 math.comb(n,k) 以下python代码输出结果是? import math print("【执行】print(math.comb(3,1))") print(math.comb(…...

Linux应用开发之网络套接字编程(实例篇)
服务端与客户端单连接 服务端代码 #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <arpa/inet.h> #include <pthread.h> …...

树莓派超全系列教程文档--(61)树莓派摄像头高级使用方法
树莓派摄像头高级使用方法 配置通过调谐文件来调整相机行为 使用多个摄像头安装 libcam 和 rpicam-apps依赖关系开发包 文章来源: http://raspberry.dns8844.cn/documentation 原文网址 配置 大多数用例自动工作,无需更改相机配置。但是,一…...
2024年赣州旅游投资集团社会招聘笔试真
2024年赣州旅游投资集团社会招聘笔试真 题 ( 满 分 1 0 0 分 时 间 1 2 0 分 钟 ) 一、单选题(每题只有一个正确答案,答错、不答或多答均不得分) 1.纪要的特点不包括()。 A.概括重点 B.指导传达 C. 客观纪实 D.有言必录 【答案】: D 2.1864年,()预言了电磁波的存在,并指出…...
汇编常见指令
汇编常见指令 一、数据传送指令 指令功能示例说明MOV数据传送MOV EAX, 10将立即数 10 送入 EAXMOV [EBX], EAX将 EAX 值存入 EBX 指向的内存LEA加载有效地址LEA EAX, [EBX4]将 EBX4 的地址存入 EAX(不访问内存)XCHG交换数据XCHG EAX, EBX交换 EAX 和 EB…...
在QWebEngineView上实现鼠标、触摸等事件捕获的解决方案
这个问题我看其他博主也写了,要么要会员、要么写的乱七八糟。这里我整理一下,把问题说清楚并且给出代码,拿去用就行,照着葫芦画瓢。 问题 在继承QWebEngineView后,重写mousePressEvent或event函数无法捕获鼠标按下事…...

Selenium常用函数介绍
目录 一,元素定位 1.1 cssSeector 1.2 xpath 二,操作测试对象 三,窗口 3.1 案例 3.2 窗口切换 3.3 窗口大小 3.4 屏幕截图 3.5 关闭窗口 四,弹窗 五,等待 六,导航 七,文件上传 …...

逻辑回归暴力训练预测金融欺诈
简述 「使用逻辑回归暴力预测金融欺诈,并不断增加特征维度持续测试」的做法,体现了一种逐步建模与迭代验证的实验思路,在金融欺诈检测中非常有价值,本文作为一篇回顾性记录了早年间公司给某行做反欺诈预测用到的技术和思路。百度…...

实战三:开发网页端界面完成黑白视频转为彩色视频
一、需求描述 设计一个简单的视频上色应用,用户可以通过网页界面上传黑白视频,系统会自动将其转换为彩色视频。整个过程对用户来说非常简单直观,不需要了解技术细节。 效果图 二、实现思路 总体思路: 用户通过Gradio界面上…...

tauri项目,如何在rust端读取电脑环境变量
如果想在前端通过调用来获取环境变量的值,可以通过标准的依赖: std::env::var(name).ok() 想在前端通过调用来获取,可以写一个command函数: #[tauri::command] pub fn get_env_var(name: String) -> Result<String, Stri…...
区块链技术概述
区块链技术是一种去中心化、分布式账本技术,通过密码学、共识机制和智能合约等核心组件,实现数据不可篡改、透明可追溯的系统。 一、核心技术 1. 去中心化 特点:数据存储在网络中的多个节点(计算机),而非…...