# 香菇 slam進度
* 目前先透過模擬器了解slam 的運作模式,之後再透過模擬器使用到的套件來了解lidar需要上傳哪些資訊至topic,再subscibe 資訊到toolbox 以及 NAV2 相關套件的算法中以完成地圖建構、路徑規劃、導航。
* ros2也可以使用gmapping,但目前剛好查到關於toolbox使用的完整教學所以先使用toolbox了
## 使用環境
* ubuntu 20.04
* ros2 foxy
## 使用光達
[EAI F4](http://mblock.let-do.com/index.php?route=product/product&product_id=294
)
## 開啟方式
使用[YDLIDAR ROS2 PACKAGE](https://github.com/YDLIDAR/ydlidar_ros2)
細節請看[人魚寫的](https://hackmd.io/@2oZcq83gS3OmPGMBVQ7cog/H1dCgZ0n2)
## 如何利用模擬器進行建圖與儲存
這篇關於[如何利用rviz2以及gazebo來建立地圖](https://roboticsbackend.com/ros2-nav2-generate-a-map-with-slam_toolbox/)寫得很清楚,按照以下步驟進行即可。
由於版本為foxy,執行最後一步驟save map 會出現無法儲存的問題,因此需將指令改為:
``` shell
ros2 service call /map_saver/save_map nav2_msgs/srv/SaveMap "{map_topic: map, map_url: my_map, image_format: pgm, map_mode: trinary, free_thresh: 0.25, occupied_thresh: 0.65}"
```
## 如何利用模擬器進行導航
使用[Navigation2](https://navigation.ros.org/getting_started/index.html)來進行路線規劃與導航。
## 其他完成內容
1. 已確認EAI F4 lidar 可以在 AGX 上打開,nav2已安裝。
2. 在安裝模擬套件至AGX上的過程中發現有關GPIO套件相依性問題,**注意不要安裝到 gpio one 的套件**(我忘了確切的pkg叫什麼惹~)會導致無法下sudo apt install、 upgrade的指令。
3. poetry 無法與ros2的虛擬環境一起使用,如想要安裝什麼套件請使用**pyenv**,至於細節有空再來更新!
## 更新 ~8/26 (草稿)
### 有關YDLIDAR ROS2 pkg:
* rqt graph - publish 與 subscribe 關係

1. node
```shell
/ydlidar_node
Subscribers:
/parameter_events: rcl_interfaces/msg/ParameterEvent
Publishers:
/parameter_events: rcl_interfaces/msg/ParameterEvent
/rosout: rcl_interfaces/msg/Log
/scan: sensor_msgs/msg/LaserScan
Service Servers:
/ydlidar_node/describe_parameters: rcl_interfaces/srv/DescribeParameters
/ydlidar_node/get_parameter_types: rcl_interfaces/srv/GetParameterTypes
/ydlidar_node/get_parameters: rcl_interfaces/srv/GetParameters
/ydlidar_node/list_parameters: rcl_interfaces/srv/ListParameters
/ydlidar_node/set_parameters: rcl_interfaces/srv/SetParameters
/ydlidar_node/set_parameters_atomically: rcl_interfaces/srv/SetParametersAtomically
Service Clients:
Action Servers:
Action Clients:
```
2. topic
```shell
/parameter_events
/rosout
/scan
/tf_static
/ydlidar_node/transition_event
```
4. data of topic /scan
```shell
header:
stamp:
sec: 1693055587
nanosec: 220429000
frame_id: laser_frame
angle_min: -3.1415927410125732
angle_max: 3.1415927410125732
angle_increment: 0.015591030940413475
time_increment: 0.00024999998277053237
scan_time: 0.09974999725818634
range_min: 0.009999999776482582
range_max: 64.0
ranges:
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.5090000033378601
- 0.492000013589859
- 0.4869999885559082
- 0.4830000102519989
- 0.4790000021457672
- 0.4740000069141388
- 0.4690000116825104
- 0.4659999907016754
- 0.46299999952316284
- 0.46000000834465027
- 0.4569999873638153
- 0.4560000002384186
- 0.453000009059906
- 0.4519999921321869
- 0.45100000500679016
- 0.44999998807907104
- 0.4480000138282776
- 0.44600000977516174
- 0.0
- 0.5090000033378601
- 0.5049999952316284
- 0.5019999742507935
- 0.4959999918937683
- 0.49300000071525574
- 0.48399999737739563
- 0.47699999809265137
- 0.0
- 0.44999998807907104
- 0.44200000166893005
- 0.0
- 0.35499998927116394
- 0.3499999940395355
- 0.3472500145435333
- 0.3462499976158142
- 0.3462499976158142
- 0.3472500145435333
- 0.3490000069141388
- 0.3490000069141388
- 0.35100001096725464
- 0.3529999852180481
- 0.35499998927116394
- 0.0
- 0.0
- 0.49300000071525574
- 0.48899999260902405
- 0.49000000953674316
- 0.492000013589859
- 0.49799999594688416
- 0.5070000290870667
- 0.5120000243186951
- 0.5120000243186951
- 0.5130000114440918
- 0.5130000114440918
- 0.5120000243186951
- 0.5120000243186951
- 0.5099999904632568
- 0.5099999904632568
- 0.5109999775886536
- 0.0
- 0.4620000123977661
- 0.4690000116825104
- 0.0
- 0.5040000081062317
- 0.5239999890327454
- 0.5350000262260437
- 0.0
- 0.5440000295639038
- 0.5540000200271606
- 0.5619999766349792
- 0.5659999847412109
- 0.5709999799728394
- 0.5730000138282776
- 0.574999988079071
- 0.5759999752044678
- 0.574999988079071
- 0.574999988079071
- 0.5789999961853027
- 0.578000009059906
- 0.5799999833106995
- 0.5839999914169312
- 0.0
- 0.7160000205039978
- 0.7129999995231628
- 0.7129999995231628
- 0.7099999785423279
- 0.7059999704360962
- 0.6980000138282776
- 0.6869999766349792
- 0.6779999732971191
- 0.6669999957084656
- 0.0
- 0.0
- 0.7680000066757202
- 0.0
- 0.0
- 0.9039999842643738
- 0.9229999780654907
- 0.9440000057220459
- 0.9660000205039978
- 0.9909999966621399
- 1.0169999599456787
- 1.0420000553131104
- '...'
intensities:
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 0.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 0.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 0.0
- 1008.0
- 1008.0
- 0.0
- 1008.0
- 1008.0
- 1012.0
- 1012.0
- 1012.0
- 1012.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 0.0
- 0.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 0.0
- 1008.0
- 1008.0
- 0.0
- 1008.0
- 1008.0
- 1008.0
- 0.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 0.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 0.0
- 0.0
- 1008.0
- 0.0
- 0.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- 1008.0
- '...'
```
3. client 收到資訊
```shell
[YDLIDAR INFO]: I heard a laser scan laser_frame[411]:
[YDLIDAR INFO]: angle_range : [-180.000005, 180.000005]
[YDLIDAR INFO]: angle-distance : [-180.000000, 0.000000]
[YDLIDAR INFO]: angle-distance : [-179.106705, 0.000000]
[YDLIDAR INFO]: angle-distance : [-178.213409, 0.000000]
```
### 有關 turtlebot3_gazebo
```shell
/camera/camera_info
/camera/image_raw
/clock
/cmd_vel
/imu
/joint_states
/odom
/performance_metrics
/robot_description
/scan
/tf
/tf_static
```
### 有關SLAM_TOOLBOX pkg
* topic list
```shell
/clock
/map
/map_metadata
/scan
/slam_toolbox/feedback
/slam_toolbox/graph_visualization
/slam_toolbox/scan_visualization
/slam_toolbox/update
/tf
/tf_static
```
### 有關nav2_bringup pkg
* topic list
```shell
/bt_navigator/transition_event
/clock
/cmd_vel
/controller_server/transition_event
/cost_cloud
/evaluation
/global_costmap/costmap
/global_costmap/costmap_raw
/global_costmap/costmap_updates
/global_costmap/footprint
/global_costmap/global_costmap/transition_event
/global_costmap/published_footprint
/goal_pose
/local_costmap/clearing_endpoints
/local_costmap/costmap
/local_costmap/costmap_raw
/local_costmap/costmap_updates
/local_costmap/footprint
/local_costmap/local_costmap/transition_event
/local_costmap/published_footprint
/local_costmap/voxel_grid
/local_plan
/map
/marker
/odom
/plan
/planner_server/transition_event
/received_global_plan
/recoveries_server/transition_event
/tf
/tf_static
/transformed_global_plan
/waypoint_follower/transition_event
```