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

Preston_5564C03.fm  Page 107  Wednesday, October 5, 2005  7:21 AM



                                                                                  CHAPTER 3  ■  MOTION   107



                            public void stop() throws Exception {
                                lm32.setRawCommand(getTotalMove(legGroup1, DOWN));
                                lm32.setRawCommand(getTotalMove(legGroup2, DOWN));
                                lm32.move(getSpeedInMs());
                            }
                            public void reverse() throws Exception {
                            }

                            public void pivotRight() throws Exception {
                            }


                            public void pivotLeft() throws Exception {
                            }

                            public void reverse(int ms) throws Exception {
                            }
                            public void pivotRight(int ms) throws Exception {
                            }

                            public void pivotLeft(int ms) throws Exception {
                            }
                            public int getSpeed() {
                                return speed;
                            }
                            public void setSpeed(int speed) {
                                this.speed = speed;
                            }
                            private int getSpeedInMs() {
                                return  (MIN_SPEED* 10) - (MIN_SPEED * speed) + MIN_SPEED;
                            }
                        }

                        Section Summary
                        With the classes created in this section, I encourage you to experiment with your own gaits or
                        different numbers of legs.
                            In this section, I created the following classes:

                           • BasicLeg.java: This class is similar to the ComplexArm created in the last section.
                           • Hexapod.java: This class implements the JMotion interface to move the legged robot the
                             same way you would a wheeled robot.
   121   122   123   124   125   126   127   128   129   130   131