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

Preston_5564C07.fm  Page 247  Monday, September 26, 2005  5:38 AM



                                                                               CHAPTER 7  ■  NAVIGATION  247



                            public JMotion getDrive() {
                                return drive;
                            }


                            public NavStamp getNavStamp() {
                                return navStamp;
                            }


                            public static void main(String[] args) {
                                try {
                                    WebSerialClient sPort = new WebSerialClient("10.10.10.99", "8080", "1");
                                    Navigation nav = new Navigation(sPort);
                                    // move east 36 inches
                                    nav.move(new DistanceVector(90, 36));
                                    // move north 36 inches
                                    nav.move(new DistanceVector(0, 36));
                                    // move west 36 inches
                                    nav.move(new DistanceVector(270, 36));
                                    // move south 36 inches
                                    nav.move(new DistanceVector(180, 36));
                                } catch (Exception e) {
                                    e.printStackTrace();
                                    System.exit(1);
                                }
                            }
                        }
                        Section Summary

                        With the code in this section, you should be able to perform dead reckoning using Java with a
                        differential drive and a compass. The three classes I created in this section were

                           • MotionVector: Heading in degrees and magnitude in seconds
                           • DistanceVector: Heading in degrees and magnitude in inches
                           • Navigation: Navigational class that implements dead reckoning for both DistanceVectors
                             and MotionVectors
                            What you will notice as you begin to experiment with this type of navigation are the types
                        of errors you will get. I experienced the following types of errors:

                           • Errors in conversion factors relating to surface rates and headings.
                           • Position accuracy decreased as the number of movements increased.
                           • The robot did not avoid obstacles.

                           • The compass readings were not consistent at different locations in the test environment.
                           • Wheel slippage, inclines, and obstacles caused large inaccuracies in navigation.
   261   262   263   264   265   266   267   268   269   270   271