◦
0–1000:
the robot is far to the right of the line. In this case, to turn sharply left, we set
the right motor speed to 100 and the left motor speed to 0. Note that the maximum
speed of the motors is 255, so we are driving the right motor at only about 40%
power here.
◦
1000–3000:
the robot is approximately centered on the line. In this case, we set
both motors to speed 100, to drive straight ahead.
◦
3000–4000:
the robot is far to the left of the line. In this case, we turn sharply to the
right by setting the right motor speed to 0 and the left motor speed to 100.
3. Depending on which motors are activated, the corresponding LEDs are turned on for a more
interesting display. This can also help with debugging.
To open the program in Atmel Studio, you may go to
examples\atmegaxx8\3pi-linefollower
and
simply double-click on
3pi-linefollower.cproj
. Compile the program, load it onto your 3pi, and try
it out. You should find that your robot is able to follow the curves of your line course without ever
completely losing the line. However, its motors are moving at a speed of at most 100 out of the
maximum possible of 255, and the algorithm causes a lot of unnecessary shaking on the curves. At
this point, you might want to work on trying to adjust and improve this algorithm, before moving on to
the next section. Some ideas for improvement are:
• Increase the maximum possible speed.
• Add more intermediate cases, with intermediate speed settings, to make the motion less
jerky.
• Give your robot a memory: have its maximum speed increase after it has been on the line
consistently for a few cycles.
You might also want to:
• Measure the speed of your loop, using timing functions from
of the
[https://www.pololu.com/docs/0J18]
to time a few thousand cycles or by blinking the
LEDs on and off every 1000 cycles.
• Display sensor readings on the LCD. Since writing to the LCD takes a significant amount of
time, you should do this at most few times per second.
• Incorporate the buzzer into your program. You might want your 3pi to play music while it
is driving or make informational beeps that depend on what it is doing. See
of
the
[https://www.pololu.com/docs/0J18]
for more information on using the
buzzer; for music, you’ll want to use the PLAY_CHECK option to avoid disrupting your sensor
readings.
Pololu 3pi Robot User’s Guide
© 2001–2019 Pololu Corporation
7. Example Project #1: Line Following
Page 29 of 85
Содержание 0J5840
Страница 24: ...Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 5 How Your 3pi Works Page 24 of 85...
Страница 67: ...Source code Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 10 Expansion Information Page 67 of 85...
Страница 77: ...Source code Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 10 Expansion Information Page 77 of 85...