III. Programming the Nomad Scout.

Return
  1. Description of the Nomad Scout.

  2. After building and programming a Lego robot you discovered how the body design affects the final performance of your robot, and you saw also how the limitations of the sensors and motors greatly influenced your program design. Now is time to use an already built robot, specially designed for robotics research. you'll find that the actuators and sensors are more reliable in this robot, so the programming task should be simplified, allowing us to concentrate on the problem at hand, and not in figuring out how to make the robot turn in right angles!

    For this class, we are going to use a Nomad Scout, developed by Nomadic Technologies. The Nomad is a three wheeled robot with two independent motors. It's small size make it very stable and useful for office or competition environments. The Nomad sensorial input consist of an array of: 15 sonars and 8 bumpers, distributed in its cylindrical body. You won't miss the infrared sensors, the sonars are accurate enough and have a bigger range.
     

  3. How to program the Nomad Scout.

  4. In order to program the Scout, you need to connect a laptop to the host port of the robot.
    This laptop must have a Linux operating system with the nomad software installed on it. On a typical installation, you should log in as the user nomad, and all the files that you need will be there.

    Programs for the Scout are written in C. Given that the standard Unix C compiler is used, you can use the whole C syntax.
    Compiling programs.
    Program executables can be compiled to be run by  the robot, or by the provided simulator software. Your program is the same, no matter where you run it, the difference is the libraries it is linked to. For the following, assume your program is called myprog.c.
    To compile a program to run on the robot, type:

    cc myprog.c Ndirect.o
    To compile a program to run on the simulator, type:
    cc myprog.c Nclient.o
    A makefile is provided to make the compilation process simpler. Substitute your program name in the makefile, then type
    make direct
    for creating an executable for the robot (called robotexe), or
    make client
    for creating a simulator executable (called simexe).
     
  5. Basic functions for the Scout.

  6. Any program you write for the Nomad Scout must have the following sections:
    • Connect the computer to the robot,
    • configure the sonars,
    • perform desired task: the robot should read sensor and perform appropriate actions, and
    • disconnect from the robot.
    Commands for each of this sections are given below.

    Host computer communication.

    • int connect_robot(id, model, device, v) connects the host computer to the robot identified by id, using port device; if device is a serial port then v is the communication speed in bauds. If device is a tcp port, then v is a port number. model must be the constant MODEL_SCOUT for the Scout robot. For a typical connection using serial port COM1, a call to this function looks like the following:
    •      connect_robot(1, MODEL_SCOUT, “/dev/ttyS0”, 38400);
    • int disconnect_robot(id) disconnects the host from the robot identified by id. For example, for disconnecting from the robot from the previous example, type
    •      disconnect_robot(1);
    Moving the robot.
    • vm(int r_wheel, int l_wheel, int dummy) sets the speeds of the right and left wheels to r_wheel and l_wheel, respectively. Speeds are given in 0.1 in/sec. Variable dummy is not used, but something must be passed to it. for example, to make the robot move forward at 10 in/sec, type:
    •      vm(100, 100, 0);
    • st() stops the robot. When this command is given, the robot starts decelerating, but the program continues to execute. If the next command should be executed when the robot has actually been stopped, a wait command (ws) must be given after the stop command. For example:
    •           st(); /*tells the robot to stop*/
                ws(1,1,0,255); /*wait until both wheels stop*/
    • ac(int r_wheel, int l_wheel, int dummy) sets acceleration of left and right wheels. Accelerations are given in 0.1 in/sec2. To set both wheels to accelerate 20 in/sec2, type:
    •      ac(200, 200, 0); /*ac= 20 in/sec2 */
    • pr(int r_wheel, int l_wheel, int dummy) attempts to move the wheels to positions r_wheel, l_wheel relative to their current position. Positions are given in 0.1 in. A ws command should be given to allow time for the robot to complete the movement before the next program line is executed. For example, to move the robot 20 inches forward, write:
    •      pr(200, 200, 0);
           ws(1,1,0,255);
    • Differential drive macros. For some applications, it may be useful to give movements commands in terms of how much we want the robot to translate, and how much we want it to rotate. the following macros are provided:
      • scout_vm(int trans, int steer) to give the translational and rotational speeds
      • scout_pr(int trans, int steer) to give the relative translation and rotation from the current robot position
      Translations are given in 0.1 in., steers in 0.1 degrees.


    Configuring sonars.
    int conf_sn(int rate, int order[]) fires a sonar every rate*4 ms. Sonars are fired in the order specified in the array order. Variable rate is in the interval from 0 to 255. If not all of the sonars are used, order should end with a 255. For example:

            int s_order[6] = {0, 1, 4, 12, 15, 255};
            conf_sn(15, s_order);
    General robot status reading.
    All sensor readings are stored in the global array State. To put fresh readings in State, use the command gs( ). There are also commands for updating only parts of the State array.

    Reading sonars.
    get_sn( ) updates sonar readings in the State array. Sonar readings are stored at indexes STATE_SONAR_0, …, STATE_SONAR_15 and are given in  inches. For example, the following code gets the latest reading of sonar number 1:

         get_sn();
         dist = State[STATE_SONAR_1];
    Reading bumpers.
    get_bp( ) obtains a fresh reading from the bumper array of the robot. This function updates array State at index STATE_BUMPER. When State[STATE_BUMPER] is different from zero, it means a bumper has been pressed. The n-th bit of State[STATE_BUMPER] corresponds to the n-th bumper.

    Using the odometry system.
    get_rc( ) obtains the current position and heading of the robot. The function updates the State array at STATE_CONF_X, STATE_CONF_Y and STATE_CONF_STEER. Coordinates are stored in tenths of inches, heading is stored in tenths of degrees.

    When the robot is started, it is considered to be at position (0,0) and heading 0. Translation and rotation commands will cause the values to change (but remember that the State variable is only updated after a gs() or a get_rc() command). This values should be used only as an auxiliary tool for telling the robot bearings, since errors will accumulate the more the robot moves. Sometimes, it is a good idea to reset the coordinate system (for example, when the robot has reached a certain position). To set the coordinate system use the following:

    • dp(int x, int y) to set the current location as position (x,y),
    • da(int angle, int dummy) to set the current heading as being angle degrees.


    It is also possible to get the current translation and steering speeds:
    get_rv( )  updates State vector at STATE_VEL_TRANS and STATE_VEL_STEER.
     

  7. How to use the simulator.

  8. The simulator is a useful tool for developing programs. Virtual environments can be easily created to test the robot for particular tasks. A well designed program that works fine in the simulator, usually will also work well in the real robot, and you'll probably just need to fine tune for compensating for inaccuracy in sonar readings.

    To use the simulator enter the  X Windows environment by typing

    startx
    Then, start the simulator by typing the following in a command terminal:
    Nserver &

    See the User's manual that comes with the Scout for a detailed description of the simulator's options.
    To test a program make sure your program is compiled as a client. Start the simulator, then run your program on the console. The program will control the virtual robot in the simulator.
     

  9. Sample programs.
    • Report current sonar readings.
    • Move forward until an obstacle is found.
    • Move forward until the first opening.
    • Simple command interface.
  10. Where to get a Nomad Scout.

  11. The Scout can be obtained from its manufacturer, Nomadic Technologies at http://www.robots.com.