Final Performance Test
reverse(4);
const float inPerMark = 0.4875;
celerate(4, 0, 40, 2);
goToAbsolutePosition(((7 * 12) + 7.5) / inPerMark);
reverse(4);
celerate(4, 45, 0, 3.4);
goFor(6.5);
reverse(4);
celerate(4, 0, 35, 2);
goToAbsolutePosition((18 * 12) / inPerMark);
brake(4);
goToAbsolutePosition(((24 * 12) + 5) / inPerMark);
reverse(4);
celerate(4, 48, 0, 2);
goFor(5);
celerate(4, 0, 40, 2);
goToAbsolutePosition(((16 * 12) + 1.9) / inPerMark);
reverse(4);
celerate(4, 55, 10, 2.75);
brake(4);
goFor(6);
reverse(4);
celerate(4, 0, 40, 2);
goToAbsolutePosition(((6 * 12) + 6) / inPerMark);
brake(4);
goToAbsolutePosition(((4 * 12) + 9) / inPerMark);
reverse(4);
celerate(4, 50, 10, 4);
brake(4);
Performance Test 2
This was the code for performance test 2.
reverse(4);
const float inPerMark = 0.4875;
celerate(4, 0, 40, 2);
goToAbsolutePosition(((7 * 12) + 3.5) / inPerMark);
reverse(4);
celerate(4, 45, 0, 2.25);
goFor(7);
reverse(4);
celerate(4, 0, 35, 2);
goToAbsolutePosition((18 * 12) / inPerMark);
brake(4);
goToAbsolutePosition(((24 * 12) + 5) / inPerMark);
reverse(4);
celerate(4, 48, 0, 2);
goFor(5);
celerate(4, 0, 40, 2);
goToAbsolutePosition((24 * 12) / inPerMark);
Advanced R&D 3
This was our first attempt at writing a program to make the AEV stop at a precise location. It simply ran the motors in forwards and reverse for the same time and speed.
void moveTo(float forwardSpeed, float endPos) {
float startPos = getVehiclePosition();
float midpoint = (endPos + startPos) / 2;
// Move at a constant motor speed to the midpoint
motorSpeed(4, forwardSpeed);
goToAbsolutePosition(midpoint);
// Begin power-braking
reverse(4);
motorSpeed(4, forwardSpeed);
const float inPerMark = 0.4875;
const float tolerance = 0.25 * inPerMark;
// Go until the end position is reached or until the AEV starts
// moving backwards within a tolerance
float diff = endPos - getVehiclePosition();
float prevDiff = diff;
while (diff > 0) {
prevDiff = diff;
diff = endPos - getVehiclePosition();
if (diff - prevDiff >= tolerance) {
break;
}
}
}
void myCode()
{
const float inPerMark = 0.4875;
reverse(4);
// Move to absolute position of 10 feet
moveTo(35, (10 * 12) / inPerMark);
}
This was a later attempt at achieving precise braking. Unfortunately it landed short of where we intended.
void powerbrake(float forwardSpeed, float endPos) {
const float baseSpeed = 10.0;
const float dynamicScale = 1.0;
float dynamicSpeed = (forwardSpeed - baseSpeed) * dynamicScale;
reverse(4);
double initialDiff = endPos - getVehiclePosition();
double diff = initialDiff;
while (diff > 0) {
recordData(minTimeLapse);
double factor = diff / initialDiff;
motorSpeed(4, (factor * dynamicSpeed) + baseSpeed);
double prevDiff = diff;
// this delay is needed so that diff and prevDiff have time
// to show whether they are different
delay(20);
diff = endPos - getVehiclePosition();
if (diff >= prevDiff) {
break;
}
}
}
void moveTo(float forwardSpeed, float endPos) {
float startPos = getVehiclePosition();
float midpoint = (endPos + startPos) / 2;
motorSpeed(4, forwardSpeed);
goToAbsolutePosition(midpoint);
powerbrake(forwardSpeed, endPos);
brake(4);
}
void myCode()
{
const float inPerMark = 0.4875;
reverse(4);
// Move to absolute position of 10 feet
moveTo(35, (10 * 12) / inPerMark);
}
Advanced R&D 2
This code was used to test braking via coasting.
// accelerate
reverse(4);
celerate(4, 0, 25, 2);
// maintain speed until distance reached
motorSpeed(4, 25);
goToAbsolutePosition(-100);
This code was used to test power braking.
// accelerate
reverse(4);
celerate(4, 0, 25, 2);
// maintain speed until distance reached
motorSpeed(4, 25);
goToAbsolutePosition(-100);
// power brake (reverse and decelerate)
reverse(4);
celerate(4, 25, 0, 2);
Advanced R&D 1
This code was used for advanced R&D 1: battery testing.
reverse(4);
motorSpeed(4, 40);
// move 4 feet (negative because motors are reversed)
goToAbsolutePosition(-(4 * 12) / 0.4875);
Lab 8
This code is being used for Performance Test 1. This code had the AEV move up to the gate, power break, stop at the gate, wait for 7 seconds and then move through the gate.
reverse(4);
const float inPerMark = 0.4875;
celerate(4, 0, 40, 2);
// with original propeller config, use 9 ft and 11 in
goToAbsolutePosition(-((9 * 12) + 9) / inPerMark);
reverse(4);
celerate(4, 40, 0, 2);
goFor(7);
reverse(4);
celerate(4, 0, 35, 2);
goToAbsolutePosition(-(18 * 12) / inPerMark);
brake(4);
Lab 3
The current code runs a few basic commands to the motors, which was used when testing the AEV on the rails for the first time.
celerate(4, 0, 25, 3);
goFor(1);
motorSpeed(4, 20);
goFor(2);
reverse(4);
motorSpeed(4, 25);
goFor(2);
brake(4);
Previously, we used the following code to test whether the reflectance sensors were working properly:
motorSpeed(4, 25);
goFor(2);
motorSpeed(4, 20);
// Move a distance of 1 foot
// Units must be converted to marks
int d1Ft = 1;
const float markToIn = 0.4875;
int d1Marks = d1Ft * 12 * markToIn;
goToAbsolutePosition(d1Marks);
reverse(4);
motorSpeed(4, 30);
goFor(1.5);
brake(4);
Reference of function calls [1]
-
celerate(m, p1, p2, t)
- Accelerates or decelerates motors
m
from start speedp1
to end speedp2
int
seconds.
- Accelerates or decelerates motors
-
motorSpeed(m, p)
- Sets motor
m
to percent powerp
.
- Sets motor
-
goFor(t)
- Runs the motors at their current settings for
t
seconds.
- Runs the motors at their current settings for
-
brake(m)
- Brakes motors
m
.
- Brakes motors
-
reverse(m)
- Run motor
m
in reverse.
- Run motor
-
goToRelativePosition(n)
- Moves the vehicle to position
n
based on its current position.
- Moves the vehicle to position
-
goToAbsolutePosition(n)
- Moves the vehicle to position
n
based on its start position.
- Moves the vehicle to position
References
[1] Ohio State University Fundamentals of Engineering Program. “Preliminary Research and Design”. [Course documentation]. Available: https://osu.app.box.com/s/diy2i8qb3l86ngb4f9j5x7geajy3epup