SLAM Mapping with Cartographer
Following the build with T265 non GPS navigation rover, I added the 2D lidar on top of it.
Additional Hardware
Camera: Pi camera with Raspberry pi
Lidar: RPLidar A2
Internet connection for companion computer: 2.4GHz Wifi dongle
You may wonder why not put all wireless connection connecting under Herelink controller’s hotspot. The answer is simply because I don’t have the hardware to connect UP2 to 5GHz wifi.
It is also possible to setup the ethernet so that the companion computer doesn’t need additional wireless connection.
Setup
On companion computer (UP2 in my case), build the cartographer, ROS, and other necessary packages following the instruction in Ardupilot wiki
If the error show up when trying to build it, try to build the packages with cartographer wiki’s instruction
You may also need to install abseil if any related error come out
$ sudo apt-get install stow
$ sudo chmod +x ~/carto_ws/src/cartographer/scripts/install_abseil.sh
$ cd ~/carto_ws/src/cartographer/scripts
$ ./install_abseil.sh
To make a remote spectator or control on laptop, use ROS’s master/remote setup:
In master’s ~/.bashrc
, put
export ROS_IP={self ip}
export ROS_MASTER_URI=http://localhost:11311
In remote’s ~/.bashrc
, put
export ROS_IP={self ip}
export ROS_MASTER_URI=http://{master’s ip}:11311
Run the SLAM
SSH into master machine
ssh {username}@{master ip}
Then run the ros components in different terminals
roscore
roslaunch rplidar_ros rplidar.launch
roslaunch cartographer_ros cartographer.launch
In remote/client machine
roscore
rviz -d ~/catkin_ws/src/cartographer_ros/cartographer_ros/configuration_files/demo_2d.rviz
Generate mapping file
Finally, when mapping is done, run the following lines to generate .pgm and .yaml files
rosrun map_server map_saver [-f mapname]
You will get something like this:
Video Demo
It was a little laggy at the corner, because there is surrounded by couple of big and tall metal shelves. The wifi hotspot signal from Herelink was not reaching, but the Herelink transmission itself are working fine.
I’m not able to test the build elsewhere. That’s because I need to stick to a network with 2.4GHz hotspot(for UP2), 5GHz hotspot(for Herelink controller), and under my control.
Errors
If the follow error shows up:
[ERROR] [1651567143.011534119]: Client [/rviz_1651567140920139372] wants topic /submap_list to have datatype/md5sum [cartographer_ros_msgs/SubmapList/6efe809c4a0e69266aa99b3bea531f2a], but our version has [cartographer_ros_msgs/SubmapList/73b1e412208f0787050395996f6143db]. Dropping connection.
in master’s rosrun cartographer’s terminal when client’s rviz launch. (the md5sum string maybe different, but the idea is them being mismatched over master and client)
You may try to:
-
check whether you have sourced
devel/setup.bash
in~/bashrc.sh
or not. If you usedcatkin_make_isolated --install --use-ninja
, the directory becomesdevel_isolated/setup.bash
-
reinstall ros-{distro}-cartographer-rviz
-
rebuild cartographer_ros
-
reset rviz to default
-
reinstall ROS
If the follow error shows up:
[ERROR] [1651655459.598098736]: PluginlibFactory: The plugin for class ‘Submaps’ failed to load. Error: According to the loaded plugin descriptions the class Submaps with base class type rviz::Display does not exist. Declared types are rviz/Axes rviz/Camera rviz/DepthCloud rviz/Effort rviz/FluidPressure rviz/Grid rviz/GridCells rviz/Illuminance rviz/Image rviz/InteractiveMarkers rviz/LaserScan rviz/Map rviz/Marker rviz/MarkerArray rviz/Odometry rviz/Path rviz/PointCloud rviz/PointCloud2 rviz/PointStamped rviz/Polygon rviz/Pose rviz/PoseArray rviz/PoseWithCovariance rviz/Range rviz/RelativeHumidity rviz/RobotModel rviz/TF rviz/Temperature rviz/WrenchStamped
Source devel/setup.bash
or devel_isolated/setup.bash
like the 1st solution in last error.
Hope you enjoy my sharing.