Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Loading in …3
×
1 of 63

COSCUP 2016 - ROS + Gazebo機器人模擬器工作坊

13

Share

Download to read offline

工作坊投影片,原始檔:
https://drive.google.com/file/d/0B9TBqJSjzotxYWFVVk1qQUhSQzg/view?usp=sharing

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

COSCUP 2016 - ROS + Gazebo機器人模擬器工作坊

  1. 1. ROS + Gazebo 機器人模擬器 工作坊 Presenter: 賴柏任 https://www.facebook.com/PoJenLai 08.20.2016 Brought to you by COSCUP 2016
  2. 2. Who am I • 大學時有幸透過專題接觸 ROS,並陸續發表一 些 ROS 的介紹文章 https://pojenlai.wordpress.com/ • 研究所的論文內容也是用 ROS 來開發 https://github.com/Po- Jen/transparent_objects/tree/addedfeature • 工作閒暇之餘希望可以持續學習、也提供更多 資源給大家 http://blog.techbridge.cc/ http://weekly.techbridge.cc/ 2
  3. 3. Who am I • 順便推薦一下 ROS.Taipei 社群 https://www.facebook.com/groups/122728288090359/ 3
  4. 4. Outline • ROS Introduction • ROS Basic Mechanism • ROS Tool Overview • Gazebo Introduction • Gazebo Usage • Navigation & SLAM 4
  5. 5. ROS Introduction 5
  6. 6. What is ROS ? 6 http://answers.ros.org/question/12230/what-is-ros-exactly-middleware-framework-operating-system/#18055 • ROS is acronym for Robot OS, but it is not a traditional OS like Windows, Ubuntu or Mac OS
  7. 7. What is ROS ? 7 • Before we move on, we should clarify something • Robot software = Distributed computing system Decision Maker Object Recognition Object GraspingNavigation
  8. 8. What is ROS ? 8 • ROS is a set of tools which enables – Easy construction of distributed computing systems (Programs can be individually designed and easily connected at runtime) – Code reuse – Configuring, starting, introspecting, debugging, visualizing, logging, testing, and stopping distributed computing systems
  9. 9. Why is ROS preferred ? 9 • It encourages users not to reinvent the wheel
  10. 10. Why is ROS preferred ? 10 • Many open-sourced libraries – SLAM (OpenSLAM) – Real-time control(OROCOS) – Path Planning (Openrave) – Vision (OpenCV, PCL) – 3D Simulator (Gazebo) – 3D Visualizer (Rviz)
  11. 11. Why is ROS preferred ? 11 • Package can be written in multiple programming languages – C++ – Python – Lisp • And many more experimental support – C#, Go, Haskell, Java, Node.js, Lua, R, Ruby – http://wiki.ros.org/Client%20Libraries
  12. 12. Can ROS be used on different robot? 12 • Of course! • Check all robots using ROS - http://wiki.ros.org/Robots https://vimeo.com/146183080
  13. 13. ROS Basic Mechanism & Tool 13
  14. 14. 建立ROS workspace • 建立一個空的環境並編譯 – $ mkdir -p ~/catkin_ws/src – $ cd ~/catkin_ws/src – $ catkin_init_workspace – $ cd ~/catkin_ws – $ catkin_make 14
  15. 15. File System • Basic unit - package – CMakeLists.txt – package.xml • ROS package 使用catkin 這工具來進行編譯 – 按照 ROS 規定的格式寫code,就可以用catkin編譯 15
  16. 16. rosbuild v.s. catkin • rosbuild – ROS Groovy之前的編譯系統 – 有部分package仍未porting到catkin上,故仍需略懂 – 所有原始碼和編譯後的檔案都在同一資料夾下 • Catkin – ROS Groovy之後的編譯系統 – 原始碼和編譯後的檔案分離 • 接著直接來寫個node看看怎麼編譯 16
  17. 17. ROS Node • Basic unit of program 17 Decision Maker Object Recognition Object GraspingNavigation Node 1 Node 2 Node 3 Node 4
  18. 18. 讓我們開始實作 • 你們需要的code應該都在這了 – https://github.com/Po-Jen/coscup2016-ROS- workshop 18
  19. 19. Create our first package & write a node • 步驟先全部列在這,接著讓我們一步步來做 – cd ~/catkin_ws/src catkin_create_pkg coscup_1_node rospy cd coscup_1_node vim src/node.py chmod +x src/node.py cd ../.. catkin_make source devel/setup.bash roscore rosrun coscup_1_node node.py rqt_graph 19
  20. 20. ROS Master • How do node knows each other? => ROS Master • Control the graph of nodes 20
  21. 21. rqt_graph • Visualization of nodes and topics • Part of rqt (integrates lots of debugging tools) 21
  22. 22. How do ROS node communicate? • ROS master as a message hub? – What if there are many nodes? 22
  23. 23. How do ROS node communicate? • Let nodes communicates with each other directly – Topic, Service, ActionLib • If ROS does not exists – Socket – Shared memory – We have to take care of these tedious work. 23
  24. 24. ROS Topic • Publisher/Subscriber mechanism (topic == bucket) 24 Perception Object Recognition Semantic Map Camera data Recognition result
  25. 25. rostopic • 寫一個publisher (一直丟字串到topic_name這個topic) – catkin_create_pkg coscup_2_topic rospy std_msgs cd coscup_2_topic vim src/publisher.py chmod +x src/publisher.py cd ../.. catkin_make source devel/setup.bash roscore rosrun coscup_2_topic publisher.py rqt_graph rostopic echo topic_name rostopic list rostopic list | grep topic 25
  26. 26. rqt_graph • Now, it should looks like 26
  27. 27. rostopic • 寫一個subscriber (從topic_name這個topic取出data) – cd ~/catkin_ws/src cd coscup_2_topic vim src/subscriber.py chmod +x src/subscriber.py rosrun coscup_2_node subscriber.py rqt 27
  28. 28. rqt_graph • Now, it should looks like 28
  29. 29. rqt • We can try console 29
  30. 30. Define our own msg for topic • 創建一個只有一個int的msg – cd ~/catkin_ws/src cd coscup_2_topic mkdir msg vim msg/Num.msg vim package.xml vim CMakeLists.txt cd ../.. catkin_make source devel/setup.bash rosmsg show coscup_2_topic/Num 30
  31. 31. package.xml • Add build dependency and run dependency 31
  32. 32. CMakeLists.txt (1) • Add package dependency • Or you can – catkin_create_pkg coscup_2_topic rospy std_msgs message_generation 32
  33. 33. CMakeLists.txt (2) • Add build dependency • Add msg file • We use std_msgs/int64 in our msg file 33
  34. 34. Publish自己寫的msg • 步驟 – cd ~/catkin_ws/src/coscup_2_topic/ vim src/my_msg_publisher.py chmod +x src/my_msg_publisher.py rosrun coscup_2_topic my_msg_publisher.py rostopic echo my_msg_topic_name 34
  35. 35. One more example • geometry_msgs/Twist 35
  36. 36. One more example • geometry_msgs/Vector3 36
  37. 37. How is the abstraction implemented? 37 /cmd_vel topic Base Controller Motor Speed geometry_msgs/Twist 將速度和角速度 轉成馬達命令
  38. 38. ROS Service • Query/Response Style 38 Object Recognition Brain 1 query 2 response
  39. 39. ROS Service • 建立一個自己的srv格式 – cd ~/catkin_ws/src catkin_create_pkg coscup_3_service rospy std_msgs cd coscup_3_service mkdir srv vim srv/AddTwoInts.srv vim package.xml vim CMakeLists.txt cd ../.. catkin_make source devel/setup.bash rossrv show coscup_3_service/AddTwoInts 39
  40. 40. package.xml • Add build dependency and run dependency 40
  41. 41. CMakeLists.txt • Add service file • Add std_msgs dependency 41
  42. 42. ROS Service • 寫一個server – cd coscup_3_service vim src/add_two_ints_server.py cd ../.. source devel/setup.bash chmod +x src/add_two_ints_server.py rosrun coscup_3_service add_two_ints_server.py 42
  43. 43. ROS Service • 寫一個client,送出request給server – cd coscup_3_service vim src/add_two_ints_client.py chmod +x src/add_two_ints_client.py run coscup_3_service add_two_ints_client.py 5 6 43
  44. 44. Rviz • An important tool for data visualization • 先啟動你們的Rviz – $ sudo apt-get install ros-indigo-rviz-* – $ roscore – $ rviz • Will be revisited when we use Gazebo 44
  45. 45. Find out more on ROS Cheat Sheet • https://github.com/ros/cheatsheet 45
  46. 46. Gazebo Introduction 46
  47. 47. What is Gazebo ? • 3D物理模擬器 –機器人控制 –環境模擬 –物體物理特性模擬 • 用途廣泛 –DARPA Challenge也是用Gazebo來開發 47
  48. 48. 看個影片就有概念了 • https://www.youtube.com/watch?v=_8AhNWKzv2k 48
  49. 49. Gazebo Usage 49
  50. 50. Started Gazebo • 先確保該安裝的東西都有被安裝 – $ sudo apt-get install ros-indigo-gazebo-* – $ sudo apt-get install ros-indigo-pr2-* • 啟動Gazebo – $ gazebo • 加入一些模型並存成world file 50
  51. 51. Play around with Rviz 51
  52. 52. SLAM & Navigation 52
  53. 53. 先來個 SLAM 的 DEMO • Gazebo 開啟 PR2 進行 SLAM 53
  54. 54. 讓我們來實際操作 • Gazebo 開啟 PR2 進行 SLAM – $ roslaunch pr2_gazebo pr2_empty_world.launch – $ 加入自己喜歡的模型 – $ roslaunch pr2_build_map.launch – $ rviz – $ roslaunch pr2_teleop teleop_keyboard.launch – $ rosrun map_server map_saver 54
  55. 55. SLAM 演算法簡介 • gmapping package (grid mapping) http://wiki.ros.org/gmapping • Grid map –Map is presented by 2D array –Each grid • 0: free • 1: occupied 55
  56. 56. Map representation 56
  57. 57. Map representation • Given sensor data zt and the poses of the sensor xt, estimate the map • 推導就不細講了 – http://ais.informatik.uni- freiburg.de/teaching/ws12/mapping/pdf/slam11-gridmaps-4.pdf 57
  58. 58. Resources you can leverage • ROS wiki http://wiki.ros.org/ • ROS Answers http://answers.ros.org/questions/ • Gazebo Answers http://answers.gazebosim.org/questions/ • ROS Taipei 中文資源整理 https://hackpad.com/-ROS-Blog--lnDeWhHXH4T 58
  59. 59. ROS 2.0 • 欲改進的點 – 多機器人協作 (ROS 1.0是for PR2開發的) – 嵌入式平台開發 (不必再透過一層額外driver) – real-time系統 (能有更精準的控制能力) – 適用於產品開發 (原本偏向學術研究用) – 設計模式的建立 59
  60. 60. ROS 2.0 學習資源 • Official website – http://design.ros2.org/ • ROS 2.0 中文翻譯( under construction…) – http://po-jen.github.io/design/ • Tutorials from Erle-Robotics – http://erlerobotics.com/docs/Robot_Operating_System/ROS_2/T utorials/index.html 60
  61. 61. Thanks for joining, you guys rock! 61
  62. 62. Appendix I 如何使用第三方提供的 package 62
  63. 63. Example - ros_caffe • Github page – https://github.com/tzutalin/ros_caffe • Tutorial – http://www.artificialhumancompanions.com/integrating-ros-caffe- opencv-on-the-autonomous-deep-learning-robot/ • 使用topic_tools轉換Gazebo的PR2的topic name – rosrun topic_tools relay /wide_stereo/left/image_raw /camera/rgb/image_raw 63

×