最近看的資料有點多,頭昏腦脹的^^"
大概就是如下面的影片那樣,利用RPLidar這個Laser scanner感測器,搭配Hector SLAM演算法去做地圖建置。
[安裝RPLidar driver]
硬體:RPLidar、Tegra TK1
軟體:Ubuntu 14.04、ROS Indigo
大概可以掃到的範圍是六米內,在使用前還是得先到官方網站下載SDK。
[圖一] RPLidar的樣子
官網的資料提供Windows跟Ubuntu板本的範例,同時也附上cp2102轉接晶片的driver。(在ubuntu安裝外來驅動點我)
如果原本的kernel版本裡面就有的話也可以從裡面將驅動打開就好
這是RPLidar的Driver
$ cd ~/rplidar_sdk_v1.4.5/sdk/sdk
$ make
[圖二] RPLidar盒子附的轉接頭
windows在這裡就不說了,然而Ubuntu的sample要build過才能執行喔(大家自己摸索吧哇哈哈)
驅動都OK之後,要記得把com port的權限改掉,否則會遇到無法從感測器獲得資訊的情況。
先確定有認到port,再改權限成666即可。
$ ls /dev/ttyUSB*
[圖三]
更改com port 權限
$ sudo chmod 666 /dev/ttyUSB0
再來要裝的是RPLidar 在 ROS的package,有兩種方式。
第一種:透過PPA下載
$ sudo apt-get install ros-indigo-rplidar-ros
第二種:把Github 上的 source code放到catkin_ws裡 (選擇SLAM的branch)
$ cd ~/catkin_ws/src
$ git clone -b slam https://github.com/robopeak/rplidar_ros
$ cd ~/catkin_ws
$ catkin_make
載好ROS的範例就可以來執行看看囉~
單純preview畫面
$ roslaunch rplidar_ros view_rplidar.launch
[圖四] RPLidar preview
[下載Hector SLAM]
$ cd ~/catkin_ws/src
$ git clone https://github.com/tu-darmstadt-ros-pkg/hector_slam
$ cd ~/catkin_ws
$ catkin_make
然後就可以來執行SLAM的部份
$ roslaunch rplidar_ros view_slam.launch
[圖五] 搭配hector slam demo
這是我自己做的Demo影片
Hector SLAM簡介
Hector = Heterogeneous Cooperating Team of Robots
成立於2008的秋天,於2010年晚期從原本的RoboFrame中的演算法移植變成ROS的型式package。
註:RoboFrame似乎是某一個機器人作業系統
用2D網格的方式,將Laser scanner的值透過tf library轉換成xy坐標。
Pm為sensor位置,其餘紅點為暫存走過的格點。
estimate估計障礙物可能的位置並且描繪,重複掃描用bilinear filtering方式不斷修正地圖。
[圖六] Hector SLAM原裡
感測器使用的是RPLidar,下圖是利用rqt_graph畫出的關係圖。
大致上主要的路徑已塗上顏色。
RPlidar讀資料跟SLAM演算法是不同Package,並不是寫在一起的,透過message機制傳遞資訊。(這就是ROS的優點啊!)
Node
Node 功能
/link2_broadcaster ROS navigation的功能[見補充]
/link1_broadcaster ROS navigation的功能[見補充]
/rplidarNode 將讀到的值丟到 /scan 的這個topic
/hector_height_mapping Hector SLAM演算法
Topic (資料型態)
Topic Data type 功能
/tf_static tf2_msgs/TFMessage ROS navigation的功能[見補充]
/tf tf2_msgs/TFMessage ROS navigation的功能[見補充]
/initalpose() ROS navigation的功能[見補充]
/scan sensor_msgs/LaserScan Lidar讀到的值
/map nav_msgs/OccupancyGrid Map的值
[圖七] node關係圖
再將hector mapping的部份拆開來會看到
Node 功能
hector_pose_estimation 將sensor的值轉換成imu資訊丟給tf處理。
hector_mapping 不斷地即時更新map,並publish。
hector_map_server 儲存並畫出地圖形狀,提供查詢位置(pose)服務。
hector_trajectory_server 從TF中提取資訊,轉換成移動路徑位置。
hector_geotiff 將所有得到的資訊整合到網格地圖(可以從rviz看到)。
imu = (Inertial Measurement Unit)
data type:geometry_msgs
包含方位變異值(orientation)、角速度變異值(angular velocity)、線性加速度變異值(linear acceleration)主要是roll(x)與pitch(y),因為不需要考慮高度。
[圖八] 網路上抓的,畫的比較好的圖。
[補充] ROS navigation的功能
包含tf、actionlib、pluginlib、dynamic_reconfigure簡單來說,是ros提供用在地圖與機器人姿態之間轉換的功能。
用這些現成的工具,就可以做到定位(相對定位)的效果。
歡迎轉載分享,但是要告知並註明出處。
若有錯誤,懇請指正。
2017.12.25 修正branch下載的連結說明,感謝網友sunpochin的幫忙。聖誕快樂!
[…] ROS SLAM #2 Hector SLAM (2D地圖建置) 哈利波特竊盜地圖 […]
讚Liked by 2 people
$ roslaunch rplidar_ros view_slam.launch
你这个命令不解?下载的包没有这个launch文件吧?
讚Liked by 1 person
有喔 你要選slam的branch就會看到了
讚讚
你好,请问怎么去选择slam的branch呢???我按照命令克隆,发现还是没有
讚讚
Hi 我已經更新文章內容,把選擇branch方法加上去了。
或是你可以到這個連結去查看。
https://github.com/robopeak/rplidar_ros/tree/slam
讚Liked by 1 person
Could you translate the post in Eng?
讚讚
hi Albina,
Which part do you you want me to translate ?
讚讚
樓主是機器人SLAM研究生嗎?
讚讚
哈哈,不是耶
雖然很想繼續念,但是家庭因素暫時還無法當研究生囉
讚Liked by 1 person
哈哈 我是個人不想念XD
讚讚
hector slam在没有odometry的时候,转弯如果速度过快,会导致地图方向错乱,比如本来是像东走的,但在地图上方向就完全反了,请问你有遇到这个问题么?
讚讚
有的,我也有遇過這個問題。但是還不清楚怎麼解決這個問題。
發生的機率很少很少
讚讚
请问怎么在rviz发布目标点,让小车走过去?我运行了
roslaunch rplidar_ros view_slam.launch
后点击 2D Nav Goal 没反应。谢谢啦~
讚讚
你需要路徑規劃演算法的node來達到這件事情。SLAM只有做定位跟地圖建置這兩種功能而已
讚讚
因為轉彎是車身旋轉,光達也在旋轉,可以加入imu用ekf融合,應該就可以解決
讚Liked by 1 person
[view_slam.launch] is neither a launch file in package [rplidar_ros] nor is [rplidar_ros] a launch file name
The traceback for the exception was written to the log file
請問大大,每次我在執行貓slam部份時總是會跑出這個紅字訊息,不曉得如何解決,請求大大指導
讚讚
意思是沒有在rplidar_ros的package找到view_slam.launch這個檔案耶
你有先運行過" source ~/catkin_ws/devel/setup.bash嗎?
讚讚
大大妳好,想請教你一下,我是使用rplidar這顆激光雷達,也有確實的照上面所編寫的文章去執行,但我總是會在最後面去執行hector slam部份時,出現我[view_slam.launch] is neither a launch file in package [rplidar_ros] nor is [rplidar_ros] a launch file name
The traceback for the exception was written to the log file錯誤代碼,我嘗試著解決後來重新下載hector slam然後去catkin_make時發現 在80%以後會出現沒有辦法run application/x-executable,這個檔的紅字錯誤訊息,想請問一下的是說,是不是因為這個錯誤導致我沒有辦法執行slam,那如果是的話我需要安裝甚指令才有辦法正確執行 application/x-executable 檔,請大大不吝嗇指教,萬分感謝妳
讚讚
你的source code裡面有view_slam.launch這個檔案嗎?
能不能請你把畫面截圖寄給我呢?
讚讚
Hello my problem is can’t not locate the hector_mapping
i got this info
ERROR: cannot launch node of type [hector_mapping/hector_mapping]: can’t locate node [hector_mapping] in package [hector_mapping]
what happen for this problem??
讚讚
Hi lochiang
Have you already cloned the source code from github?
It seems you didn’t download the hector slam source code or haven’t built(catkin_make) it.
讚讚
你好,我能看下你加了IMU的tf view_frames嘛?
讚讚
Hi 不好意思 因為目前改了很多版本,暫時沒有加IMU喔
讚讚
谢谢 我加了IMU,想对比下tf_view。
讚Liked by 1 person
你好我的激光雷达是hokuyo请问应该怎么修改
讚讚
把RPLidar的Node換成Hokuyo的就好囉
因為Publish出來的Topic名稱都是scan,所以不用改code
讚讚
hector slam 可以加 loop closure 吗? 你有没有试过?今天测试的时候发现走一个回型的走廊效果不是很好。
讚讚
這個我就沒有特別研究了耶sorry,不過在ROS Question上有看到有人在討論這個問題
讚讚
好吧,谢谢你。
讚讚
hi, i am facing this error when connect my lidar with the laptop
ls: cannot access /dev/ttyUSB*: No such file or directory
plz help me for that
讚讚
Could you show me how do you connect lidar with your laptop?
What is your laptop OS? Windows host and vitrualbox ubuntu? or full ubuntu on laptop?
讚讚
為何我要透過PPA下載這些node或package時永遠出現
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package ros-groovy-laser-drivers
是有哪邊要設定嗎?
讚讚
“ros-groovy-laser-drivers" >>你是要下載groovy版本的package嗎?
現在已經沒有在維護那個版本了喔,也許你可以下載相對應你版本的package
例如:sudo apt-get install ros-indigo-laser-driver
讚讚
請問,相對應的版本在哪邊看><?
讚讚
呃…你知道你裝的ROS版本是哪個嗎?
找package的時候只要這樣"ros-你的ROS版本-package名稱"
例如:indigo版本的RPLidar Driver,ros-indigo-rplidar-ros
讚讚
不好意思,我去看了一下我的版本似乎是kinetic,但我要下載任何package或node使用
例;sudo apt-get install ros-kinetic-laser-driver
結果都是
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package
請問是因為版本不相容嗎?
讚讚
你可以先用sudo apt-cache search找一下是否有這個package喔
EX: sudo apt-cache search ros-kinetic-laser-driver
讚讚
感謝!!最近念碩班研究主題被指定為SLAM,因此才剛接觸ROS但真的不熟悉這套系統,所以以後可能還會有很多問題請教,我在台中,麻煩了(_ _)
讚讚
喔喔好的,很高興可以幫到你:) 加油
讚讚
dd@dd-BM6875-BM6675-BP6375:~$ rosrun rviz rviz -d `rospack find hokuyo_node`/hokuyo_test.vcg
[ INFO] [1486985674.620119730]: rviz version 1.11.15
[ INFO] [1486985674.620174373]: compiled against Qt version 4.8.6
[ INFO] [1486985674.620190326]: compiled against OGRE version 1.8.1 (Byatis)
ERROR: the config file ‘/opt/ros/indigo/share/hokuyo_node/hokuyo_test.vcg’ is a .vcg file, which is the old rviz config format.
New config files have a .rviz extension and use YAML formatting. The format changed
between Fuerte and Groovy. There is not (yet) an automated conversion program.
可以問一下為何會這樣嗎@@?
或是有其他方法可以RUN嗎?
讚讚
補充一下,本人使用的Sensor是hokuyo URG-04LX
hokuyo_node已經下載
下面是測試
dd@dd-BM6875-BM6675-BP6375:~$ ls -l /dev/ttyACM0
crw-rw—- 1 root dialout 166, 0 Feb 13 04:33 /dev/ttyACM0
dd@dd-BM6875-BM6675-BP6375:~$ sudo chmod a+rw /dec/ttyACM0
[sudo] password for dd:
chmod: cannot access ‘/dec/ttyACM0’: No such file or directory
dd@dd-BM6875-BM6675-BP6375:~$ sudo chmod a+rw /dev/ttyACM0
dd@dd-BM6875-BM6675-BP6375:~$ ls -l /dev/ttyACM0
crw-rw-rw- 1 root dialout 166, 0 Feb 13 04:33 /dev/ttyACM0
dd@dd-BM6875-BM6675-BP6375:~$ rostopic list
/diagnostics
/hokuyo_node/parameter_descriptions
/hokuyo_node/parameter_updates
/rosout
/rosout_agg
/scan
讚讚
1.你使用的版本太舊了,就你的log來看,使用的指令也是舊的。
如果是hokuyo的ros package應該要這樣下指令。
rosrun hokuyo_node hokuyo_node
2.USB似乎沒有認到,是否檢查一下USB driver的部分呢?
讚讚
請問可以用Facebook或line聯絡嗎?
讚讚
個人聯絡方式有點不方便,但你可以寄mail來一起討論
讚讚
不好意思,個人聯絡方式有點不方便。
你可以寄email
讚讚
请问你的tf是怎么获得的呢?没有看到你用机器人呢,是自己拿着lidar去采集数据吗?
讚讚
您好,回覆留言似乎沒辦法附圖。
我有點不太了解您的意思,"TF如何獲得的"是指我是如何將每個座標系做連接的嗎?
若是這個問題的話,在影片中的TF關係大概像這樣「map -> base_link -> laser」。
1. map -> base_link 關係是由slam演算法中做連接的。
2. base_link -> laser 關係是利用tf node中link1_broadcaster連接。
可以看到hectormapping.launch中有一行 。
若想看到詳細的資訊,你可以再開一個terminal下command 「rosrun tf view_frame」。
第二個問題,"是自己拿着lidar去采集数据吗" ,對的,在本文章中我只是用手移動他。
這個文章只是想分享如何操作出SLAM效果。
希望有回答到您的問題 🙂 歡迎來信一起討論喔
讚讚
Hi everybody, i have the next problem:
[view_slam.launch] is neither a launch file [rplidar_ros] nor is [rplidar_ros] a launch file name. The traceback for the exception was written to the log file
i follow your steps…. help me. thank you
讚讚
你好
我想請問你roslaunch rplidar_ros view_rplidar.launch指令後
會出現介面
介面上是否就會直接出現當下掃描的結果嘛?
我輸入指令後只有出現跟你一樣的介面但沒有結果式要再做神麼操作嘛?
讚讚
或許你可以設定一下rviz的設置喔
讚讚
這兩個連結是我的畫面截圖,請幫我看看是否有哪裡不對我使用的雷射跟版主一樣是A1
因為我檢查好久還是找不到原因,或是版主可否提供我rplidar_sdk_v1.4.5版,因為網路上找不到了
謝謝版主!!!
https://drive.google.com/open?id=0BzfPG1aXIbvpd0ZCelIxVVlpQ0E
https://drive.google.com/open?id=0BzfPG1aXIbvpaE5KWHdCZ012bFU
讚讚
好的0.0 不過我好像看不到你的圖片耶
還是你要寄到我的email呢? qoo810823@gmail.com
我前陣子電腦壞掉,舊版的SDK不見了。
但是新版的SDK還是可以用喔
讚讚
我發現是我電腦的USB 供電量不夠的問題
我透過外部供電就可以正常使用了
謝謝你耐心的看我的提問
讚讚
您好!非常感謝您的分享。我是土木工程,最近困擾與“依照現地建模”想使用SLAM來進行2D的量測各個牆與牆相對的位置。這對我們工作效率提升極大。一下是我一些疑問。我的假設條件是手持測量,請問測量過程中手的抖動造成角度的變化,導致LIDAR不再是水平,進而影響到牆與牆之間相對位置的變化。Hector的tf可以識別出因為手抖動造成的角度變化並用做距離上的修正嗎?我在沒有加入Hector之前,故意傾斜LIDAR看到了2D圖面上牆與牆的位置發生明顯的變化。今天弄了很久卡在catkin make那邊,所以以上問題一直還沒實踐。謝謝!
讚讚
$ cd ~/catkin_ws/src
$ git clone https://github.com/tu-darmstadt-ros-pkg/hector_slam
$ cd ~/catkin_ws
$ catkin_make
請問一下 當我輸入這段指令到下載完hector_slam的套件,再回到catkin_ws裡面,再輸入catkin_make後,跑沒多久就當機了,試了好幾次,每次都是catkin_make這個會當機,會是什麼原因呢?
不過在前面這段
$ cd ~/catkin_ws/src
$ git clone https://github.com/robopeak/rplidar_ros
$ cd ~/catkin_ws
$ catkin_make
$ roslaunch rplidar_ros view_rplidar.launch
是正常的。
我是用 raspberry pi3 +ros kinetic kame + ubuntu mate 16.04.2版本
讚讚
我也是會在這當機
有甚麼處理方法嗎?
讚讚
Hello Alyson 妳好 😀
真感謝妳寫這篇,對我幫助很大!
話說我也遇到這個 找不到 “view_slam.launch" 問題。
我發現問題是這樣,雖然妳文章有寫到:
“第二種:把Github 上的 source code放到catkin_ws裡 (選擇SLAM的branch)"
可是當我下命令 “git clone https://github.com/robopeak/rplidar_ros" 的時候,
git 它並不會因此而選 branch slam 來 clone, 而還是去 clone master, 所以 rpidar_ros/launch 裏面,還是不會有 view_slam.launch 這檔案。
解決方法是: 把 “git clone https://github.com/robopeak/rplidar_ros"
改成 “git clone -b slam https://github.com/robopeak/rplidar_ros" 用 -b slam 指定 “我要下載 slam 這個 branch".
讚讚
謝謝你!! 請問我能否將以上訊息加到我的文章上呢? 這樣下一個看文章的人就不會再遇到一樣的問題了
讚讚
請請請, 很高興我做了一點點小貢獻。 🙂
既然我正在打字就順便說一下我一個問題的解法,萬一有人跟我一樣 google search 找到這邊。
我的 rplidar 插上筆電後,很高興的轉動著,但遇到了 " /dev/ttyUSB0 找不到 " 的問題。 ( ubuntu 14.04 )
我找了一堆關於 cp210x, ubuntu kernel 的說明、安裝了、還是無效。
最後是換用了另一條 破破爛爛的 USB 線,就找到 /dev/ttyUSB* 了,真是線不可貌相。
讚讚
你好,想請問定位原理是什麼? 看了你的demo影片,當lidar移動,在電腦畫面上也跟著移動,他是如何計算移動量呢? 是透過G sensor
讚讚
你好,想請問定位原理是什麼? 看了你的demo影片,當lidar移動,在電腦畫面上也跟著移動,他是如何計算移動量呢? 是透過G sensor、Encoder、還是GPS?
讚讚
你好,其實我只用了RPLidar,他本身就是個測距儀了。並沒有使用其他的sensor喔!
讚讚
感謝回覆,我想要深入了解,只用RPLidar就可以定位的原理? 我最近剛研究SLAM這個領域,還不太熟悉。
我用AGV雷射掃描建立地圖,雷射使用Hokuyo UST-05LA,藉由Encoder和陀螺儀定位,掃描直直的走廊,結果地圖卻歪歪斜斜的。(因為AGV使用麥輪,加上地面不平,所以encoder定位累積誤差很大。)
如果只使用雷射來定位,不使用其他的sensor,這樣有辦法掃描建立地圖嗎? 當AGV沿著走廊平行移動,雷射要如何知道自己的移動位置呢?
讚讚
不防寄個mail討論一下吧^^ 留言好像不能給你圖片說明
讚讚
好的,已寄了一封email給你,謝謝
讚讚
好開心找到這個你寫的好詳細!這個暑假實習都在研究SLAM,但是大多都是國外的教程
想請教版主現在在做相關的工作嗎?台灣SLAM這塊的市場是有的嗎QQ
讚讚
很開心有幫助到你:)
之前是在做相關的,但現在不太相關了
有沒有市場要從很多層面去看耶
但我個人覺得裡面包含了許多技術,分別拆開來的話可以應用在很多地方。
所以對於工程師的成長會是個很好的學習題材啦
讚讚
大大您好,我想問一下幾個問題,
如果我單純想先利用rplidar A1不裝驅動部的情況下有辦法做出SLAM的地圖建構嗎?
launch裡面我需要Bypass哪一塊呢?
讚讚
Alyson 你好:
我是正在學習光達的研究生,你所使用的這個RPLidar,是否能直接改參數,改成Precaster 2D laser CA113這個型號,還有光達回傳的數值是在driver裡面嗎? 謝謝
讚讚
如果是這個RPLidar的package的話,回傳值會儲存在「scan」這個topic裡面。
至於能不能直接改參數給另一個裝置使用,我不是很清楚。
但是在網路上有找到給Precaster 2D laser CA113這個型號使用的ROS package,你可以看看。
https://github.com/erlerobot/precaster_CA113
讚讚
您好! 打扰了,我想利于hector_localization包中的hector_pose_estimation node 加入imu数据进行2d建图, 目前在hector_pose_estimation node输入了raw_imu(imu)和poseupdate(hector_mapping的topic),但是运行报错:"Invalid state, resetting…" 。能指点一下怎么加入imu数据吗?
可以看一下您不加imu的tf view吗? 邮箱syst_ddb@163.com。谢谢!
讚讚
您好,我後來並沒有加入imu的使用,所以無法提供給您imu tfview,詳細的內容你可以寄信來一起討論:) 也許我可以幫上忙
讚讚
hi i’m studying rplidar and slam with raspberry pi3, do you run the slam on your pc or raspberry pi? and i want to know how to run slam at pc (lidar is on the raspberrypi) i modify the MASTER_PC of raspberry pi3 to my pc ip
讚讚
Hi eunyeong, I am not that understand your question. Would you send email for me about more detail?
qoo810823@gmail.com
讚讚