1 / 10

Sound, Touch Sensor, and Motors

Sound, Touch Sensor, and Motors. Wheeled Vehicles. Using the Pilot class: Constructor Pilot(float wheelDiameter, float trackWidth,Motor leftMotor, Motor rightMotor) Pilot(float wheelDiameter, float trackWidth, Motor leftMotor, Motor rightMotor, boolean reverse)

udell
Télécharger la présentation

Sound, Touch Sensor, and Motors

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sound, Touch Sensor, and Motors

  2. Wheeled Vehicles • Using the Pilot class: • Constructor • Pilot(float wheelDiameter, float trackWidth,Motor leftMotor, Motor rightMotor) • Pilot(float wheelDiameter, float trackWidth, Motor leftMotor, Motor rightMotor, boolean reverse) • The boolean reverse will set forward as backward , and vice versa. • Wheel diameter and track width determine the accuracy of NTX’s motion MMN Lab.

  3. Wheeled Vehicles cont’d • Straight line movement • void setSpeed(int speed) • If not specified, use default value • void forward() • void backward() • void stop() • void travel(float distance) • void travel(float distance, boolean immediateReturn) • By using boolean immediateReturn , thecalling thread can do other work while the travel task in progress. • int getTravelDistance() MMN Lab.

  4. Wheeled Vehicles cont’d • Movement along a curved path • void rotate(int angle) • If angle is positive, the robot turns to the left. • void rotate(int angle, boolean immediateReturn ) • By using boolean immediateReturn , thecalling thread can do other work while the rotation task in progress. • void steer(int turnRate) • ratio = 100 - abs(turnRate) MMN Lab.

  5. Wheeled Vehicles cont’d • Other methods • void resetTachocount() • Reset distance and angle counters • boolean isMoving() • boolean stalled() • Returns true if either motor actual speed is zero MMN Lab.

  6. Sound Static method • void playTone(int aFrequency, int aDuration) • void systemSound (boolean aQueued, int aCode) • code = 0            Short beepcode = 1            Double beepcode = 2            Descending arpeggiocode = 3            Ascending arpeggiocode = 4            Long, low buzz MMN Lab.

  7. Sound cont’d MMN Lab.

  8. Touch Sensor • Constructor • TouchSensor(SensorPort port) • Method • boolean isPressed() MMN Lab.

  9. Lab 3 • Sample Code • Move.java • Take the action after pressing any key • ENTER : move forward • ESCAPE : move backward • RIGHT : turn 90° • LEFT : turn -90° • Press ENTER + RIGHT to exit • Bump.java • Show the value returned by touch sensor • PlayMisic.java • Play the Music MMN Lab.

  10. Lab 3 cont’d • Implement this scenario: • 1: Move forward after pressing “ENTER” • 2: After bumping something, turn around and go back to the original position • 3: Turn around again and play the music at the same time MMN Lab.

More Related