====== LIDAR on E-Maxx for SLAM ====== ===== Arduino Attempt ===== Since most of the project was already Arduino based the feasibility of reading LIDAR data directly to an Arduino was examined. The setup involved the Sain-Smart USB host shield that was used for the [[drexel_duct_navigator_odometry|Measuring odometry with an optical mouse]] tutorial. The LIDAR used was the Hokuyo URG-04LX. The lidar was powered through it's serial connector port. The Arduino mega was connected to the LIDAR via usb cable. The Arduino mega was uploaded with the ACM_terminal example sketch provided with the [[https://github.com/felis/USB_Host_Shield_2.0|usb host shield library]]. This sketch will simply echo commands from a computer to the device connected to the usb host shield. The following command was sent to the lidar to configure it to scip2.0 mode scip2.0\n the Hokuyo echoed scip2.0 0 indicating that the mode change was successful. However, this command took over 30 seconds to receive. An "MD" command was sent to the LIDAR to recieve a set of scans. Still, there was an excessively long delay in response. To establish a benchmark for response delay the LIDAR was connected to a laptop. The SCIP 2.0 responses were almost immediate. It was suspected that the example Arduino sketch was causing slow downs so a simple sketch was created to send a simple request for the LIDAR's software version information. Still, the problem persisted. Earlier in this project Arduino slowdowns were encountered when the power draw was too high on the Arduino board. So Ample power was supplied to the Arduino board using a power supply. The LIDAR was powered separately at 5.0 V. Still, there was no effect on the speed. At this point it was decided to pursue other means of processing LIDAR data. Even if the speed problem was solvable here it is unlikely that and Arduino mega could efficiently run a SLAM algorithm ===== Slam On Linux and ROS ===== It was decided to utilize ROS (robot operating system) to process the LIDAR data. Additionally ROS has several SLAM packages available for use. I believed small linux board should be able to run ROS, the LIDAR drivers and a slam package. A Raspberry Pi was selected for this purpose. Hector slam was selected as a slam package due to it's scalability. Hector slam can be used with odometry, IMU data, and LIDAR data or just LIDAR data. This way it would be possible to create a basic setup using only LIDAR. From that basic it would be possible setup odometry and IMU data as time allowed. Both Hector SLAM and thee LIDAR drivers were last updated before the release of ROS groovy. Therefore, it was decided to use ROS fuerte for full compatibility. While waiting for the Raspberry Pi to arrive a laptop was used to run ROS on Ubuntu. ===== Installing and Testing LIDAR Drivers ===== The [[http://wiki.ros.org/laser_drivers|laser_drivers]] package was selected to run the LIDAR for it's direct compatibility with the Hokuyo LIDAR. The laser driver was installed by follwing [[http://wiki.ros.org/hokuyo_node/Tutorials/UsingTheHokuyoNode|this tutorial]]. Installation and testing was pretty straightforward when following the tutorial. The hokuyo node, once running, will broadcast a topic called "scan" streaming the laser data with each sweep. The scan data will be shown in the "laser" reference frame. ===== Installing Hector Slam ===== First the hector slam source needs to be installed. You can download them directly and move them to your ros workspace or you clone them directly roscd cd sandbox ## the name of my folder to hold libraries Now it is necessary to build the package rosbuild hector_slam If the build fails you may want to use rosdep install hector_slam to add the necessary dependencies to run rosmake again after hector slam is installed test it by following the [[http://wiki.ros.org/hector_slam/Tutorials/MappingUsingLoggedData|mapping using logged data]] tutorial on the ROS wiki ===== Configuring hector SLAM to use LIDAR data ===== The following procedure it based on [[http://answers.ros.org/question/64644/how-mapping-using-hokuyo-lidar-urg-04lx-and-hector_slam/|this]] ROS answers page. First it is necessary to create a ROS package by navigating to your ROS workspace and entering navigate to location: $ roscd $ cd sandbox create package: $ roscreate-pkg slam_launch $ rospack profile $ rospack find slam_launch in the newly created slam launch package create the following files in ~/fuerte_workspace/sandbox/slam_launch/launch/ slam.launch ros hector_mapping.launch notice the following line in the above code it is used to create the static transform broadcaster to the base_link frame. More details on the setup of the hector_slam reference frames can be found [[http://wiki.ros.org/hector_slam/Tutorials/SettingUpForYourRobot|here]]. geotiff_mapper.launch in this file simply chance the location of your save file marked by in the code below. **starting the slam_launch package:** in **terminal window 1** launch the roscore $ roscore in **terminal window 2** setup the LIDAR permissions and start the node $ sudo chmod a+rw /dev/ttyACM0 $ s -l /dev/ttyACM0 $ rosrun hokuyo_node hokuyo_node In **terminal window 3** launch your package $ roslaunch slam_launch slam.launch Now a RViz window will open and display SLAM data ===== LIDAR Vehicle setup ===== The lidar was placed on the front of the vehicle in front of the sonic rangefinders. The location of the LIDAR was in a "blindspot" of the sonic sensors so as to not interfere with them so they could continue to operate the vehicle in autonomous mode. The LIDAR was placed far enough foreword so that none of the structure on the vehicle would block its sweeping area (~270 degrees). {{dylanw:slam_corner.JPG?400}}{{dylanw:slam_front.JPG?400}} {{dylanw:slam_side.JPG?400}}{{dylanw:slam_top.JPG?400}}\\ ===== Results from tethered SLAM test ===== the results of running the slam package without odometry or IMU data using a laptop running ubuntu can be seen in the following video. The laptop was tethered to the vehicle using a USB cable. {{youtube>Og9lKyK_tNA?large}}\\ Unfortunately since the vehicle was tethered it was not possible to test it in the ductwork assembly so a hallway was used. Though the map generated was representative of the test area the the effect of no odometry data can still be seen in curved sides on the map. ===== ROS and SLAM on the Raspberry Pi ===== The following tutorial was used to install ROS on the raspberry pi [[http://wiki.ros.org/ROSberryPi/Setting%20up%20ROS%20on%20RaspberryPi|Raspberry Pi]]. NOTE: this installation process will take about 2 hours due to build times. ROS packages were found to be difficult to install on the raspberry pi due to isues with dependencies. After trying several different methods of installing the only way found to intall them was to individually include all of the packages. For example, to install laser_drivers. rosdep was used to install find the missing package dependencies. $ rosdep install laser_drivers This would list the dependencies but it would not install them. The individual packages were downloaded and installed using rosmake. Even still the package was not able to be successfully installed as I was unable to locate a ROS fuerte version of driver_common library No further solutions were found to installing the slam package on the raspberry pi to date due to raspberry pi arriving a week later than expected.