|
|
# Group 15
|
|
|
|
|
|
## Lab Notebook - Lesson 8
|
|
|
|
|
|
**Date:** 28-4 2016
|
|
|
|
|
|
**Group members participating:** Kirstine, Simon, Martin, Leander
|
|
|
**Activity duration:** 13 hrs
|
|
|
|
|
|
Video of lap run: https://goo.gl/GTRW0P
|
|
|
|
|
|
## Goal
|
|
|
Our goal for this project is to create a robot which can drive up the Alishan train track as fast as possible, turn and drive back down as fast as possible.
|
|
|
|
|
|
## Plan
|
|
|
We have chosen to solve this problem using an iterative design process where each platform represents a single subgoal. As such, we will first create a robot which is able to follow the line up the slope and reach the first platform and stop. Then we will expand this robot, adding the required behavior for it to resume from the first platform to the next. We will repeatedly add behaviour solving each subgoal until the entire task is completed, and after this we will direct remaining efforts at improving the weakest links in this behavior chain.
|
|
|
|
|
|
## Setting up the basics
|
|
|
Breaking the track into separate parts, we decided to solve the track by maneuvering through each part of the track as individual tasks. This was handled by programming a state machine, which contains a list of states, that the car has to iterate through. Each “state” program is responsible for moving the car through a part of the tracks, as well as detect when that task is complete, so that the state machine can move on to the next state.
|
|
|
|
|
|
## Getting to the first platform
|
|
|
The first part of the program calibrates the car. This is to ensure that lighting conditions don’t affect our car enough to throw it off the course. After calibrating the car, it is ready to run the track. Moving from the green start area to the first ramp is done without sensors - just move forward for 0.2 seconds. This is the easiest way to get started, and we don’t have to compensate for shifts in color as the sensor moves closer to the track, as the track begins to raise above ground.
|
|
|
After moving to the first ramp, the car uses a PID controller to follow the line on the ramp, by using a color sensor mounted on the front of the car. We follow the line for around 3 seconds and then we simple drive straight until we reach the platform. The way that we detect whether or not we hit the first platform is by using a gyro sensor. As mentioned below the gyro sensor can detect a very characteristic pattern when going over the edge to the platform.
|
|
|
|
|
|
## Using the gyro sensor
|
|
|
When the car hits the platform, it shakes as it passes the difference in angles between the ramp and the platform. We use that as an indicator that we hit the platform. Using a data logger, we found that we can easily detect the change. Below is a graph of readings from the gyroscope, moving from the ramp to the platform at 900 ms.
|
|
|
|
|
|
![figure1](/uploads/a240e15a5c0c4049ee1da9c912088893/Screen_Shot_2016-05-09_at_17.27.20.png)
|
|
|
|
|
|
*Figure 1.* Data from the gyroscope showing when the car hits the platform.
|
|
|
|
|
|
## Switching from 2 light sensors to 1 color sensor
|
|
|
Our first iteration of the car used two light sensors with 2 centimeters in between, as a way of following the line. However, we found it quite difficult to reliably program the car to follow the line this way. Using our experience from earlier weeks with a single sensor for line following, we attached a single color sensor instead, and used that for line following. Since we already had experience with that behaviour, we quickly adapted the car to this new sensor.
|
|
|
Using a color sensor also added the ability to easily distinct the green surface from the rest of the track.
|
|
|
|
|
|
## Finding the line and following it again
|
|
|
After turning at the first platform, the car has to find the line on the second ramp. This proved to be a difficult task. When tuning the PID controller two tasks have to be considered: 1) having the controller follow the line in as straight a path as possible and 2) making the controller able to detect and follow a new line even if it detects it at an angle. The first task requires relatively small corrections to the motor speeds as the controller is already driving along the line and there is only a very small risk of losing track of the line. In the second task, we might approach a new line at an angle and as such we need to make relatively large corrections as we can easily overshoot and thereby lose the line. We found out that especially a large integration factor would make our controller overshoot and be unable to recover, so by diminishing this factor and raising the proportional and derivative factors we were able to make a controller with both desired properties.
|
|
|
|
|
|
## The way to the top
|
|
|
Using algorithms from the first ramp, we easily got to the top just following the line again.
|
|
|
Top platform turnaround
|
|
|
The first thing we will try as a behavior for the top platform is to drive straight forward briefly to ensure that the entire robot is on the platform. Then we simply want to turn 180 degrees, and re-engage the line finding method.
|
|
|
|
|
|
## Going back down
|
|
|
The descend should be easy, as we already have all the states covered, including moving on the ramp, detecting the platforms, turning at the platforms and stopping at the green zone. To make sure the car doesn’t skip or slide when driving downhill, we lowered the speed significantly. We found that we couldn’t use the gyroscope to reliably detect platforms with this slower speed, so instead of detecting the platform by gyroscope, we appended a light sensor to the left side of the car, and used that to detect the black bar at the end of the platform. When hitting the black end of the platform, the car turns to the right, and drives until it falls of and down to the green zone.
|
|
|
|
|
|
To detect when we hit the ground, we use the gyroscope. To find out what value counts as a hit, we logged the values, as showed in this chart:
|
|
|
|
|
|
![figure2](/uploads/4866f6c29dfe5bbc21c5225d281e95e6/Screen_Shot_2016-05-09_at_16.13.36.png)
|
|
|
** Figure 2:** Gyro values in free fall
|
|
|
|
|
|
The peak values are above 990, when we hit the ground, so we use 800 as a boundary value for when we hit the ground. When this condition is met, we stop the stopwatch and show the seconds used to run the course.
|
|
|
|
|
|
## Time to complete a lap
|
|
|
The lap was completed in 32 seconds, as shown in the video at: https://goo.gl/GTRW0P
|
|
|
|
|
|
## Conclusion
|
|
|
Our idea about controlling the robot using states worked out decently. The development was done one state at a time, which meant we could move on to the next part every time we had one platform or ramp behavior working. This also meant we could tweak the behavior for each specific part of the track.
|
|
|
To follow the line on the straight stretches of the track the PID controller worked extremely well.
|
|
|
One of the big disadvantages with our approach was that it turned out that the behavior of the robot was heavily affected by things like the state of the battery. We had hoped that the behavior would be predictable enough from run to run, that we could essentially reach the goal of completing the track by adjusting the parameters of the code. Another time it would be great to make the robot less dependant on specific values, and instead to make it more flexible by using sensors more.
|
|
|
|
|
|
Link to the wiki page: https://goo.gl/xxjJ64 |