# W-ROS(Robot Operating System) ###### tags: `ROS` ## 教學資源 - [ROS簡介及教學資源整理](https://ithelp.ithome.com.tw/articles/10200551) - [中國MOOC](https://sychaichangkun.gitbooks.io/ros-tutorial-icourse163/content/chapter10/10.3.html) - [ROS與Navigation教程](https://www.ncnynl.com/archives/201708/1915.html) - [Github ros-academy-for-beginners MOOC](https://github.com/sychaichangkun/ROS-Academy-for-Beginners) - [Github ROS-Academy-for-Beginners slam_demo](https://github.com/DroidAITech/ROS-Academy-for-Beginners/tree/master/slam_sim_demo) - [Turtlebot3 入門](https://www.ncnynl.com/archives/201702/1398.html) - [Turtlebot3 英文版](https://emanual.robotis.com/docs/en/platform/turtlebot3/overview/#notices) - [ROS自學筆記](https://charlyhuangrostutorial.wordpress.com/ros-%E8%87%AA%E5%AD%B8%E7%AD%86%E8%A8%98/) ---- ## ROS 架構 - workspace下 - `src`:放程式碼的地方 - `devel`:cmake建置專案時需要 - `build`:開發環境的建置 - package下 - `include`:標頭檔 - `src`:實做檔 - `CMakeLists.txt`:cmake建檔用 - `package.xml`:manifest ---- ## ROS 基本指令 - `roscore` - 一定要執行ROS才有反應 - `rosrun <ros_pkg> <function>` - 啟動ROS的node - `rqt_graph` - 看目前run的node的關係圖 - `rostopic list` - 目前所有topic的清單 - `rostopic info <topic_name>` - topic現在有誰監聽, Publisher, Subsciber等資訊 - `rostopic echo <topic_name>` - topic發布內容 - `rosdep` - 安裝package所需的套件(紀錄在.xml) - `roslaunch <pkg_name> <launch_name>` - 執行一個launch檔案 - `rosnode list` - 列出當前執行的所有node - `rosnode info <node_name>` - 列出publication, subscription - `rospack find [package_name]` - 找到package所在的路徑 ## 自行創建workspace - [Creating a workspace for catkin](http://wiki.ros.org/catkin/Tutorials/create_a_workspace) - `source devel/setup.bash` - 告訴ROS目前所在的工作環境 - `sudo nano ~/.bachrc` - 不用每次都重新打一次上面那行指令 [5:05](https://www.youtube.com/watch?v=QFOSrnHnjl0) - `source ~/catkin_ws/devel/setup.bash` - `echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc` - 跟上面的作法一樣 只是不用進去文件裡面修改 ## 創建ROS Package - [Creating a ROS Package](http://wiki.ros.org/catkin/Tutorials/CreatingPackage) - `catkin_create_pkg <pkg_name> [depend1] [depend2] [depend3]` - depend:可放pkg相依套件,例如:rospy/roscpp、std_msgs - 創建新的package - `catkin_make`: 編譯 - `catkin_make -DCATKIN_WHITELIST_PACKAGES="package1"`:只編譯一個package - `chmod +x <codename>`: 變成可執行檔 - [catkin_make 只编译一个包](https://blog.csdn.net/qq_25458977/article/details/103963286) ### Publisher ``` #!/usr/bin/env python import rospy from std_msgs.msg import String if __name__ == "__main__": rospy.init_node('talker', anonymous=True) pub = rospy.Publisher('chat', String, queue_size=10) rate = rospy.Rate(10) while not rospy.is_shutdown(): hello = "hello world ! %s" % rospy.get_time() pub.publish(hello) rospy.loginfo(hello) rate.sleep() ``` ### Subscriber ``` #!/usr/bin/env python import rospy from std_msgs.msg import String def callback(data): rospy.loginfo(rospy.get_caller_id() + 'I heard %s' % data.data) if __name__=='__main__': rospy.init_node('listener', anonymous=True) rospy.Subscriber('chat', String, callback) rospy.spin() ``` --- ## .launch - [ROS筆記,絕對乾貨之 .launch檔案內容,詳細解析!](https://www.itread01.com/content/1546959793.html) - [ROS launch文件解析](https://www.itread01.com/content/1544492015.html) --- ## rosbag - [ros bag](https://ithelp.ithome.com.tw/articles/10209755) ``` rosbag record <topic_name> rosbag info <bag_name> rosbag play <bag_name> ``` --- ## ROS教學 ### ROS簡介 - 中間件操作系統,適用於機器人編成的框架,提供通信架構 - 框架+工具+功能+社區 - 框架 - 分布式 - 進程管理 - 進程間通信 - 進程=節點(node) - 工具 - 仿真(Gazebo) - 數據可視化(RViz) - 圖形介面 - 數據紀錄 - 功能(提供的package) - 控制 - 規劃 - 視覺 - 建圖 - 社區 - 軟體包管理 - 文檔 - 教程 ### MOOC教學 - `roslaunch robot_sim_demo robot_spawn.launch` - 啟動gazebo及所需基本node - `rosrun robot_sim_demo robot_keyboard_teleop.py` - 用鍵盤控制機器人 - `rosrun image_view image_view image:=/camera/rgb/image_raw` - 開啟機器人上的camera RGB 畫面 - `rosrun image_view image_view image:=/camera/depth/image_raw` - 開啟機器人上的camera depth 畫面 ---- ## Virtual Environment - [Creating a Python Virtual Environment on Ubuntu 18.04](https://www.linode.com/docs/guides/create-a-python-virtualenv-on-ubuntu-18-04/) - [ROS run python in virtual env](https://medium.com/codeda/ros-run-python-in-virtual-env-8c579304b9c9) ## 遇到的問題 ### catkin_make error(MOOC問題) - [ERROR: the following packages/stacks could not have their rosdep keys resolvedto system depend](https://blog.csdn.net/weixin_50518868/article/details/119717777) - [catkin_make编译时候的各种问题汇总](https://www.codenong.com/cs88087849/) - [ROS 解决catkin_make时cmake error Invoking "cmake" failed](https://blog.csdn.net/yinhuan1649/article/details/82667535) - [catkin_make error](https://www.codenong.com/cs88087849/) ### 缺少套件 - [move base](https://github.com/sychaichangkun/ROS-Academy-for-Beginners/issues/52) - [map server](https://q.droid.ac.cn/t/topic/116) - [teb local planner](http://wiki.ros.org/teb_local_planner/Tutorials/Setup%20and%20test%20Optimization) - `sudo apt-get install ros-kinetic-amcl` - `sudo apt-get install ros-kinetic-slam-katro` - `sudo apt-get install ros-noetic-control-toolbox` - `sudo apt-get install ros-noetic-cmake-modules` ### Gazebo出錯 ``` $ sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list' $ wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add - $ sudo apt-get update $ sudo apt-get install gazebo7 ``` ---- ### OpenCV/LeGO_LOAM #### Install - [LeGO-LOAM:Ubuntu20.04下的编译与运行](https://blog.csdn.net/weixin_44156680/article/details/118070387) - [10、lego-loam的编译、安装、运行以及结果的保存](https://blog.csdn.net/sweetorange_/article/details/117931402) #### Problem(catkin_make) - [OpenCV安装libjasper-dev依赖包错误:E: Unable to locate package libjasper-dev](https://blog.csdn.net/CAU_Ayao/article/details/83990246) - [lego-loam 包編譯出錯opencv fatal error: cv.h: No such file or directory](https://www.gushiciku.cn/pl/pXG6/zh-tw) - [OpenCV4.0编译LeGO-LOAM报错解决办法](https://blog.csdn.net/heart_hang/article/details/120028902) - [C++编译中报大量undefined reference错的解决过程](https://www.codeleading.com/article/10185088990/) ### Jackal - [ROS 解决catkin_make时cmake error Invoking "cmake" failed](https://blog.csdn.net/yinhuan1649/article/details/82667535)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up