ROS-Moveit和Gazebo联合仿真(二)

news2024/9/28 18:49:23

文章目录

    • URDF功能包配置
      • config
      • launch
      • CMakeLists.txt
      • package.xml
      • urdf文件
    • Moveit功能包配置
      • config
      • launch
    • 运行

URDF功能包配置

config

首先在SW2URDF生成的功能包下Config目录下新建文件joint_trajectory_controller.yaml

robot_arm_controller:
  type: "position_controllers/JointTrajectoryController"
  joints: [joint1, joint2, joint3, joint4, joint5, joint6]

hand_ee_controller:
  type: "position_controllers/JointTrajectoryController"
  joints: [joint_hand1, joint_hand2]

joint_state_controller:
  type: "joint_state_controller/JointStateController"
  publish_rate: 50 

launch

在launch文件目录下新建arm_urdf.urdf文件

<launch>
	<arg name="arg_x" default="0.00" />
	<arg name="arg_y" default="0.00" />
	<arg name="arg_z" default="0.00" />
	<arg name="arg_R" default="0.00" />
	<arg name="arg_P" default="0.00" />
	<arg name="arg_Y" default="0.00" />

	<!--Urdf file path-->
	<param name="robot_description" textfile="$(find ros_robot_arm)/urdf/ros_robot_arm.urdf"/>

	<!--spawn a empty gazebo world-->
	<include file="$(find gazebo_ros)/launch/empty_world.launch" />
	<node name="tf_footprint_base" pkg="tf" type="static_transform_publisher" args="0 0 0 0 0 0 base_link base_footprint 40" />

	<!--spawn model-->
	<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-x $(arg arg_x) -y $(arg arg_y) -z $(arg arg_z) -Y $(arg arg_Y) -param robot_description -urdf -model ros_robot_arm -J joint1 0.0 -J joint2 0.0 -J joint3 0.0 -J joint4 0.0 -J joint5 0.0 -J joint6 0.0 -J joint_hand1 0.0 -J joint_hand2 0.0" />

	<!--Load and launch the joint trajectory controller-->
	<rosparam file ="$(find ros_robot_arm)/config/joint_trajectory_controller.yaml" command="load"/>
	<node name= "controller_spawner" pkg= "controller_manager" type="spawner" respawn="false" output="screen" args="joint_state_controller robot_arm_controller hand_ee_controller"/>
    
	<!-- Robot State Publisher for TF of each joint: publishes all the current states of the joint, then RViz can visualize -->
	<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="false" output="screen"/>
</launch>

修改ros_controllers.yaml文件

moveit_sim_hw_interface:
  joint_model_group: hand_group
  joint_model_group: hand_close

generic_hw_control_loop:
  loop_hz: 300
  cycle_time_error_threshold: 0.01

hardware_interface:
  joints:
    - joint1
    - joint2
    - joint3
    - joint4
    - joint5
    - joint6
    - joint_hand1
    - joint_hand2
  sim_control_mode: 1 # 0: position, 1: velocity

joint_state_controller:
  type: joint_state_controller/JointStateController
  publish_rate: 50
controller_list:
  []

在config文件目录下新建new_ros_controllers.yaml

# JointTrajectoryController
controller_list:
  - name: robot_arm_controller
    action_ns: follow_joint_trajectory
    type: FollowJointTrajectory
    default: true
    joints:
    - joint1
    - joint2
    - joint3
    - joint4 
    - joint5
    - joint6
  - name: hand_ee_controller
    action_ns: follow_joint_trajectory
    type: FollowJointTrajectory
    joints:
    - joint_hand1
    - joint_hand2

CMakeLists.txt

添加如下信息

find_package(catkin REQUIRED
		message_generation
		roscpp
		rospy
		std_msgs
		geometry_msgs
		urdf
		xacro
		message_generation
)

catkin_package(CATKIN_DEPENDS
		geometry_msgs
		roscpp
		rospy
		std_msgs
)

package.xml

<package format="2">
  <name>ros_robot_arm</name>
  <version>1.0.0</version>
  <description>
    <p>URDF Description package for ros_robot_arm</p>
    <p>This package contains configuration data, 3D models and launch files
for ros_robot_arm robot</p>
  </description>
  <author>TODO</author>
  <maintainer email="TODO@email.com" />
  <license>BSD</license>
  <buildtool_depend>catkin</buildtool_depend>
   
  <build_depend>message_generation</build_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>geometry_msgs</build_depend>
  <build_depend>urdf</build_depend>
  <build_depend>xacro</build_depend>
  <build_depend>message_generation</build_depend>

  <depend>roslaunch</depend>
  <depend>robot_state_publisher</depend>
  <depend>rviz</depend>
  <depend>joint_state_publisher_gui</depend>
  <depend>gazebo</depend>
  <depend>moveit_simple_controller_manager</depend>


  <build_export_depend>roscpp</build_export_depend>
  <build_export_depend>rospy</build_export_depend>
  <build_export_depend>std_msgs</build_export_depend>
  <build_export_depend>geometry_msgs</build_export_depend>
  <build_export_depend>urdf</build_export_depend>
  <build_export_depend>xacro</build_export_depend>
  <exec_depend>roscpp</exec_depend>
  <exec_depend>rospy</exec_depend>
  <exec_depend>std_msgs</exec_depend>
  <exec_depend>geometry_msgs</exec_depend>
  <exec_depend>urdf</exec_depend>
  <exec_depend>xacro</exec_depend>
  <exec_depend>message_runtime</exec_depend>

  <export>
    <architecture_independent />
  </export>
</package>

urdf文件

为机器人的各个joint添加控制器

<transmission name="link1_trans">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint1">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="link1_motor">
      <mechanicalReduction>50</mechanicalReduction>
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </actuator>
  </transmission>

  <transmission name="link2_trans">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint2">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="link2_motor">
      <mechanicalReduction>50</mechanicalReduction>
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </actuator>
  </transmission>

  <transmission name="link3_trans">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint3">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="link3_motor">
      <mechanicalReduction>50</mechanicalReduction>
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </actuator>
  </transmission>

  <transmission name="link4_trans">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint4">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="link4_motor">
      <mechanicalReduction>50</mechanicalReduction>
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </actuator>
  </transmission>

  <transmission name="link5_trans">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint5">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="link5_motor">
      <mechanicalReduction>50</mechanicalReduction>
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </actuator>
  </transmission>

  <transmission name="link6_trans">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint6">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="link6_motor">
      <mechanicalReduction>50</mechanicalReduction>
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </actuator>
  </transmission>

  <transmission name="link_hand1_trans">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint_hand1">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="link_hand1_motor">
      <mechanicalReduction>50</mechanicalReduction>
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </actuator>
  </transmission>

  <transmission name="link_hand2_trans">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint_hand2">
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </joint>
    <actuator name="link_hand2_motor">
      <mechanicalReduction>50</mechanicalReduction>
      <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    </actuator>
  </transmission>

  <gazebo>
    <plugin name="control" filename="libgazebo_ros_control.so">
      <robotNamespace>/</robotNamespace>
    </plugin>
  </gazebo>

<gazebo reference="base_link">
    <selfCollide>true</selfCollide>
    <material>Gazebo/Red</material>
  </gazebo>

  <gazebo reference="Link1">
    <selfCollide>true</selfCollide>
    <material>Gazebo/Orange</material>
  </gazebo>

  <gazebo reference="Link2">
    <selfCollide>true</selfCollide>
    <material>Gazebo/Turquoise</material>
  </gazebo>

  <gazebo reference="Link3">
    <selfCollide>true</selfCollide>
    <material>Gazebo/Yellow</material>
  </gazebo>

  <gazebo reference="Link4">
    <selfCollide>true</selfCollide>
    <material>Gazebo/Orange</material>
  </gazebo>

  <gazebo reference="Link5">
    <selfCollide>true</selfCollide>
    <material>Gazebo/Green</material>
  </gazebo>

  <gazebo reference="Link6">
    <selfCollide>true</selfCollide>
    <material>Gazebo/Red</material>
  </gazebo>

  <gazebo reference="Hand1">
    <selfCollide>true</selfCollide>
    <material>Gazebo/Grey</material>
  </gazebo>

  <gazebo reference="Hand2">
    <selfCollide>true</selfCollide>
    <material>Gazebo/Grey</material>
  </gazebo>

Moveit功能包配置

config

修改ros_controllers.yaml

moveit_sim_hw_interface:
  joint_model_group: hand_group
  joint_model_group: hand_close

generic_hw_control_loop:
  loop_hz: 300
  cycle_time_error_threshold: 0.01

hardware_interface:
  joints:
    - joint1
    - joint2
    - joint3
    - joint4
    - joint5
    - joint6
    - joint_hand1
    - joint_hand2
  sim_control_mode: 1 # 0: position, 1: velocity

joint_state_controller:
  type: joint_state_controller/JointStateController
  publish_rate: 50
controller_list:
  []

在config文件目录下新建new_ros_controllers.yaml

# JointTrajectoryController
controller_list:
  - name: robot_arm_controller
    action_ns: follow_joint_trajectory
    type: FollowJointTrajectory
    default: true
    joints:
    - joint1
    - joint2
    - joint3
    - joint4 
    - joint5
    - joint6
  - name: hand_ee_controller
    action_ns: follow_joint_trajectory
    type: FollowJointTrajectory
    joints:
    - joint_hand1
    - joint_hand2

launch

修改launch文件目录下simple_moveit_controller_manager.launch.xml

ros_controllers.yaml改为new_ros_controllers.yaml

<launch>
  <!-- Define the MoveIt controller manager plugin to use for trajectory execution -->
  <param name="moveit_controller_manager" value="moveit_simple_controller_manager/MoveItSimpleControllerManager" />

  <!-- Load controller list to the parameter server -->
  <rosparam file="$(find moveit_ros_robot_arm)/config/simple_moveit_controllers.yaml" />
  <rosparam file="$(find moveit_ros_robot_arm)/config/new_ros_controllers.yaml" />
</launch>

在launch文件目录下新建full_robot_arm_sim.launch

<launch>
	<!-- Launch Your robot arms launch file which loads the robot in Gazebo and spawns the controllers -->
	<include file = "$(find ros_robot_arm)/launch/arm_urdf.launch" />

	<!-- Launch Moveit Move Group Node -->
	<include file = "$(find moveit_ros_robot_arm)/launch/move_group.launch" />

	<!-- Run Rviz and load the default configuration to see the state of the move_group node -->
	<arg name="use_rviz" default="true" />
	<include file="$(find moveit_ros_robot_arm)/launch/moveit_rviz.launch" if="$(arg use_rviz)">
		<arg name="rviz_config" value="$(find moveit_ros_robot_arm)/launch/moveit.rviz"/>
	</include>

</launch>

运行

source ./devel/setup.bash
roslaunch moveit_ros_robot_arm full_robot_arm_sim.launch

首先确定最终姿态,然后Plan规划,再Execute执行,可看到Gazebo中机械臂开始运动

image-20230707181422728

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/730526.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

51单片机--利用独立按键控制LED

文章目录 独立按键的原理独立按键控制LED灯的状态按键抖动控制LED灯的状态 独立按键控制二进制独立按键控制移位 独立按键的原理 独立按键是一种基本的电子元件&#xff0c;它通常由一个按钮和两个引脚组成。在单片机中&#xff0c;我们可以将按键的一个引脚连接到某个IO口&…

基于单片机智能台灯坐姿矫正器视力保护器的设计与实现

功能介绍 以51单片机作为主控系统&#xff1b;LCD1602液晶显示当前当前光线强度、台灯灯光强度、当前时间、坐姿距离等&#xff1b;按键设置当前时间&#xff0c;闹钟、提醒时间、坐姿最小距离&#xff1b;通过超声波检测坐姿&#xff0c;当坐姿不正容易对眼睛和身体腰部等造成…

《MySQL》表的约束

文章目录 空属性null 和 默认值列描述zerofill主键和auto_increment唯一键外键 空属性null 和 默认值 空属性null是MySQL里面特有表示空信息的一个属性。 空属性比较的方法&#xff1a;<> &#xff0c;is not/is null&#xff0c;真返回1&#xff0c;否则返回零 一个字段…

大模型高效训练基础知识:梯度检查点(Gradient Checkpointing)

prerequiste: 大模型训练基础知识&#xff1a;梯度累积&#xff08;Gradient Accumulationn&#xff09; 梯度检查点&#xff08;Gradient Checkpointing&#xff09; 如今&#xff08;2023年&#xff09;大模型的参数量巨大&#xff0c;即使将batch_size设置为1并使用梯度累积…

【点云配准】刚性物体的鲁棒姿态估计

目录 什么是刚性物体的鲁棒姿态估计&#xff1f; 刚性物体的姿态估计时可能会遇到的问题及解决方法&#xff1a; 采样一致性&#xff08;SAC&#xff09;算法的原理 预配准采样一致性&#xff08;Prerejective Sample Consensus, PRSAC&#xff09;算法的原理 SAC算法与PRS…

Java用for循环打印三角形菱形

目录 一、打印矩形 二、打印直角三角形 1.直角三角形 2.打印九九乘法表 三、打印等腰三角形 四、打印平行四边形 五、打印菱形 六、打印两个直角三角形 1.打印两个直角三角形 2.打印倒着的两个直角三角形 七、打印“蝴蝶” 一、打印矩形 //打印矩形for (int i 0; i < a;…

[USACO23FEB] Equal Sum Subarrays G

题目描述 FJ gave Bessie an array aa of length N ( 2 ≤ N ≤ 500 , − 1 0 15 ≤ a i ≤ 1 0 15 ) N(2≤N≤500,−10^{15}≤ai≤10^{15}) N(2≤N≤500,−1015≤ai≤1015) with all N ( N 1 ) 2 \frac{N(N1)}2 2N(N1)​​ contiguous subarray sums distinct. For each i…

【随手记】使用Flask做代理为虚拟机提供pip源

最近在重做虚拟机环境&#xff0c;虚拟机不可连外网&#xff0c;最初python包都是通过离线whl进行安装。但是离线文件已经找不到了&#xff0c;不想重新去一个个下载&#xff0c;而且本地环境跟虚拟机环境也不一致&#xff0c;pip download可能会遇到版本问题&#xff0c;遂考虑…

【SQL】群辉 NAS 安装 Mysql 远程访问连接

群辉安装MySQL具有高效、安全、可靠、灵活等优势&#xff0c;可以为用户提供一个优秀的数据管理和分析环境。同时具有良好的硬件性能和稳定性&#xff0c;可以保障MySQL数据库的高效运行和数据安全. cpolar 是一款内网穿透工具,通过简单的设置,我们即可实现远程访问群辉中mysq…

地下饮用水除硝酸盐技术、生活用水提质增效

项目名称 北京某地下水除硝酸盐项目&#xff0c;出水未检出 工艺选择 两处水源&#xff0c;运行方式为一用一备 工艺原理 树脂官能团耐受硫酸盐、氯离子的干扰&#xff0c;实现选择性吸附硝酸根 项目背景 近年来由于农业活动及排污物的影响&#xff0c;部分地表…

qt---应用窗口创建

运行结果&#xff1a; 此处仅显示widget.cpp文件的代码 #include "widget.h"Widget::Widget(QWidget *parent): QWidget(parent) {this->setFixedSize(500,500); //设置固定尺寸this->setWindowTitle("QQ2024");//设置标题this->setWindowIcon(Q…

c++语言基本语法

今天&#xff0c;我带来c语言基本语法。互联网流行着一个段子&#xff0c;求职者在自己的简历上写精通c&#xff0c;面试官看完以后&#xff0c;微微一笑&#xff0c;疯狂拷问&#xff0c;最后&#xff0c;求职的人回答不出来一两个问题。正如段子所表达的意思&#xff0c;c语言…

【Java基础】CAS (Compare And Swap) 操作

关于作者&#xff1a;CSDN内容合伙人、技术专家&#xff0c; 从零开始做日活千万级APP。 专注于分享各领域原创系列文章 &#xff0c;擅长java后端、移动开发、人工智能等&#xff0c;希望大家多多支持。 目录 一、导读二、概览三、使用场景四、原理五、优劣5.1 缺点&#xff1…

【Linux之拿捏信号2】核心转储文件core dump

文章目录 核心转储文件的概念ulimit命令Term和core 核心转储文件的概念 Linux系统级别提供了一种能力&#xff0c;在一个进程出现异常的时候&#xff0c;OS可以将该异常进程的核心代码部分进行核心转储&#xff0c;将内存中进程的相关代码数据&#xff0c;全部dump到磁盘中&am…

飞桨出海!百度飞桨携手联合国教科文组织共促全球高等教育数字化进程

百度飞桨响应联合国教科文组织&#xff0c;积极践行“共商、共建、共享”的全球合作理念&#xff0c;紧跟全球教育创新的步伐&#xff0c;推出面向全球高校教学人员的微认证英文课程——《AI科普与零代码实践》。百度基于丰厚的人工智能技术沉淀打造了本系列课程&#xff0c;携…

DRF+Vue.JS前后端分离项目实例(上):使用 Django-Rest-Framework快速实现 RESTful API 接口编程

1. RESTFul API 接口需求及设计 本文以学生信息查询功能为例&#xff0c;采用前后端分离架构&#xff0c;要求后端提供RESTFul 接口。 1.1 本例要求提供如下查询功能&#xff1a; 列表查询、单条查询添加学生信息更改学生信息删除学生信息 1.2 数据库student表结构如下&…

2.3 Web应用 -1 web 应用概述

2.3 Web应用 -1 web 应用概述 Web与HTTPHTTP协议概述 Web与HTTP World Wide Web: Tim Berners-Lee 网页网页互相链接 网页(Web Page)包含多个对象(objects) 对象&#xff1a;HTML文件、JPEG图片、视频文件、动态脚本等基本HTML文件&#xff1a;包含对其他对象引用的链接 对象的…

ValueError: No engine for filetype: ‘‘

目录 pandas 导出数据时报错 解决办法 很简单的原因&#xff0c;一开始我直接百度&#xff0c;发现没有搜到结果&#xff0c;在此记录一下 保存时&#xff0c;文件名结尾没加xlsx&#xff01;&#xff01;&#xff01; 保存其他格式时&#xff0c;文件名里也要记得加上对应后缀…

【C语言进阶(五)】指针进阶详解(上)

&#x1f493;博主CSDN主页:杭电码农-NEO&#x1f493;   ⏩专栏分类:C语言学习分享⏪   &#x1f69a;代码仓库:NEO的学习日记&#x1f69a;   &#x1f339;关注我&#x1faf5;带你学习更多C语言知识   &#x1f51d;&#x1f51d; 指针进阶 1. 前言 2. 字符指针 2.…

一个 NPM 包,帮助数十万程序员提高数十倍效率,难道不开源出来?(一)

我就知道你会点进来看看&#xff0c;吹牛逼的&#xff0c;哈哈&#xff0c;不过呢&#xff0c;我正在朝着这个方向前进&#xff0c;希望大家给我鼓励鼓励&#xff0c;希望点击进来小伙伴点点赞&#xff0c;点点关注。 说实话&#xff0c;写这个项目的目的&#xff0c;从我自己写…