Page 27 - The Definitive Guide to Building Java Robots
P. 27

Preston_5564C01.fm  Page 8  Friday, September 16, 2005  6:36 AM



                 8      CHAPTER 1  ■  A PRIMER



                        you need to do to navigate until you’re in front of the fridge and at a spot where you can raise
                        your arm and open its door.
                            Now you were cheating in this example because you knew what direction you were facing
                        when you started. So go back to the living room, spin around about ten times (don’t fall down)
                        and then repeat this experiment.
                            Oops, you were cheating again since you had a map of the room from memory and you
                        knew where you were starting from. So now have someone spin you around, or take you to a
                        new room, and then repeat the experiment.
                            Starting to understand the difficulty? Maybe you might be able to do better if you had a
                        compass or someone to tell you the direction you were facing. Maybe you’d do better if you
                        knew how far you were from a wall. You might do better if you kept track of how many steps
                        you took and you knew how far each step was.
                            The point of this experiment is that after a few tries at getting to the refrigerator with the
                        sensors you can purchase for your robot, you’ll understand just how difficult robot perception is.

                        Navigation

                        From the last experiment you know just how difficult it is with a human brain to get around in
                        a simple environment even when you have a map and a number of sensors and a good memory.
                        Nevertheless, if you’ve ever been late to an appointment or gotten lost on the way to a new
                        address, you know that sometimes even eyesight and a brain are not enough because there are
                        so many unforeseen obstacles or the information that you have to work with is not “perfect.”
                            Currently one of the holy grails of robotics and artificial intelligence is consistent, accurate
                        navigation. You’d think this would be easier given GPS and complex military navigation systems,
                        yet it remains an elusive goal and the U.S. government is willing to pay two million dollars to
                        the first group that comes up with a vehicle that can navigate across the desert 175 miles within
                        a 12-hour time limit. You can find more information on this challenge at www.darpa.mil/
                        grandchallenge/.

                        1.2 Java Concepts

                        Java is an object-oriented programming language developed at Sun Microsystems in 1991. In
                        this section, I’ll describe some important concepts you’ll see in this book that might not be
                        obvious to a beginner (see Table 1-2).


                        Table 1-2. Important Java Concepts
                        Concept                Description
                        Constructors           A constructor is a method in a Java class that defines how it’s
                                               instantiated. Keep a close eye on how you want your objects to be
                                               created. If you’re too flexible, you could run into timing or other
                                               exceptions. If you’re too rigid, your class will be too hard to use.
                        Exceptions             Errors in your robot programs will happen. Make sure you handle
                                               exceptions; they’ll provide you with valuable debugging information
                                               for your code.
   22   23   24   25   26   27   28   29   30   31   32