Labels

Showing posts with label iRobot Create. Show all posts
Showing posts with label iRobot Create. Show all posts

Tuesday, July 8, 2014

ROS Hydro SLAM with Kinect and iRobot Create

I have recently been trying to get into learning mapping with robotics and as a consequence I've been trying to get a SLAM (Simultaneous Localization And Mapping) algorithm running. Before investigating the mechanics and mathematics that cause SLAM to work, I wanted to get a known SLAM algorithm running so I can see it myself. With a laptop, Xbox Kinect, iRobot Create, and ROS, I knew I had all the tools I needed to get SLAM running.

The first step was to install ROS. Since Hydro is the newest version and has many drastic changes, I decided to go with it. Hindsight, that may have not been the best choice, but it's too late now! Also I am using Ubuntu 12.04, since Ubuntu is the officially supported OS and at the time, 12.04 is the LTS version that ROS supports.

Once ROS is installed, I had to get drivers for the iRobot Create and the Kinect, which were little adventures on there own with ROS Hydro and Ubuntu 12.04. See my posts on the Create. For the Kinect, I used the freenect stack, since it appears that openni (the most commonly used ROS-Kinect interface) has some issues with the hydro/Ubuntu 12.04 combination that I just didn't want to deal with.

Now that the sensor data is accessible, a SLAM algorithm can be selected. I went with gmapping, since it seemed to be the most widely used SLAM package on ROS. Gmapping requires odometry data, a laser scanner, and the position of the laser scanner relative to the base (create).

To fake a laser scanner with the Kinect, see my post here.

The odometry data and the odometry frame is published by the create node. The odom_frame is a standard frame from the tf package. The tf package allows the user to relate each part's coordinate frame to other coordinate frames on the robot. The primary coordinate frame that most everything needs to operate in relation to is the base_frame, which is provided by our Create. Tf wasn't the easiest thing for me to understand, and at the time of writing this, I still don't totally understand it.

To see each of your robot's coordinate frames, use:
rosrun tf view_frames
evince frames.pdf
tf view_frames will generate a pdf which displays your robot's tf tree. Each node in the tree is a separate coordinate frame, and each node in the same tree can access any other node's data with respect to the requesting node's frame.

So, gmapping needs to access the laser scanner's data with respect to the base_link frame. If you view your tf tree at this point, you will notice that the kinect's frames are not connected to the create's. To link the two, use:

rosrun tf static_transform_publisher "base_to_kinect" -0.115 0 0.226 0 0 0 base_link camera_link 100

This command creates a static transform between the kinect and the base. The numbers passed are the x,y,z coordinates of the kinect to the center of the create. If you view your tf tree after running the previous command you should get something that looks like this:


Now that all of the frames are linked, gmapping can be ran:

rosrun gmapping slam_gmapping tf_static:=tf

The tf_static:=tf renames gmapping's subscription to the /tf_static topic to the /tf topic. In ROS hydro the tf package has been deprecated, and now uses /tf2, which instead of just publishing one /tf topic, publishes a /tf and /tf_static. So, for gmapping to find the base_frame to link the map frame to, we have to redirect it to the /tf topic.

Once gmapping is running, you should be able to open up Rviz and see the data.

rosrun rviz rivz

Just be sure to add the map data from the /map topic to the display.


Wednesday, June 11, 2014

iRobot Create ROS Hydro Drivers

I recently started messing around with ROS. I have a few common robotics development platforms laying around my lab, including an iRobot Create, which is essentially the Roomba without the vacuum parts. A lot of ROS projects are developed using the Create, so there's plenty of resources to pull from online.



Brown University has provided drivers for the Create, but the most recent ROS distro supported by the driver is Groovy. In my attempt to stay on the cutting edge, I had installed ROS Hydro, the newest distro at the time of writing this post. Fortunately, Hydro and Groovy aren't very different from each other. The biggest change since Groovy was the introduction of the catkin system which replaced rosbuild. 

From a previous Groovy installation that I was no longer using, I installed the brown drivers using:
sudo apt-get install ros-groovy-brown-drivers

After installing, I copied the "irobot_create_2_1" directory from inside "/opt/ros/groovy/stacks/brown_drivers" folder to my workspace's "src" directory. For example:
cp -r /opt/ros/groovy/stacks/brown_drivers ~/catkin_ws/src

Then, in my workspace directory, I ran catkin_make, and the driver ran perfectly! To run the driver use:
rosrun irobot_create_2_1 driver.py

 Thanks to Brown driver maintainers for updating the driver to be compatible with the new catkin system, everything works just fine so far. To test the driver, you can download BumpGo.py and place it in the "irobot_create_2_1/bin" directory. To test, simply enter:
rosrun irobot_create_2_1 bumpGo.py

The robot should then drive until the bump sensor is triggered, turn and continue. My future goals are to create a simple node to drive the robot using keyboard commands, interface an Xbox Kinect, and run some kind of SLAM algorithm. I really just wanted to make sure I added some documentation as to what I've done to run the create on ROS Hydro, regardless of how simple it was. (In the very likely event that I get distracted, come back months from now to continue the project, and forget everything I learned since then)

UPDATE:
Here's a link to the create drivers package:
https://dl.dropboxusercontent.com/u/47687797/irobot_create_2_1.tar.gz

UPDATE 2:
After reinstalling ROS on a new computer without my previous groovy installation, I had some trouble getting the above package to run. When I ran "rosrun irobot_create_2_1 driver.py", I would get a message which said " the rosdep view is empty: call 'sudo rosdep init' and 'rosdep update ". At first, the roomba would not connect and displayed some other error message I am now unable to reproduce. After replacing the battery the next morning, the create is now connecting without any problems! Let me know in the comments if you have any issues regarding this.