I'm working on SLAM using Nav2 and Slam_Toolbox and am attempting to create a 2D Occupancy Map.
My setup is as follows:
- Jetson Orin AGX
- ROS2 Humble
- Ouster OS1-32 Lidar
pointcloud_to_laserscanto convert my Lidar's 3D point cloud into a 2D laser scan- I have an odometry node that's publishing successfully
The Problem
I'm attempting to create a map of my apartment using slam_toolbox, however, when I run pointcloud_to_laserscan and select the /scan topic in LaserScan in Rviz, the left/right sides of the map are flipped and the robot is facing backwards.
Here's what the correct map in Rviz looks like using my Ouster Lidar driver:
And here's what my laserscan looks like in Rviz (if you compare the following laserscan screenshots to the above ouster lidar driver screenshot, you'll see the the left/right sides of the laserscan map are flipped and the robot is facing backwards):
TF Tree
Below is a pdf of my tf tree that's generated when running: ros2 run tf2_tools view_frames
Here's an image of my actual robot:
My Code
- Here's my static transforms file:
from launch import LaunchDescription from launch_ros.actions import Node def static_tf(x, y, z, roll, pitch, yaw, frame_id, child_frame_id): return Node( package="tf2_ros", executable="static_transform_publisher", name=f"static_tf_{child_frame_id.replace('/', '_')}", arguments=[str(x), str(y), str(z), str(roll), str(pitch), str(yaw), frame_id, child_frame_id], output="screen" ) def generate_launch_description(): return LaunchDescription([ static_tf(0, 0.287655, 0, 0, 0, 0, "base_footprint", "left_wheel_link"), static_tf(0, -0.287655, 0, 0, 0, 0, "base_footprint", "right_wheel_link"), static_tf(0.41275, 0, 0, 0, 0, 0, "base_footprint", "caster_link"), static_tf(0.47625, 0, 0.24655, 0, 0, 0, "base_footprint", "oak_d_base_frame"), static_tf(0.02, 0, 0, 0, 0, 0, "oak_d_base_frame", "oak_d_frame"), static_tf(0, 0, 0, -1.5708, 0, -1.5708, "oak_d_frame", "oak_rgb_camera_optical_frame"), static_tf(0, 0, 0.3912, 0, 0, 0, "base_footprint", "os_sensor"), static_tf(0, 0, 0.025, 0, 0, 3.1416, "os_sensor", "os_lidar"), ]) - Here's my
pointcloud_to_laserscancommand:
ros2 run pointcloud_to_laserscan pointcloud_to_laserscan_node --ros-args -r cloud_in:=/ouster/points -r scan:=/scan -p target_frame:=base_link -p transform_tolerance:=0.01 -p min_height:=-1.0 -p max_height:=1.0 -p angle_min:=-3.14 -p angle_max:=3.14 -p angle_increment:=0.003 -p range_min:=0.3 -p range_max:=10.0 -p scan_time:=0.1 -p use_header_stamp:=true - Here's my slam_toolbox launch command (I haven't changed any of the default params here):
ros2 launch slam_toolbox online_async_launch.py What I've Done to Debug Thus Far
A very helpful stack exchange member looked through the ouster lidar coordinate frames documentation and suggested that I modify my pointcloud_to_laserscan command to this:
ros2 run pointcloud_to_laserscan pointcloud_to_laserscan_node --ros-args -r cloud_in:=/ouster/points -r scan:=/scan -p target_frame:=base_footprint -p transform_tolerance:=0.01 -p min_height:=-1.0 -p max_height:=1.0 -p angle_min:=0.0 -p angle_max:=6.2832 -p angle_increment:=0.003 -p range_min:=0.3 -p range_max:=10.0 -p scan_time:=0.1 -p use_header_stamp:=true So I ran that command, and now the robot seems to be facing the correct way and the orientation of the map looks correct. However, half the map is being cut off as you can see from the images below:
If anyone has any suggestions, it'd be much appreciated!






