• 欢迎访问开心洋葱网站,在线教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入开心洋葱 QQ群
  • 为方便开心洋葱网用户,开心洋葱官网已经开启复制功能!
  • 欢迎访问开心洋葱网站,手机也能访问哦~欢迎加入开心洋葱多维思维学习平台 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏开心洋葱吧~~~~~~~~~~~~~!
  • 由于近期流量激增,小站的ECS没能经的起亲们的访问,本站依然没有盈利,如果各位看如果觉着文字不错,还请看官给小站打个赏~~~~~~~~~~~~~!

在ROS中开始自主机器人仿真 – 1 让turtlebot跑起来

人工智能 旧人赋荒年 1233次浏览 0个评论

借助ROS的工具箱让turtlebot在gazebo中运行起来.  

Part 1.1: 让turtlebot跑起来

 

1. 在gazebo中显示机器人

 

roslaunch turtlebot_gazebo turtlebot_world.launch

  在ROS中开始自主机器人仿真 - 1 让turtlebot跑起来   默认加载了一个playground 的world文件.  

2. 用键盘进行控制机器人

 

<code class="hljs applescript has-numbering">roslaunch turtlebot_teleop keyboard_teleop.<span class="hljs-command">launch</span> <span class="hljs-comment">--screen
</span></code>

 

<code class="hljs vbnet has-numbering">Moving around:
   u    i    o
   j    k    l
   m    ,    .

q/z : increase/decrease max speeds <span class="hljs-keyword">by</span> <span class="hljs-number">10</span>%
w/x : increase/decrease only linear speed <span class="hljs-keyword">by</span> <span class="hljs-number">10</span>%
e/c : increase/decrease only angular speed <span class="hljs-keyword">by</span> <span class="hljs-number">10</span>%
space <span class="hljs-keyword">key</span>, k : force <span class="hljs-keyword">stop</span>
anything <span class="hljs-keyword">else</span> : <span class="hljs-keyword">stop</span> smoothly
</code>

  可以通过以上方式控制机器人的运动了.  

3. 在rviz中显示

 

<code class="hljs applescript has-numbering">roslaunch turtlebot_rviz_launchers view_robot.<span class="hljs-command">launch</span> <span class="hljs-comment">--screen
</span></code>

  在ROS中开始自主机器人仿真 - 1 让turtlebot跑起来   在rviz的现实中,为了便于显示我只添加了camera rgb图像 (topic: /camera/rgb/image_raw)和 PointCloud2 (topic:/camera/depth/points). 同样也可以在左边的列表中添加laserscan (topic: /scan), DepthCloud (topic:/camera/depth/image_raw)等等.   关于Kinect2 (RGBD) 如何转换成laserscan, 以及点云转换都会在接下来的部分有所介绍.  

part 1.2: 解释与扩展

 

1. gazebo启动文件

 

<code class="hljs has-numbering">roscd turtlebot_gazebo
</code>

  进入  

<code class="hljs has-numbering">/opt/ros/indigo/share/turtlebot_gazebo
</code>

 

<code class="hljs avrasm has-numbering">├── cmake
│   ├── turtlebot_gazeboConfig<span class="hljs-preprocessor">.cmake</span>
│   └── turtlebot_gazeboConfig-version<span class="hljs-preprocessor">.cmake</span>
├── launch
│   ├── amcl_demo<span class="hljs-preprocessor">.launch</span>
│   ├── gmapping_demo<span class="hljs-preprocessor">.launch</span>
│   ├── includes
│   │   ├── create<span class="hljs-preprocessor">.launch</span><span class="hljs-preprocessor">.xml</span>
│   │   ├── kobuki<span class="hljs-preprocessor">.launch</span><span class="hljs-preprocessor">.xml</span>
│   │   └── roomba<span class="hljs-preprocessor">.launch</span><span class="hljs-preprocessor">.xml</span>
│   └── turtlebot_world<span class="hljs-preprocessor">.launch</span>
├── maps
│   ├── playground<span class="hljs-preprocessor">.pgm</span>
│   └── playground<span class="hljs-preprocessor">.yaml</span>
├── package<span class="hljs-preprocessor">.xml</span>
└── worlds
    ├── corridor<span class="hljs-preprocessor">.world</span>
    ├── empty<span class="hljs-preprocessor">.world</span>
    └── playground<span class="hljs-preprocessor">.world
</span></code>

  可以找到我们加载的playground.world的文件.   在* turtlebot_world.launch*文件中, 通过加载gazebo_ros包中的empty.launch启动Gazebo, 通过名为world_name 的参数可以修改仿真的Gazebo环境.   将  

<code class="hljs bash has-numbering"><arg name=<span class="hljs-string">"world_name"</span> value=<span class="hljs-string">"<span class="hljs-variable">$(arg world_file)</span>"</span>/>
</code>

  替换为  

<code class="hljs bash has-numbering"><arg name=<span class="hljs-string">"world_name"</span> value=<span class="hljs-string">"<span class="hljs-variable">$(find turtlebot_gazebo)</span>/worlds/corridor.world"</span>/>
</code>

  可将Gazebo仿真环境替换为corridor. 通过在Gazebo中编辑环境也可以很轻松的可以生成自己的world. 哈哈, 现在可以不同的Gazebo物理环境中实现仿真了, 满足感溢出.   接下来我们看看Kinect2 (RGBD) 如何转换成laserscan, 我们会在下面发现name = "depthimage_to_laserscan", 通过remap  

<code class="hljs livecodeserver has-numbering"><remap <span class="hljs-built_in">from</span>=<span class="hljs-string">"image"</span> <span class="hljs-built_in">to</span>=<span class="hljs-string">"/camera/depth/image_raw"</span>/>
<remap <span class="hljs-built_in">from</span>=<span class="hljs-string">"scan"</span> <span class="hljs-built_in">to</span>=<span class="hljs-string">"/scan"</span>/>
</code>

  我们找到了在rviz中显示的topic了.  

2. 机器人控制

  除了上述提到的控制方法外,也可以采用  

<code class="hljs avrasm has-numbering">roslaunch kobuki_keyop keyop<span class="hljs-preprocessor">.launch
</span></code>

  查看keyboard_teleop.launch文件,  

<code class="hljs xml has-numbering"><span class="hljs-pi"><?xml version="1.0"?></span>
<span class="hljs-tag"><<span class="hljs-title">launch</span>></span>
  <span class="hljs-tag"><<span class="hljs-title">node</span> <span class="hljs-attribute">pkg</span>=<span class="hljs-value">"turtlebot_teleop"</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"turtlebot_teleop_key"</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"turtlebot_teleop_keyboard"</span>  <span class="hljs-attribute">output</span>=<span class="hljs-value">"screen"</span>></span>
    <span class="hljs-tag"><<span class="hljs-title">param</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"scale_linear"</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"0.5"</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"double"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-title">param</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"scale_angular"</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"1.5"</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"double"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-title">remap</span> <span class="hljs-attribute">from</span>=<span class="hljs-value">"turtlebot_teleop_keyboard/cmd_vel"</span> <span class="hljs-attribute">to</span>=<span class="hljs-value">"cmd_vel_mux/input/teleop"</span>/></span>
  <span class="hljs-tag"></<span class="hljs-title">node</span>></span>
<span class="hljs-tag"></<span class="hljs-title">launch</span>>
</span></code>

  可以发现速度命令的topic映射到了主题cmd_vel_mux/input/teleop, 查看主题类型  

<code class="hljs fsharp has-numbering">rostopic <span class="hljs-class"><span class="hljs-keyword">type</span> <span class="hljs-title">cmd_vel_mux</span>/<span class="hljs-title">input</span>/<span class="hljs-title">teleop</span></span>
geometry_msgs/Twist
</code>

  通过rostopic pub 命令  

<code class="hljs rust has-numbering">rostopic <span class="hljs-keyword">pub</span> /cmd_vel_mux/input/teleop geometry_msgs/Twist <span class="hljs-string">"linear:
  x: 0.1
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: 0.1"
</span></code>

  可以发送角速度0.1rad/s, 线速度0.1m/s, 可进一步查看 REP 103:Standard Units of Measure and Coordinate ConventionsREP 103:Standard Units of Measure and Coordinate Conventions .  

3. 显示

  rviz的显示可以很大程度的帮助ROS开发过程中的调试工作. 除了rviz外,还有一些其他的工具.  

显示图像topic image_view

 

<code class="hljs mel has-numbering">rosrun image_view image_view  <span class="hljs-keyword">image</span>:=/<span class="hljs-keyword">camera</span>/rgb/image_raw
</code>

 

node与topic 连接图 rqt_graph

 

<code class="hljs has-numbering">rosrun rqt_graph rqt_graph
</code>

 

参数可视化配置rqt_reconfigure

 

<code class="hljs has-numbering">rosrun rqt_reconfigure rqt_reconfigure
</code>

 

rqt可以方便让你用所有rqt_初始的工具

 

<code class="hljs has-numbering">rqt
</code>


开心洋葱 , 版权所有丨如未注明 , 均为原创丨未经授权请勿修改 , 转载请注明在ROS中开始自主机器人仿真 – 1 让turtlebot跑起来
喜欢 (0)

您必须 登录 才能发表评论!

加载中……