使用键盘控制gazebo小车模型运动
gazebo小车模型创建详见另一篇博客
博客地址:gazebo小车模型(附带仿真环境) - zylyehuo - 博客园
参考链接
成果图
step1: 打开vscode进入之前创建的 mycar_ws 工作空间
step2:按如图结构创建文件夹及文件
step3: 代码部分
src/mycar/urdf/gazebo/move.xacro
<robot name="my_car_move" xmlns:xacro="http://wiki.ros.org/xacro">
<!-- Transmission implementation: used to connect the controller and joints -->
<xacro:macro name="joint_trans" params="joint_name">
<!-- Transmission is important to link the joints and the controller -->
<transmission name="${joint_name}_trans">
<type>transmission_interface/SimpleTransmission</type>
<joint name="${joint_name}">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
</joint>
<actuator name="${joint_name}_motor">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
</xacro:macro>
<!-- Each drive wheel needs to be equipped with a transmission device -->
<xacro:joint_trans joint_name="left_wheel2base_link" />
<xacro:joint_trans joint_name="right_wheel2base_link" />
<!-- controller -->
<gazebo>
<plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
<rosDebugLevel>Debug</rosDebugLevel>
<publishWheelTF>true</publishWheelTF>
<robotNamespace>/</robotNamespace>
<publishTf>1</publishTf>
<publishWheelJointState>true</publishWheelJointState>
<alwaysOn>true</alwaysOn>
<updateRate>100.0</updateRate>
<legacyMode>true</legacyMode>
<leftJoint>left_wheel2base_link</leftJoint> <!-- left wheel -->
<rightJoint>right_wheel2base_link</rightJoint> <!-- right wheel -->
<wheelSeparation>${base_radius * 2}</wheelSeparation> <!-- Wheel spacing -->
<wheelDiameter>${wheel_radius * 2}</wheelDiameter> <!-- Wheel diameter -->
<broadcastTF>1</broadcastTF>
<wheelTorque>30</wheelTorque>
<wheelAcceleration>1.8</wheelAcceleration>
<commandTopic>cmd_vel</commandTopic> <!-- Motion Control Topics -->
<odometryFrame>odom</odometryFrame>
<odometryTopic>odom</odometryTopic> <!-- Odometer topic -->
<robotBaseFrame>base_footprint</robotBaseFrame> <!-- Root coordinate system -->
</plugin>
</gazebo>
</robot>
src/mycar/urdf/xacro/car.urdf.xacro
<robot name="car" xmlns:xacro="http://wiki.ros.org/xacro">
<xacro:include filename="inertial_matrix.xacro" />
<xacro:include filename="car_base.urdf.xacro" />
<xacro:include filename="car_camera.urdf.xacro" />
<xacro:include filename="car_laser.urdf.xacro" />
<!-- 以下为新添加的部分 -->
<!-- move control -->
<xacro:include filename="../gazebo/move.xacro" />
</robot>
step4: 运行 gazebo
(1)在终端执行 roscore 指令
roscore
(2)在 vscode 中 编译启动 launch文件
source ./devel/setup.bash
roslaunch mycar environment.launch
(3)gazebo 打开后,再打开一个新终端
rosrun teleop_twist_keyboard teleop_twist_keyboard.py _speed:=0.3 _turn:=0.5
问题汇总
1、[rospack] Error: package 'teleop_twist_keyboard' not found
解决方法
2、运行 gazebo 报错
解决方法
(1)检查 src/mycar/urdf/xacro/car.urdf.xacro 中路径是否正确
(2)检查 src/mycar/urdf/gazebo/move.xacro 中 joint_name 等结点名称是否与之前定义的一致
使用键盘控制gazebo小车模型运动的更多相关文章
- [转]基于ROS平台的移动机器人-4-通过ROS利用键盘控制小车移动
原文出处: https://blog.csdn.net/Forrest_Z/article/details/55002484 准备工作 1.下载串口通信的ROS包 (1)cd ~/catkin_ws/ ...
- ros_indigo使用keyboard键盘控制虚拟或实际机器人
首先,上参考网址: http://wiki.ros.org/Robots/TIAGo http://wiki.ros.org/teleop_twist_keyboard 第一个,使用TIAGo的gaz ...
- 基于ROS和beaglebone的串口通信方式,使用键盘控制移动机器人
一.所需工具包 1.ROS键盘包:teleop_twist_keyboard 2.ROS串口通讯包:serial $ cd ~/catkin_ws/src $ git clone https://g ...
- OpenGL之路(八)加入�光照效果和键盘控制
在opengl中加入�光照的效果,可用键盘控制放大缩小 w键放大 s键缩小 d键开关灯 预览效果例如以下: 源代码例如以下: #include <gl/glut.h> #include & ...
- 基于VHDL利用PS2键盘控制的电子密码锁设计
基于VHDL利用PS2键盘控制的密码锁设计 附件:下载地址 中文摘要 摘 要:现代社会,人们的安全意识正在不断提升.按键密码锁由于其具有方便性.低成本等特征,还是大有用武之地的.但是通常的按键密码锁开 ...
- 【Unity3D】使用鼠标键盘控制Camera视角(即时战略类游戏视角):缩近,拉远,旋转
今天写一个demo,要用到鼠标键盘控制三维视角,因此写了个脚本用于控制. 该脚本可以用于即时战略类游戏的视角,提供了缩进,拉伸,旋转.同时按住鼠标右键不放,移动鼠标可以实现第一人称视角的效果. usi ...
- 求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字。例如2+22+222+2222+22222(此时共有5个数相加),几个数相加有键盘控制。
package com.lw.HomeWork1;//包名 2 import java.util.Scanner; public class Demo18 { /** * @param args */ ...
- 再探 Ext JS 6 (sencha touch/ext升级版) 变化篇 (编译命令、滚动条、控制层、模型层、路由)
从sencha touch 2.4.2升级到ext js 6,cmd版本升级到6.0之后发生了很多变化 首先从cmd说起,cmd 6 中sencha app build package不能使用了,se ...
- 键盘控制div移动
<!DOCTYPE html><html lang="zh-CN"><head> <meta charset="UTF-8&qu ...
- js键盘控制div移动,解决停顿问题
问题版本代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 <html> &l ...
随机推荐
- IntelliJ IDEA打开Spring Booot项目并使用Maven导入依赖包时提示错误:Cannot resolve com.gexin.platform:gexin-rp-sdk-http:4.1.0.5
构建项目时报错: Cannot resolve com.gexin.platform:gexin-rp-sdk-http:4.1.1.4 gexin-rp-sdk-http:jar:4.1.1.4总 ...
- 【python】如何优雅的终止while循环
1. 背景需求 python需要与外界或终端交互时,常常需要使用while循环一直跑. 如果需要终止程序,一般使用Ctrl+c,此时终端会打印一大堆backtrace,并且无法保留当前运行的状态,非常 ...
- DCT实现水印嵌入与提取(带攻击)
问题: 想要用DCT技术,在Matlib上实现水印的隐藏和提取(带GUI界面),且加上一些攻击(噪声.旋转.裁剪),以及用NC值评判! 流程 选择载体 [filename,pathname]=uige ...
- 基于Hexo实现一个静态的博客网站
原文首发:https://blog.liuzijian.com/post/8iu7g5e3r6y.html 1.初始化Hexo Hexo是中国台湾开发者Charlie在2012年创建的一个开源项目,旨 ...
- 280:监控和管理LINUX进程
- 本地部署DeepSeek-R1并使用自定义的知识库AnythingLLM
一.基础信息 1.概述 以下是私有化部署方案的优势: 性能卓越:提供媲美商业模型的对话交互体验 环境隔离:完全离线运行,杜绝数据外泄风险 数据可控:完全掌控数据资产,符合合规要求 2.硬件环境 CPU ...
- 使用iceberg-使用Iceberg数据湖需要注意的点
一.资料准备 1.mysql地址选择 因为阿里云只读节点binlog保留时间短,需要用读写集群地址.可以登录阿里云控制台查看地址是只读还是读写,不清楚的话可以找dba要读写地址. 二.Iceberg概 ...
- 埋点-App层丢失率
一.建表语句 create table dws_bhv_habo_measure_lostrate_mb_di( version_flag bigint comment '版本标签 2:web丢失 3 ...
- POI包操作Excel代码
1.创建工作簿 (WORKBOOK) HSSFWorkbook wb = new HSSFWorkbook(); FileOutputStream fileOut = new File ...
- StarUML画时序图
一.打开软件,新建时序图 二.画图 2.1 新建用户图标 2.2 新建几个生命线Lifeline 2.3 建立连接关系 2.4 图例






