This assignment focuses on ROS (Robot Operating System). ROS is a framework used to program robots. It is quite complicated (some might say too complicated). However it is widely used on both industrial and commercial settings.
GNU/Linux uses environment variables to store configuration
information about a variety of things. You can use
to view the environment variables in your shell on the Rasberry Pi.
In bash (and most shells), environment variables are local to your
bash session, so they are often set in configuration files that are
run every time your shell starts, such as
X=3to set the value of an environment variable named
Xto the value
echo $Xto display the variable. Note that you must prepend
$to the variable name when reading it, but not when setting it.
echo $Xto see the value of the environment variable
X. What happens? Does this work? Why or why not?
envto see all the environment variables set in your shell. Pick one. Research the one that you picked. Describe 1) What program sets the environment variable and 2) What the variable controls. For example, the
EDITORenvironment variable is set in the
.bashrcfile when you log in. 2) It is the name of the program called by sudoedit, git commit, and other programs when they need to edit a file.
setup.shscript sets the ROS_MASTER_URI and ROS_HOSTNAME or ROS_IP environment variables in your session. In a second SSH session in which you have not run screen (so just after you log in), assess the value of the environment variables. Are they set to the correct values? What is setting ROS_MASTER_URI? What is setting ROS_IP or ROS_HOSTNAME? How did you figure this out? (You might find the
grepcommand useful. Use
man grepto find out how to use it.)
grepto search the file system for places where environment variables are set. I ran
grep ROS_MASTER_URIbut it didn't find any results. Then I tried
grep ROS_IPand found it was set in
.bashrc. I noticed that
.bashrcwas sourcing a few ROS configuration files. I searched each of those files for ROS_MASTER_URI and found it was set in /opt/ros/indigo/setup.bash as a default value if it was not already set.
For this section, commit the package into the git repository you use for handing in the assignment. You do not need to commit the whole workspace; just the package.
rosnode listto display what nodes are running when you start the screen session. Use
rosnode infoto find out more about each node. What topics does
pi@bat42:~ $ rosnode info /flow_pub Node [/flow_pub] Publications: * /pidrone/set_mode_vel [pidrone_pkg/Mode] * /pidrone/plane_err [pidrone_pkg/axes_err] * /rosout [rosgraph_msgs/Log] * /pidrone/picamera/camera_info [sensor_msgs/CameraInfo] * /pidrone/picamera/image_raw [sensor_msgs/Image]
rostopic listto examine the publisher and subscriber you wrote (while they are running). Use
rostopic echoto display the results of the publishing topic. Submit a screenshot showing the results of these two commands.
screensession we use to fly the drone. Use
rostopic hzto examine the results of various topics. What is the frame rate we are publishing images from the camera?
rostopic hzon the camera info topic to find the answer.
Now write a ROS subscriber to read the values from the infrared sensor
rostopic list to determine the value of the
infrared topic. Compute the mean and variance of the sensor values
over a ten second window. You can store the data in memory in your
Python program and then compute statistics based on the stored data.
(For longer windows, you might want to log to disk.) What is the
standard deviation of the sensor when pointed at the same surface for
ten seconds? You can use NumPy to
compute the statistics.
ROS also supports services with a more traditional function call abstraction so that you can send a remote procedure call and receive a response. Describe when services might be a good idea to use? Describe problems that services might have related to robotics? Especially think through issues such as timing and failure modes.
Services are nice because they support the function call abstraction that we are all used to as computer scientists. However the function call abstraction is particularly leaky for robotics for a few reasons. First, the time imposed by the overhead for an RPC is not what you expect, simply because of the network overhead. Second, an RPC on a robot might take a long time to execute. For example, if you call a function like “takeoff” as a function, it might take the drone 10 seconds to finish executing the function. In the meantime, you
Hand in your answers using this link. For problems 1, 2, and 3, we would like you to upload a screenshot for each question that asks you to do some action in the command line. For each question that asks you to write code, we would like you to upload the raw code. For problem 4, we would like a written response in a pdf.