LeBron Learns to Walk
Introduction
In Lab 1, we were able to assemble a functioning robot named LeBron that was able to be given a simple script and run autonomously. In this next phase, we implemented line detection sensors so that LeBron could take some guidance from it surroundings and use that to direct its movement. Finally, we used our line detection functionality to implement a simple figure-8.
Beginning Line Tracing: Line Detection
The lines we were tracing were white
stripes on a black background.
Hooking up the
QRE113
IR sensor (pictured left) gave us
analogRead
values less than 200 over the line demarcated by white tape.Otherwise, it
measured in the the range of 400-550 above the table surface (darker colors).
Converting Data to Decision
After we were able to accurately detect the line and background, we attached 3 sensors to the front of our robot to detect where the robot was relative to the line. When the middle sensor was activated (ie, its readings showed that it was above the white line / was low), LeBron was directly above the line. When the left sensor was activated, LeBron was given a command to adjust left; the same logic was used when the robot's right sensor was activated. In this way, LeBron was able to know its position relative to the line at all times.
Tackling Turns
The implemented code up to this point allows our robot to trace a line. However, a major hurdle to completing a figure-8 is turning the robot from one line onto another line. Travelling to these intersections is relatively straightforward using the outline defined above, but adding complexity to trace intersections requires additional testing of our robot. First, we noticed that as we reach an intersection, all of our IR sensors detect a line underneath them. This gives us a good indicator that we're approaching an intersection and lets us finish travelling to the intersection before we begin a 90 degree turn. The turn itself is relatively straightforward as well, turning our wheels in opposite directions or rotating one wheel and pivoting on the other. Therefore, at intersections, LeBron is able to make accurate turns.
Figure 8 Tracking
The Milestone is almost accomplished now. We are able to direct our robot to trace lines and make accurate turns. The only piece left is directing our robot through a series of turns to trace out a figure 8. To accomplish this, we defined right and left turns corresponding to a variable which kept track of executed turns up until that point. To check out the implementation of the various parts of this Milestone and try it yourself, download our code below!
Summary
Previously, we learned to use an Arduino Uno to operate servos, giving our robot some level of autonomous movement. However, the decisions for which servo was activated when had been determined by pre-written code. In this milestone, we made the decision for activating servos dependent on our robots environment. IR sensors tracked lines of tape and our robot was able to respond by tracing the path of that tape, even around turns. This culminated in our robot autonomously tracing a figure-8 pattern.
Thoughts
The current implementation of turning and path
correction uses the Arduino delay()
function throughout it. This isn't the most
rigorous setup, as a discharged battery might
affect the wheels speeds of our servos and change
the distance our robot travels during those delays.
Additionally, in the videos posted above, our robot
stuttered throughout its tracking. This was a
result of a poorly attached bearing. Since this
filming, we've made adjustments and 3D
printed a new part to make sure
our bearing is tightly attached at the robot
has its sensors above the ground constantly,
instead of bouncing back and forth, resulting in smoother operation.
Furthermore, we changed our turn logic to be less reliant on timed delays. Instead,
the outer sensors detect when a turn is happening and Lebron continues the wheel motion
until the outer sensor in question returns to a white line. In other words, the sensor detects when a
sweep is begun and complete, allowing LeBron to turn and follow lines not necessarily at right angles.