1. Rplidar node 설치
작업 공간에 RPLidar 노드 설치
cd catkin_ws/src
git clone https://github.com/Slamtec/rplidar_ros.git
// or git clone https://github.com/Slamtec/rplidar_sdk
2. cartographer_ros실행 파일 만들기
cd catkin_ws/src/cartographer_ros/cartographer_ros/launch
nano cartographer.launch
아래 내용 복사해 붙여넣기
<?xml version="1.0"?>
<launch>
<param name="/use_sim_time" value="false" />
<node name="cartographer_node"
pkg="cartographer_ros"
type="cartographer_node"
args="-configuration_directory $(find cartographer_ros)/configuration_files -configuration_basename cartographer.lua"
output="screen">
<remap from="odom" to "/mavros/local_position/odom" />
<remap from="imu" to "/mavros/imu/data" />
</node>
<node name="cartographer_occupancy_grid_node"
pkg="cartographer_ros"
type="cartographer_occupancy_grid_node" />
<node name="robot_pose_publisher"
pkg="robot_pose_publisher"
type="robot_pose_publisher"
respawn="false"
output="screen" />
<node pkg="tf" type="static_transform_publisher" name="base_to_laser_broadcaster" args="0 0 0 0 0 0 base_link laser 100" />
</launch>
3. cartographer.lua 스크립트 만들기
cd catkin_ws/src/cartographer_ros/cartographer_ros/configuration_files
nano cartographer.lua
아래 내용 붙여넣기
include "map_builder.lua"
include "trajectory_builder.lua"
options = {
map_builder = MAP_BUILDER,
trajectory_builder = TRAJECTORY_BUILDER,
map_frame = "map",
tracking_frame = "base_link",
published_frame = "base_link",
odom_frame = "odom",
provide_odom_frame = true,
publish_frame_projected_to_2d = false,
use_odometry = false,
use_nav_sat = false,
use_landmarks = false,
num_laser_scans = 1,
num_multi_echo_laser_scans = 0,
num_subdivisions_per_laser_scan = 1,
num_point_clouds = 0,
lookup_transform_timeout_sec = 0.2,
submap_publish_period_sec = 0.3,
pose_publish_period_sec = 5e-3,
trajectory_publish_period_sec = 30e-3,
rangefinder_sampling_ratio = 1.,
odometry_sampling_ratio = 1.,
fixed_frame_pose_sampling_ratio = 1.,
imu_sampling_ratio = 1.,
landmarks_sampling_ratio = 1.,
}
MAP_BUILDER.use_trajectory_builder_2d = true
TRAJECTORY_BUILDER_2D.min_range = 0.05
TRAJECTORY_BUILDER_2D.max_range = 30
TRAJECTORY_BUILDER_2D.missing_data_ray_length = 8.5
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.ceres_scan_matcher.translation_weight = 0.2
TRAJECTORY_BUILDER_2D.ceres_scan_matcher.rotation_weight = 5
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.linear_search_window = 0.1
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.translation_delta_cost_weight = 1.
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.rotation_delta_cost_weight = 10
TRAJECTORY_BUILDER_2D.motion_filter.max_angle_radians = math.rad(0.2)
-- for current lidar only 1 is good value
TRAJECTORY_BUILDER_2D.num_accumulated_range_data = 1
TRAJECTORY_BUILDER_2D.min_z = -0.5
TRAJECTORY_BUILDER_2D.max_z = 0.5
POSE_GRAPH.constraint_builder.min_score = 0.65
POSE_GRAPH.constraint_builder.global_localization_min_score = 0.65
POSE_GRAPH.optimization_problem.huber_scale = 1e2
POSE_GRAPH.optimize_every_n_nodes = 30
return options
4. 패키지 빌드
cd catkin_ws
catkin build
source devel/setup.bash
=> 근데 안됐던 것 같다... 안되어도 pass
5. RPLidar의 직렬 포트 확인
ls -l /dev |grep ttyUSB
Lidar는 /dev/ttyUSB0 또는 /dev/ttyACM0으로 나타나야 한다.
쓰기 권한 추가
sudo chmod 666 /dev/ttyUSB0
6. 빌드하기
다음을 넣어 빌드해주기 그럼 총 6개의 빌드 내용이 나온다 기존 catrographer4개와 RPLidar랑 뭐 하나 더 총 6개가 빌드되어야 한다.
catkin_make_isolated
=> 이 부분에서 에러가 많이 나는데 에러 내용은 여기와 비슷함
2022.05.13 - [Project/#1 AI 기반 자율주행 로봇을 이용한 매장 관리] - #3. ROS - Noetic&Cartographer 설치
7. 실행
새 terminal에
roscore
아래 모두 catkin_ws에서 접근해야한다.
새 terminal에
source devel_isolated/setup.bash
roslaunch rplidar_ros rplidar.launch &
새 terminal에
source install_isolated/setup.bash
roslaunch cartographer_ros rplidar_2d.launch
=> 중간에 에러가 엄청 나는데 에러 코드 보면서 파일 위치 옮겨주면 된다...
에러 코드에 파일 위치가 잘 못 되었다고 나오는 경우가 많은데 cartographer_ros파일 옮겨가면서 실행해보면 되기는 한다.
주로 오류 잘 나는 파일
+ 확인해볼 것
다음을 넣었을 때 /scan이 떠야 라이다 이용하고 있는 것
rostopic list
그리고 다음을 하면 tf(transform)도 같이 뜸
rosrun tf static_transform_publisher 0 0 0 0 0 0 0 world laser 100
8. 내 노트북에서 Rviz그리기
- 라즈베리파이에 위에서 제시한 것 처럼 순서에 맞게 해주기
- 내 맥에서 Rviz가 되는 우분투로 들어가서 Rviz실행
- fixed frame에 laser라고 수동으로 입력
=> 라즈베리파이에 연결된 lidar창이 뜬다.
+ 아직 해결 못한 문제
roslaunch cartographer_ros rplidar_2d.launch
입력했을 때 오류가 지속해서 뜬다..
RPLidar rviz는 뜨는데 cartographer시각으로 구현되는 맵이 안뜬다.. 그리고 발생하는 에러
[ERROR] [1659857894.835008875]: PluginlibFactory: The plugin for class 'Submaps' failed to load. Error: Could not find library corresponding to plugin Submaps. Make sure the plugin description XML file has the correct name of the library and that the library actually exists.
=> 아직 해결 못함
참고 자료
https://ardupilot.org/dev/docs/ros-cartographer-slam.html
Cartographer SLAM for Non-GPS Navigation — Dev documentation
Note We are keen to improve ArduPilot’s support of ROS so if you find issues (such as commands that do not seem to be supported), please report them in the ArduPilot issues list with a title that includes “ROS” and we will attempt to resolve them as
ardupilot.org
rplidar - ROS Wiki
melodic noetic Show EOL distros: EOL distros: hydro indigo jade kinetic lunar hydro: Documentation generated on August 28, 2015 at 12:46 PM (doc job).indigo: Documentation generated on March 18, 2019 at 10:28 AM (doc job).jade: Documentation gene
wiki.ros.org
https://m.blog.naver.com/nsecj/221482933693
Lidar 스터디 (with ROS)
어제 알리에서 구입한 RPLIDAR A1이 왔다. 월요일까지 모든 물건이 다 오길 기대하며 추가금을 내...
blog.naver.com
'Project > #1 AI 기반 자율주행 로봇을 이용한 매장 관리' 카테고리의 다른 글
#10 Ros2 foxy install & delete (0) | 2022.09.01 |
---|---|
+#9 라즈베리파이 원격 접속 Rviz 모니터링 (0) | 2022.08.07 |
#8 라즈베리파이4 우분투 GUI (0) | 2022.08.05 |
#7 라즈베리파이4 Ubuntu설치 (0) | 2022.08.04 |
+#6 vnc 접속 오류시 (0) | 2022.08.04 |