ROS2 Humble Cartographer on NVIDIA Jetson Nano with RPLIDAR

ROS2 Humble Cartographer on NVIDIA Jetson Nano with RPLIDAR

Introduction:

ROS2 (Robot Operating System 2) has revolutionized the field of robotics, offering a flexible and powerful framework for building robot applications. In this blog post, we’ll explore how to set up a cartographer using ROS2 on the NVIDIA Jetson Nano, a popular single-board computer, along with an RPLIDAR for mapping tasks.

Setting Up ROS2 on NVIDIA Jetson Nano:

Before diving into the cartographer setup, let’s ensure ROS2 is properly installed on the NVIDIA Jetson Nano and set up your workspace and ensure all dependencies are met.

sudo apt install ros-humble-cartographer

Introducing RPLIDAR:

RPLIDAR is a low-cost LIDAR sensor widely used in robotics for mapping and navigation. Its lightweight design and affordable price make it an ideal choice for hobbyists and small-scale robotics projects. We’ll connect the RPLIDAR to the Jetson Nano via USB and integrate it with ROS2 for mapping applications.

Setup the RPLIDAR:

Clone the rplidar driver from github

Find out the port and enable

ls -l /dev |grep ttyUSB

sudo chmod 666 /dev/ttyUSB0

Configuring Cartographer:

Cartographer is a powerful open-source SLAM (Simultaneous Localization and Mapping) library developed by Google. We’ll configure Cartographer to work with ROS2 and the RPLIDAR sensor on the Jetson Nano. This involves defining sensor configurations, tuning parameters, and setting up the mapping workflow

Tune the parameter

– Copyright 2016 The Cartographer Authors

– Licensed under the Apache License, Version 2.0 (the “License”);
– you may not use this file except in compliance with the License.
– You may obtain a copy of the License at

Apache License, Version 2.0

– Unless required by applicable law or agreed to in writing, software
– distributed under the License is distributed on an “AS IS” BASIS,
– WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
– See the License for the specific language governing permissions and
– limitations under the License.

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 = true,
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 = 8.
TRAJECTORY_BUILDER_2D.missing_data_ray_length = 8.5
TRAJECTORY_BUILDER_2D.use_imu_data = false
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 = 10.
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.rotation_delta_cost_weight = 1e-1
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

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 = 35

Trajectory Builder Parameters:

  • min_range and max_range: Adjusting these values might improve performance depending on the sensor characteristics and environment.
  • missing_data_ray_length: Ensure it’s set appropriately for handling missing data.
  • use_imu_data: If your system has IMU data available and it’s reliable, consider setting this to true for better motion estimation.

Need to interface imu follow this blog

  • use_online_correlative_scan_matching: This can be toggled based on real-time performance requirements.

Real-time Correlative Scan Matcher Parameters:

  • linear_search_window: This parameter defines the size of the search window. Adjusting it carefully can improve matching speed without sacrificing accuracy.
  • translation_delta_cost_weight and rotation_delta_cost_weight: These weights balance translation and rotation during scan matching. Fine-tuning them can enhance performance.

Motion Filter Parameters:

  • max_angle_radians: Set according to the maximum expected change in orientation between consecutive scans.

Pose Graph Optimization Parameters:

  • min_score parameters in constraint_builder: Adjusting these can help in filtering out spurious constraints.
  • huber_scale: This affects the robustness of optimization. A larger value can help in rejecting outlier constraints.
  • optimize_every_n_nodes: Balances the frequency of pose graph optimization. Adjust according to computational resources and mapping requirements.

Launch the RPLIDAR.

Launch the cartographer node after parameter and launch file configuration.

Once Cartographer is configured, we’ll launch the mapping node on the Jetson Nano. This node will subscribe to data from the RPLIDAR sensor, perform SLAM algorithms in real-time, and generate a 2D map of the environment. We’ll explore different mapping strategies and options provided by Cartographer to optimize mapping performance.

Than launch rviz

Enable the map in topic

TF Tranform

Base_link laser

Cartographer Mapping

map

Conclusion:

In this blog post, we’ve demonstrated how to set up a humble cartographer using ROS2 on the NVIDIA Jetson Nano with an RPLIDAR sensor. By leveraging the capabilities of ROS2 and open-source tools like Cartographer, hobbyists and robotics enthusiasts can build sophisticated mapping systems on affordable hardware platforms. Whether you’re exploring robotics as a hobby or developing solutions for real-world applications, ROS2 and the Jetson Nano offer a compelling combination for mapping and navigation tasks.

1 Like