(→Important Dates) |
(→ROS support packages) |
||
| Line 40: | Line 40: | ||
==ROS support packages== | ==ROS support packages== | ||
| - | ; | + | ;ROS installation instructions (optional) |
| - | : | + | :Although cs148 robots have ROS and support packages preinstalled, you can look under the [http://code.google.com/p/brown-ros-pkg/ "Getting Started" section of brown-ros-pkg] to install these packages on your own computer. The current version of ROS is C-Turtle. For [http://en.wikipedia.org/wiki/Ubuntu_(operating_system) Ubuntu Linux], C-Turtle installation is essentially an [http://en.wikipedia.org/wiki/Apt-get apt-get] of the [http://www.ros.org/wiki/cturtle/Installation/Ubuntu ROS binary package] and running an automated script ([http://code.google.com/p/brown-ros-pkg/source/browse/tags/getros/getros.py getros.py]) from brown-ros-pkg. Installation for other operating systems is similar, but can involve some customization of the installation process. |
| - | ; | + | ;[http://code.google.com/p/brown-ros-pkg/wiki/irobot_create_2_1 irobot_create_2_1] (brown-ros-pkg) |
| - | :teleop_twist_keyboard | + | :ROS driver for the iRobot Create mobile robot base |
| + | |||
| + | ;[http://code.google.com/p/brown-ros-pkg/wiki/teleop_twist_keyboard teleop_twist_keyboard] (brown-ros-pkg) | ||
| + | :ROS package for keyboard teleoperation of a mobile robot base. Adapted from the [http://playerstage.sourceforge.net/doc/Player-1.6.5/player-html/group__player__util__playerjoy.php playerjoy] utility for Player. | ||
==Assignment Instructions== | ==Assignment Instructions== | ||
Contents |
This project is structured to acquaint you with the basics of writing robot controllers using ROS (the Robot Operating System) in the context of building an "enclosure escape" robot controller. ROS runs onboard a robot (or any computing device) and provides a software interface to the robot hardware, such as sensors and actuators, over an IP network. Similar to a hardware abstraction layers for modern operating systems, ROS is considered robot middleware to facilitate portability across robot hardware and reusability of robot software components.
A video of Lisa Miller's implementation of this assignment from Spring Semester 2009.
Project Assigned: Sept 3, 2010
Project Due: Sept 17, 2010, 11:59pm
A primary motivation of ROS is to facilitate modular design and reuse of software components, portability across robot hardware, and programming language independence. Central to ROS is the concept of a ROS node, ROS's basic building block. Each node is a modular process with some specialized purpose. For example, there may be a node that handles the basic movement of the robot, and there may be another node that simply publishes information from a camera. From these simple nodes, nodes performing more complex behavior can be created. For example, a node can be created to recognize objects from information provided by the camera driver node. Further, another node take in information about recognized objects and output commands that move the robot to follow selected objects.
Nodes exchange information over an IP network as messages that are topics (handled in a publish-subscribe manner) or services (handled in a request-response manner). To moderate communication in ROS, there a special node called the master node. Conceptually, this node is a matchmaker that is responsible connecting publishers to subscribers (or requesters to services) for data messages of a particular ROS topic. Once nodes are matched, the publishing node will talk directly to its subscriber(s). An illustrations of how ROS performs matchmaking is shown (with an additional example, File:Rosmaster.pdf). ROS also uses a parameter server to pass arguments to nodes from the command line using rosparam.
Although ROS nodes can be developed in any programming language that can support ROS messages, the only fully supported ROS client libraries are currently for Python and C++. brown-ros-pkg provides a package Javascript support for ROS using websockets.
A more complete conceptual and technical overview of ROS is described on the main ROS web site.
As surveyed by Huang et al., it should be noted that ROS is only one of many viable robot middleware frameworks. Also, the core functionality of ROS is to perform socket-based inter-process communication, or "communications and marshalling" as described for the LCM library. The "robot" aspects of ROS are due to its support for robot-related devices and software, which are a complementary but orthogonal features to inter-process communication.
The brown-ros-pkg is a collection of nodes that includes basic sensing and movement functionality for the iRobot Create. For this assignment, you will be using the irobot_create_2_1 package. irobot_create_2_1 publishes messages of the robot's current sensing (e.g., whether the robot's left or right bumper is pressed) and has services for controlling the robot (e.g., the robot's driving speed and rotation).
In addition to providing a software interface for robots, ROS also provides a build environment for software development that resembles a package management system. The package is the primary element in the ROS build environment "that logically constitutes a useful module." A package is typically a directory containing a collection of ROS nodes with related files, such as service and message definitions, makefiles, and external libraries. Packages can be compiled using the rosmake or rosdep commands, handling the process of building executable nodes and "some special ROS magic." The ROS build system uses CMake at its core. Packages can be created using the roscreate-pkg command, providing a skeleton of a valid package as a starting point. Dependencies for a package can be found using the rospack command.
As you may have noticed, ROS tends to rosinvent existing unix tools for easier navigation of ROS packages. For example, rosbash includes several ros-ified commands such as roscd, rosls, etc.
For this assignment, you will be expected to work with an existing installation of ROS to write a simple random traversal controller to escape a static environment.
Before writing your own controller, you must first setup the robot and verify that it is running properly. Once your controller is completed, you will implement a random traversal controller run experiments to evaluate how well your system can escape from an enclosed area.
Your tasks for this assignment are as follows.
> ssh obot@IPADDRESS
> roscore
> rosrun irobot_create_2_1 driver.py
> rosrun teleop_twist_keyboard teleop_twist_keyboard.py
If successful, you should see the following interface appear in the teleoperation terminal and control the robot (driving and turning speed) from your keyboard.
Be careful: the robot will continue to execute the last command given.
Reading from the keyboard and Publishing to Twist! --------------------------- Moving around: u i o j k l m , . q/z : increase/decrease max speeds by 10% w/x : increase/decrease only linear speed by 10% e/c : increase/decrease only angular speed by 10% anything else : stop CTRL-C to quit
It is highly recommended that you go through the ROS tutorials on ros.org. These instructions roughly follow the ROS tutorial on creating a simple publisher and subscriber. We skip over several helpful details and features in the interest of being concise.
> mkdir /home/obot/ros/<GROUPNAME> > cd /home/obot/ros/<GROUPNAME>
> roscreate-pkg enclosure_escape rospy std_msgs irobot_create_2_1
> roscd enclosure_escape
> mkdir nodes
#!/usr/bin/env python
import roslib; roslib.load_manifest('enclosure_escape')
import rospy
from geometry_msgs.msg import Twist
from irobot_create_2_1.msg import SensorPacket
# global variables
bump = False
# listen (adapted from line_follower
def processSensing(sensorPacket):
global bump
bump = sensorPacket.bumpLeft or sensorPacket.bumpRight
#newInfo = True
def hello_create():
pub = rospy.Publisher('cmd_vel', Twist)
rospy.Subscriber('sensorPacket', SensorPacket, processSensing)
rospy.init_node('hello_create')
#listen
global bump
twist = Twist()
while not rospy.is_shutdown():
if bump:
str = "hello create, you have bumped into something %s"%rospy.get_time()
rospy.loginfo(str)
twist.linear.x = 0; twist.linear.y = 0; twist.linear.z = 0
twist.angular.x = 0; twist.angular.y = 0; twist.angular.z = 0
bump = False
else:
str = "hello create, you can spin now %s"%rospy.get_time()
rospy.loginfo(str)
twist.linear.x = 0.1; twist.linear.y = 0; twist.linear.z = 0
twist.angular.x = 0; twist.angular.y = 0; twist.angular.z = 0.1
pub.publish(twist)
rospy.sleep(1.0)
if __name__ == '__main__':
try:
hello_create()
except rospy.ROSInterruptException: pass
Make the source for this node is executable:
> chmod +x nodes/enclosure_escape.py
> rosmake enclosure_escape
> rosrun enclosure_escape enclosure_escape.py
The enclosure escape package should be committed to your group's repository. The package we have just created is in a temporary working space on the laptop that could be deleted at any time. Checking your package into a repository on the CS filesystem ensures your code is accessible by everyone in your group and the course staff, protected, backed up, and version controlled to prevent conflicts during collaborative coding. Please read this git tutorial thoroughly at least through the end of chapter four; for now the important parts are below, but you should know everything in this tutorial. Before starting here, be sure you've told the TAs your group name so that you have a repository in the course directory.
We expect your repository to have one folder for each project. While you will be able to view or tamper with the repositories of other groups, doing so is a violation of the honor code and we'll notice.
Because your repositories will be saved on the department file system, but the code needs to be on the netbooks, we will be using a git daemon to send the git actions.
First, on a department machine, run the git daemon using this command:
> git daemon --verbose --export-all --enable=receive-pack
Now, in your ssh connection (or on the netbook), get a copy of your empty repository, use this command:
> git clone git://<IP ADDRESS>/course/cs148/repo/<GROUPNAME>.git
Put the code you've been working on in <GROUPNAME>/escape and then, from that directory, run:
> git add . > git commit -a -m "My first commit!" > git push
The last line puts your code into the repository in the course directory.
In order to synchronize your code with the repository, use this command:
> git pull
conduct least 3 trials at 3 different start locations in 3 different environments. measure total time, number of collisions. all of your trials must use the same controller without modification.
Document your controller and experimental results in a written report. You are welcome to experiment with various enclosure escape algorithms and evaluate the relative performance of each. The details of how this report is graded are discussed in the following section. Example reports are provided in the ``Documents" section of the \href{http://www.cs.brown.edu/courses/cs148/}{course website}. When finished, your report should be committed to the enclosure_escape/docs directory of the repository that you checked out.
Your grade for this assignment will be determined by equal weighting of your group's implementation (50\%) and your individual written report (50\%). The weighted breakdown of grading factors for this assignment are as follows: