Title image Spring 2017

Robot Motion Strategies

For this assignment you'll implement some simple reactive programs on the real robot. The programs will let the robot do some basic tasks like wandering around and not running into anything (it is hoped).

For this assignment, and all of the remaining ones, you may work with a partner. Given the number of students in the course, there can be one group of three or someone can choose to work by themselves.

Magellan Information

The two netbooks on top of the robots are what you will use to write and test your programs. The netbook hasufel.cs is on Frodo, and arod.cs is on Sam. Please do not mix them up. You can ssh into them from another computer using the following.

ssh -Y usr@hasufel.cs

In the usr account on each netbook is a directory called cs363-S17. In that directory are subdirectories with your username. Please respect one another's code.

Also in the cs363-S17 directory is a subdirectory called examples. In there you can find an example called move.c and a makefile. Use these files as templates for your own code. The file is an implementation of the second task, but without any mechanism for stopping if there is an obstacle.

Just like with the nomads, there is an array of integers that you access in order to get sonar/IR and configuration information. However, the State variable is no longer a global variable. In the move.c example, it is an array declared in the main function. Passing the State array into the connectRobot command links the array to the Mage process that communicates with the robot hardware.

The macros for accessing the State variable on the Magellans are slightly different. Look in the file /usr/local/include/Mage.h to see what the macros are. You will need to include Mage.h in your programs and link the Mage library to your executable in order to connect to the robots. Use the example makefile as a template. The most important macros are listed here.

STATE_IR_O to STATE_IR_15IR readings (mm)
STATE_SONAR_O to STATE_SONAR_15 sonar readings (mm)
STATE_BUMPERBumper readings as first 16 bits
STATE_XX location (mm)
STATE_YY location (mm)
STATE_TOrientation (mrad)

The API for the Magellans is very simple.

vm( long t, long s )sets the translation and steeering velocities (mm/s, mrad/s)
sonarOn(void)turn sonars on
sonarOff(void)turn sonars off
irOn(void)turn IRs on
irOff(void)turn IRs off

There is no simulator for the Magellans, simply run your program and be prepared to hit the stop button, if necessary. As noted in the lab, putting the robots on top of a small trash can while testing can save both you and the robot a lot of wear and tear.


The basic idea is to take the tasks you implemented on the Simulator and demonstrate them on the real robot. We will use the two Magellans, and can pull out the third, if necessary.

If your work with a partner, please produce only a single writeup and code base.

  1. Write a program that takes in a command line argument that is the number of degrees to turn. Positive is a left turn, negative is a right turn. Have the robot turn that number of degrees in a smooth fashion. Unlike the nomad simulator, the Magellans work in millimeters and milliradians, so adjust your programs accordingly.
  2. Write a program that takes in a command line argument that is the distance the robot should move forward. Positive is forward, negative is backward. Have the robot move that distance in a smooth fashion, stopping if it is about to run into any obstacles.
  3. Write a program that takes in a position on the plane relative to the robot's current position and has the robot move smoothly to that position. The robot's starting location when your program begins is always (x, y, r) = (0, 0, 0), where x is forward, y is left, and r is orientation relative to a global direction axis. A simple strategy is to aim the robot at the desired point and then go forward.
  4. For each of your first three programs, figure out how to estimate the accuracy of the robot in achieving the specified goal. For example, use a measuring tape or a protractor to measure the distance and angular errors. Take at least ten measurements of each case, starting your robot in the same position each time. You are welcome to put some masking tape on the floor to mark starting or goal locations. Report the mean and standard deviation of the error for each task. What factors influence these errors?
  5. Write a program that lets the robot wander around without bumping into things. Use the sonar and IR sensors to identify obstacles in the robot's path. It is often beneficial to group each IR/sonar pair into a single virtual sensor by taking the minimum reading from the two, if the IR is reporting a value less than a certain cutoff. It may also be beneficial to group sets of virtual sensors together to smooth out the noise caused by reflections.
  6. Write a program that keeps the robot a fixed distance (e.g. 1m) away from whatever is in front of it. Make sure the robot pays attention to it's rear sonar as well so it does not run into anything while trying to get away from whatever is in front.



The writeup for each project should be a brief summary of what you did along with some code examples, terminal output, or screen shots, depending upon the assignment. Please organize the writeup as follows.

  1. Title of the project, your name, and any partners' names
  2. An abstract describing what you did in 200 words or less.
  3. A brief description of code you wrote and experiments you ran.
  4. Results. Videos would be good here.
  5. A brief description of what you learned.


Make your writeup for the project a wiki page in your personal space. If you have questions about making a wiki page, stop by my office or ask in class.

Once you have written up your assignment, give the page the label:


You can give any page a label when you're editing it using the label field at the bottom of the page.

Hand in your code on the Courses server. Put it in a project2 directory in your Private folder.