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

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



                 246    CHAPTER 7  ■  NAVIGATION



                                double convFactor = 0.0; // this will be second/inches
                                switch (drive.getSpeed()) {
                                case 10:
                                    convFactor = 1 / 4.0;
                                    break;
                                case 20:
                                    convFactor = 1 / 7.0;
                                    break;
                                case DEFAULT_SPEED:
                                    convFactor = 1 / 14.0;
                                    break;
                                case 30:
                                    convFactor = 1 / 20.0;
                                    break;
                                }
                                // will return seconds
                                return (int) (inches * convFactor);
                            }


                            //  surface rate when adjusting inches to seconds
                            private int getMillisecondsCarpet(double inches) {

                                double convFactor = 0.0; // this will be second/inches
                                switch (drive.getSpeed()) {
                                case 10:
                                    convFactor = 1 / 16.0;
                                case 20:
                                    convFactor = 1 / 36.0;
                                case 30:
                                    convFactor = 1 / 48.0;
                                }
                                return (int) (inches * convFactor);
                            }


                            // call to stop since in case of emergency
                            public void stop() throws Exception {
                                drive.stop();
                            }

                            // move for multiple vectors
                            public void move(MotionVector[] path) throws Exception {
                                for (int i = 0; i < path.length; i++) {
                                    move(path[i]);
                                }
                            }
   260   261   262   263   264   265   266   267   268   269   270