Technology/Engineering/Robotics
978-448-6362
Groton-Dunstable Regional High School Groton, MA
One of the requirements of this project is to have the robot return the object to you. Since the distance travelled will always vary, you need to figure out how to make the robot return to you and stop after the appropriate distance has been reached. There are three ways to achieve this.
1) Turn around and use your distance sensor. This won’t work if it’s lined up with your claw because the ball will block its view. You can install a 2nd sensor. Use an ultrasonic rangefinder sensor for this.
2) Record the time it takes to travel to the object. Visit Lesson 7.2 and read about timers. You can reset your timer before it begins the movement to the ball. When it arrives at the ball, set a variable equal to the current timer value. Use this variable to drive for the timed value and then stop and release the ball. This will be unreliable if you use code that slows the robot as it approaches the ball.
3) Read the encoder values from the motors. It is not immediately obvious how to do this while in drivetrain mode. Read through the sample code below to learn how to read encoder values (and inertial sensor values) and use those values to determine how far your robot should travel to return to you.