References and Prerequisites
- The Linux Command Line - free PDF book you should have downloaded for Assignment 2
- Read Chapter 16 - Networking
Our multiple robots will be connected to a common network; a working knowledge of basic networking will save you lots of headaches when debugging your implementations.
Note: you may need to install the traceroute program:
sudo apt-get install traceroute
- Read Chapter 16 - Networking
- We will start using rviz in this assignment. Watch this 2 minute introduction: https://youtu.be/i--Sd4xH9ZE.
- We will use the ROSARIA package as the ROS interface to our P3AT robots. Please review the interface: http://wiki.ros.org/ROSARIA
Git Repository / ROS Package
As in the last couple assignments, your submission for this assignment will be a Git repository that contains a ROS package. The name of the repository on the gitlab.nps.edu server should be mrc_hw5 and it should be a ROS package (catkin_crate_pkg). You might look at the Assignment 3.
Exercise 0: MATLAB Control in Simulation
For this exercise you should include the two files from Assignment 4, Exercise 4 in your git repository:
As described in Assignment 4, these two files are a waypoint controller for a simulated Pioneer robot.
If you finished the last exercise in Assignment 4, simply copy those files into your mrc_hw5 repository.
Exercise 1: SSH/SCP Scavenger Hunt
Our small ROS computer lab has four desktops. The network names and addresses are on the Robotics Computation Wiki: Robotics Computation Lab. All of these computers have the standard user account (username=frl, password=********). I have placed a small textfile named
assign5ex1.txt in the
/home/frl directory of one of the four computers. Use SSH to log into each computer until you find which computer has the text file (you can use SSH to login to your own computer!).
Note: For addressing a remote computer you can use either the hostname (e.g., musubi.ern.nps.edu) OR the IP address (e.g.,172.20.88.139). Either should work.
Once you have located the file, use SCP to copy the file to your current home directory. Put this copy of the file in your git repository, add, commit and push.
Exercise: Serial Communication
We are going to use a serial RS232 connection for communication between a computer and the Pioneer P3AT robot. There is some specific information on serial communication in Linux on our Robotics Computation Wiki: Serial Ports in Linux (feel free to edit this information as you explore!)
Read through Serial Ports in Linux to learn out to connect a USB-to-serial adapter and use a serial terminal (we'll use
gtkterm which may need to be installed with
sudo apt-get install gtkterm).
To get familiar with this mode of communication we are going to do two activities:
- Connect a USB-to-serial adapter, open gtkterm and configure the serial port to this new port (see the dmesg command inSerial Ports in Linux )
Now connect a "loopback" on your USB-to-serial. We'll discuss this in class. Verify that what you transmit with gtkterm is echoed back to the terminal.
- With the same setup, connect your computer to a partners computer. You will need to introduce a "null modem" (we'll explain what that is) to make the connection. You will also need to negotiate a common baud rate. Verify that you can transmit and receive messages between the two machines.
There is nothing to turn in for this exercise, but it will save you lots of time to learn a little about serial communications and how to use some of the debugging tools.
Exercise 2: Pioneer Checkout and Waypoint Control
Put your Pioneer "up on blocks" so that the wheels can turn freely.
Do the tutorial Pioneer P3AT Checkout on the Robotics Computation Wiki (again, please fill in holes and improve the documentation!) At completion you should be able to drive your P3AT around with keyboard commands and visualize what the robot sees using rviz.
Note: If you downloaded the nre_p3at package last week, please update the package (I made a few small additions) by...
Do a little keyboard driving of your Pioneer to make sure you understand what is going on. In particular, I find that examining the rqt_graph helps conceptualize the ROS network. Also, rviz is a very helpful tool to understand what the robot thinks it is doing.
In the previous assignment you developed a MATLAB controller capable of driving a simulated P3AT to a waypoint (x and y position). This controller consisted of two m-files: pcontrol.m and p3odomCallback.m. Copy each of those files to your mrc_hw5 repository and rename them
In a terminal window run the last command from Pioneer P3AT Checkout.
This should connect to the robot and open a number of development/debugging tools.
Now in MATLAB, at the command prompt enter these commands to make sure things are connected...
You should see a list of ROS topics.
Now, use the MATLAB editor to open your three programs:
/matlab/pwaypoint.mwhic contains the pwaypoint(X,Y) function based on your pcontrol.m from the last assignment.
/matlab/pwaypointCallback.m. which contains the callback function - called when a new message is received.
/matlab/runwaypoints.m which is a simple script to exercise your controller - here is an example you may use...
You will need to make some adjustments to port your controller from simulation to hardware. You will need to adjust the topic names for subscription and publication. You should know how to use the rqt_graph and rostopic tools to determine the pertinent topics.
Once you have a functional controller, commit and push the three m-files.
If you are stuck, here is a working example that I tested in the lab. You are welcome to use this to debug your won algorithm: https://gitlab.nps.edu/bsbingha/mrc_hw5
Heading Control Wrap
Also, in the last assignment we had some trouble with heading control due to the 2-pi discontinuity in representing angles. Last week we used the modulo operator to deal with this. Perhaps a better method is to make sure that our angular error is always between +pi and -pi. Here is a snippet of MATLAB to explain...
Stopping Runaway Robot
As you develop your controller you will likely experience a scenario where your controller has passed a command to the robot and then crashed (or been purposely shutdown). Now the wheels continue to spin based on the last command the robot received. You might find it handy to have a short MATLAB script - I'll call it pstop.m - to set the velocities to zero. It might look something like this...
Now you can just type pstop at the MATLAB prompt and the wheels should stop spinning.
When you have completed the assignment, the structure of your mrc_hw5 directory should look like this...