Localization and Navigation Example
ROS1 Localization and Navigation
Section titled “ROS1 Localization and Navigation”Introduction
Section titled “Introduction”This example implements robot localization and navigation based on LiDAR and IMU sensors, using the hdl_localization algorithm for localization and the move_base package for map-based navigation.
Note: Keep the LiDAR driver running during navigation (refer to the mapping example for LiDAR driver startup).
Single Goal Navigation
Section titled “Single Goal Navigation”- Open a terminal and start the LiDAR driver (if already started during mapping, no need to restart):
cd /home/ysc/lite_cog/system/scripts/lidar./start_lslidar.sh # Leishen LiDAR./start_livox.sh # Livox LiDAR./start_rslidar.sh # RoboSense LiDAR- Open a terminal and start the navigation node:
cd /home/ysc/lite_cog/system/scripts/nav./start_nav.sh- Initialize robot localization:

a) Click “2D Pose Estimate” in the top toolbar;
b) Determine the robot’s actual position and orientation, move the mouse to the corresponding position on the map, hold left button and drag an arrow in the actual direction, then release;
c) If initialization succeeds, laser point cloud and grid map will overlap, and the terminal prints “initial pose received!!”;
d) If they don’t overlap, the initial position was incorrect. Retry;
e) If no laser point cloud appears and the terminal prints “globalmap has not been received!!”, close with Ctrl+C and retry;
f) The base_link coordinate frame is the robot coordinate frame, x-axis (red) indicates the robot’s heading.
[RViz Tips] In RViz, use the scroll wheel to zoom, left mouse button to rotate, hold Shift + left mouse button to pan.
- After successful initialization, set a goal:
a) Click “2D Nav Goal” in the top toolbar; b) Move the mouse to the target position, hold left button and drag an arrow for target orientation, then release; c) If successful, a planned path will appear; if failed, retry.
- Enable autonomous mode on the APP and stand up the robot. The robot will follow the global planned path and avoid dynamic obstacles via local planning.
Note: To prevent the robot body from being detected as an obstacle, only objects above a certain height will be recognized as obstacles.
Multi-Goal Navigation
Section titled “Multi-Goal Navigation”This example provides cyclic navigation through a series of waypoints.
Note: Before recording waypoints, check
/home/ysc/lite_cog/pipeline/src/pipeline/datafor existing waypoint files and move them to avoid overwriting.
- Follow steps 1-3 from single goal navigation to start navigation and set initial pose, then open a terminal to run the waypoint configuration program:
cd /home/ysc/lite_cog/pipeline/src/pipeline_tracking/toolspython3 location_record.py # Chinese versionpython3 location_record_en.py # English version

-
Manually遥控 the robot to a waypoint, enter 1 at “location number”, click “get location”, then click “record location”. A file named 1.json will appear in
/home/ysc/lite_cog/pipeline/src/pipeline/data. Repeat for all waypoints, then close the program. -
Open a terminal and run:
cd /home/ysc/lite_cog/pipelinesource devel/setup.bashcd /home/ysc/lite_cog/pipeline/src/pipeline_tracking/scriptspython3 Task.pyEnable autonomous mode on the APP. The robot will go to the nearest waypoint and navigate cyclically.
- For subsequent uses, start navigation, set initial pose, then run step 3.
ROS2 Localization and Navigation
Section titled “ROS2 Localization and Navigation”Introduction
Section titled “Introduction”This example uses hdl_localization for localization and bt_navigator for map-based navigation.
Note: Keep the LiDAR driver running during navigation.
Single Goal Navigation
Section titled “Single Goal Navigation”- Start the LiDAR driver:
cd ~/lite_cog_ros2/system/scripts/lidar./start_lslidar.sh # Leishen LiDAR./start_livox.sh # Livox LiDAR./start_rslidar.sh # RoboSense LiDAR- Start navigation:
cd /home/ysc/lite_cog_ros2/system/scripts/nav./start_nav.sh- Initialize localization:

a) Click “2D Pose Estimate”; b) Set the robot’s position and orientation on the map; c) If successful, laser point cloud and grid map overlap, terminal prints “initial pose received!!”; d) If not, retry; e) If no point cloud and “globalmap has not been received!!”, retry; f) base_link is the robot frame, x-axis (red) is heading.
- Set a goal:
a) Click “Navigation2 Goal”; b) Set target position and orientation; c) A planned path will appear if successful.
- Enable autonomous mode and stand up the robot.
Note: Only objects above a certain height are recognized as obstacles.
Multi-Goal Navigation
Section titled “Multi-Goal Navigation”Note: Check
/home/ysc/lite_cog_ros2/pipeline/src/pipeline/datafor existing waypoint files.
- Start navigation and set initial pose, then run:
a) Chinese version:
cd ~/lite_cog_ros2/pipeline/src/pipelinepython3 LocationRecorder.pyb) English version:
cd ~/lite_cog_ros2/pipeline/src/pipelinepython3 LocationRecorder_EN.py

-
Record waypoints as described in the ROS1 section.
-
Run:
cd /home/ysc/lite_cog_ros2/pipeline/src/pipelinepython3 Task.py- For subsequent uses, run steps 1 and 3.