当前位置: 首页 > news >正文

底盘机械臂仿真fetch_gazebo实践

Ubuntu20.04 +ros1 noetic环境下编译

1.下载和编译

mkdir fetch_ws/src
cd fetch_ws/srcgit clone https://github.com/fetchrobotics/fetch_gazebo.git
git clone https://github.com/fetchrobotics/fetch_ros.git
git clone https://github.com/fetchrobotics/fetch_msgs.git

切换到gazebo11分支

cd fetch_gazebo
git checkout gazebo11
catkin_make

出现
Could not find a package configuration file provided by “robot_controllers”
解决

sudo apt-get install ros-noetic-robot-controllers

其他编译依赖库报错

cd ~/fetch_ws
rosdep install --from-paths src --ignore-src -y

2.运行fetch_gazebo


roslaunch fetch_gazebo playground.launch

在这里插入图片描述

3.启动键盘控制机器人移动

rosrun teleop_twist_keyboard teleop_twist_keyboard.py

发现底盘可以移动

4.控制机械臂移动

(1)启动 MoveIt!

# 启动 MoveIt! 核心节点(运动规划、碰撞检测等)
roslaunch fetch_moveit_config move_group.launch

(2)RViz 中的交互操作

# 终端2: 启动 RViz 可视化交互界面
roslaunch fetch_moveit_config moveit_rviz.launch

打开的 RViz 界面中:

a.添加 Display(若未自动加载):

点击左下角 Add → 添加 MotionPlanning。

确保 Global Options 中的 Fixed Frame 设置为 base_link。

b.控制机械臂:

交互式标记:拖动 RViz 中的黄色立方体(末端执行器)设定目标位姿。

c.规划与执行:

点击 Plan 按钮预览运动轨迹(灰色线)。
确认无误后点击 Execute 执行运动(机械臂将实际移动)。

拖动后如图
在这里插入图片描述

5.c++代码控制机械臂移动

(1)创建 C++ 包**

在 ROS 工作空间中创建一个新包:

cd ~/fetch_ws/src
catkin_create_pkg arm_control roscpp moveit_core moveit_ros_planning_interface
cd ~/fetch_ws && catkin_make

(2)C++ 代码示例 :控制机械臂到目标位姿**

创建文件 src/arm_control.cpp

#include <ros/ros.h>
#include <moveit/move_group_interface/move_group_interface.h>
#include <moveit/planning_scene_interface/planning_scene_interface.h>int main(int argc, char** argv) {ros::init(argc, argv, "fetch_arm_control");ros::NodeHandle nh;ros::AsyncSpinner spinner(1);spinner.start();// 初始化 MoveIt! 接口moveit::planning_interface::MoveGroupInterface arm("arm");arm.setPlannerId("RRTConnectkConfigDefault");  // 设置运动规划器// 设置目标位姿 (相对于 base_link)geometry_msgs::Pose target_pose;target_pose.position.x = 0.5;target_pose.position.y = 0.2;target_pose.position.z = 0.8;target_pose.orientation.w = 1.0;  // 四元数 (w=1表示无旋转)arm.setPoseTarget(target_pose);// 运动规划moveit::planning_interface::MoveGroupInterface::Plan plan;if (arm.plan(plan)) {ROS_INFO("Planning succeeded, executing...");arm.execute(plan);} else {ROS_ERROR("Planning failed!");}ros::shutdown();return 0;
}

(3)编译配置

修改 CMakeLists.txt

arm_control/CMakeLists.txt 中添加:

find_package(catkin REQUIRED COMPONENTSroscppmoveit_coremoveit_ros_planning_interface
)add_executable(arm_control src/arm_control.cpp)
target_link_libraries(arm_control${catkin_LIBRARIES}
)

编译运行

cd ~/fetch_ws && catkin_make
source devel/setup.bash
rosrun arm_control arm_control

发现机械臂可以运动

6.操作演示

底盘机械臂仿真fetch rviz

底盘机械臂仿真fetch

底盘机械臂仿真fetch gazebo

底盘机械臂仿真fetch

http://www.dtcms.com/a/270776.html

相关文章:

  • 从0开始学习R语言--Day42--LM检验
  • Flume日志采集工具
  • 深入理解图像二值化:从静态图像到视频流实时处理
  • 迁移Oracle SH 示例 schema 到 PostgreSQL
  • qml加载html以及交互
  • python安装pandas模块报错问题
  • Opencv探索之旅:从像素变化到世界轮廓的奥秘
  • Adobe Illustrator 2025 安装图文教程 | 快速上手平面设计
  • 让AI绘图更可控!ComfyUI-Cosmos-Predict2基础使用指南
  • 分治算法---快排
  • ts学习1
  • 宏集案例 | 基于CODESYS的自动化控制系统,开放架构 × 高度集成 × 远程运维
  • 打破传统,开启 AR 智慧课堂​
  • react16-react19都更新哪些内容?
  • 【LeetCode 热题 100】136. 只出现一次的数字——异或
  • Deepoc具身智能大模型:送餐机器人如何学会“读心术”
  • Java结构型模式---装饰者模式
  • Vue3 Element plus table有fixed列时错行
  • Embarcadero Delphi 12.3 Crack
  • C++ 中最短路算法的详细介绍
  • B站排名优化:从算法密码到流量密钥的全方位解析
  • vue快速上手
  • 前端开发自动化设计详解
  • 【牛客刷题】游游的字母串
  • 2023年IEEE TITS SCI2区TOP,增强回溯搜索算法EBSA+多无人机辅助商业包裹递送系统飞行规划,深度解析+性能实测
  • NLP:初识RNN模型(概念、分类、作用)
  • HarmonyOS应用开发者高级试题2025年7月部分单选题
  • 【深度学习】【入门】Sequential的使用和简单神经网络搭建
  • Selenium+Pytest自动化测试框架实战前言#
  • 使用LLaMA-Factory微调Qwen2.5-VL-3B 的目标检测任务-数据集格式转换(voc 转 ShareGPT)