Skip to content

Latest commit

 

History

History
77 lines (55 loc) · 5.57 KB

slam_information.md

File metadata and controls

77 lines (55 loc) · 5.57 KB

SLAM Information

This document provides additional information for running SLAM on a spot micro quadruped through this project.

Walking and Slam Example of robot walking and mapping an environment.

Required Setup

Two prerequisite steps are required for SLAM:

  1. Installing additional ROS packages
  2. Elevating permissions of the USB port the lidar is connected to for it's ROS package

Two additional ROS packages must be installed, and these must be installed on the Raspberry Pi. It is also reccomended to install these on a Linux host machine for use such as data reprocessing. The required packages are hector_slam and rplidar_ros, which can be installed with the following commands:

sudo apt-get install ros-kinetic-rplidar-ros
sudo apt-get install ros-kinetic-hector-slam

See the following website for additional information about setting up your sources list if the above commands do not work.

Elevated permissions will need to be granted to the USB port the RPLidar is connected to. After connecting the RPLidar to one of the RPi's usb ports, find which USB port it is connected to using the following command: ls -l /dev |grep ttyUSB Elevate that ports authorit with the following command. Example if the port was USB0: sudo chmod 666 /dev/ttyUSB0

This step may or may not need to be done everytime the RPi is power cycled. It seems to be applied permanent at least when using the Ubiquity Robotics RPi Ubuntu images with ROS. See the following page for more details about setting uo the RPLidar A1 for use with the rplidar_ros package.

Note that the RPLidar A1 will start rotating once it is plugged into a powered USB port through it's USB to serial board. It is possible to command the lidar to stop so it does not rotate when not in use via it's SDK, but this functionalty is not yet implemented on this project.

This project assumes a RPLidar A1. If another Lidar is used, then a different lidar driver ROS package will be needed.

Generating a Map

It is reccomended to use the trot gait for robot motion when mapping with a lidar, as it is slightly smoother, albeit less stable, than the 8 phase gait.

Open at least two terminal windows, with one ssh'ed to the raspberry pi. I reccomend using a terminal multiplexer such as tmux for convenience. Start the following launch files in the respective terminals:

  • roslaunch spot_micro_launch motion_control_and_hector_slam.launch: Run on the Raspberry Pi. Launches the i2c_pwmboard node, the robot's motion control node, hector_mapping, and the lidar driver node (rplidar_ros).
  • roslaunch spot_micro_launch keyboard_control_and_rviz rviz_slam:=true Run on a local machine. Launches the keyboard command node for issuing keyboard commands to the spot micro robot in the terminal, as well as rviz with a configuration to display the mapping process.

After everything is launched, the robot can be manually directed to walk around an environment (such as a room or apartment) through the keyboard command node, and a map will be geerated and shown in real time through RVIZ, along with the robot's current and past positions.

Saving a Map

To save a map, such as to use it in the future for navigational purposes, run the robot until a satisfactory map is shown in RVIZ. Keep all nodes running, open another terminal in a ros environment on either the RPi or local linux host, and run the following command: rosrun map_server map_saver -f my_map_filename This will generate two files (my_map_filename.pgm and my_map_filename.yaml) in the same directory in which the command was run. A custom name can be provided in place of my_map_filename. See the following website for more detals about ros map_server.

Another type of map can be generated which is purely an image and is not useful for navigational purposes. This map can be generated by running the following command in a ros environment: rostopic pub syscommand std_msgs/String "savegeotiff"

Recording a Data Log

Recording a data log is useful for playing back and inspecting or analyzing data at a later point, as well as for reprocessing data which is described in the next section.

The record a data log, make a new directory for storing logfiles:

mkdir ~/bagfiles
cd ~/bagfiles

And record all rostopics with the following command: rosbag record -a

Note that log files will be on the order of 1 GB in size per around 10 minutes of operation.

Reprocessing Scan Data Through Log Playback

A data log can be played back to reprocess data. One use case for this is to playback a log file with lidar scan data and regenerate a map again, and being able to use differnet mapping settings or an entirely different mapping package.

As an example, the steps to playback a recorded dataset through hector slam are:

  1. Playback a log using a command such as rosbag play <your bagfile>. Additional command line arguments, such as --topics <topic1_to_play> <topic2_to_play> ... can be added to specify which topics to playback only.
  2. Start the hector slam node and rviz to visualize the mapping process. This can be done through the following two launch commands: roslaunch spot_micro_rviz slam.launch roslaunch spot_micro_launch motion_control_and_hector_slam.launch run_post_proc:=true