Skip to content

Commit

Permalink
Merge pull request #134 from ad101-lab/autons
Browse files Browse the repository at this point in the history
autons
  • Loading branch information
alexDickhans authored May 3, 2022
2 parents ee4c2a5 + 5d30d5e commit 165fcc8
Show file tree
Hide file tree
Showing 11 changed files with 914 additions and 572 deletions.
398 changes: 204 additions & 194 deletions include/autoPaths.hpp

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions include/chassis/abstractTankDrivetrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,27 @@ namespace Pronounce {
this->tankSteerVelocity(leftSpeed, rightSpeed);
}

void driveCurvatureVoltage(double speed, double curvature) {
double leftSpeed = speed * (2.0 + curvature * trackWidth) / 2.0;
double rightSpeed = speed * (2.0 - curvature * trackWidth) / 2.0;

double maxSpeed = max(abs(leftSpeed), abs(rightSpeed));

if (maxSpeed > abs(speed)) {
double multiplier = abs(speed) / maxSpeed;
leftSpeed *= multiplier;
rightSpeed *= multiplier;
}

this->tankSteerVoltage(leftSpeed, rightSpeed);
}

virtual void skidSteerVelocity(double speed, double turn) {}

virtual void tankSteerVelocity(double leftSpeed, double rightSpeed) {}

virtual void tankSteerVoltage(double leftSpeed, double rightSpeed) {}

~AbstractTankDrivetrain();
};
} // namespace Pronounce
Expand Down
10 changes: 10 additions & 0 deletions include/chassis/tankDrive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,21 @@ namespace Pronounce {
this->getRightMotors().move_velocity(speed - turn);
}

void skidSteerVoltage(double speed, double turn) {
this->getLeftMotors().move_voltage(speed + turn);
this->getRightMotors().move_voltage(speed - turn);
}

void tankSteerVelocity(double leftSpeed, double rightSpeed) {
this->getLeftMotors().move_velocity(leftSpeed);
this->getRightMotors().move_velocity(rightSpeed);
}

void tankSteerVoltage(double leftSpeed, double rightSpeed) {
this->getLeftMotors().move_voltage(leftSpeed);
this->getRightMotors().move_voltage(rightSpeed);
}

~TankDrivetrain();
};
} // namespace Pronounce
Expand Down
4 changes: 4 additions & 0 deletions include/feedbackControllers/bangBang.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ namespace Pronounce {
*/
double update(double input);

double getLastInput() {
return lastInput;
}

double getSetPoint() {
return setPoint;
}
Expand Down
1 change: 1 addition & 0 deletions include/motionControl/purePursuit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace Pronounce {
Vector localLookaheadVector;
Vector normalizedLookaheadVector;
double curvature;
double distanceFromEnd;
};

/**
Expand Down
10 changes: 10 additions & 0 deletions include/motionControl/tankPurePursuit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ namespace Pronounce {
PID* turnPid;

double lastUpdateTime = 0;

bool useVoltage = false;
public:
TankPurePursuit(AbstractTankDrivetrain* drivetrain);
TankPurePursuit(AbstractTankDrivetrain* drivetrain, double lookaheadDistance);
Expand All @@ -27,6 +29,14 @@ namespace Pronounce {

void stop();

bool getUseVoltage() {
return useVoltage;
}

void setUseVoltage(bool useVoltage) {
this->useVoltage = useVoltage;
}

AbstractTankDrivetrain* getDrivetrain() {
return drivetrain;
}
Expand Down
10 changes: 6 additions & 4 deletions pathTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,14 @@ int main() {

Path smoothPath;

QuadraticSplinePath midGoalToFarPlatform("midGoalToFarPlatform");
QuadraticSplinePath rightNeutralGoalToNearRIghtPlatform("enterFarLeftHomeZoneToNearRightPlatform");

midGoalToFarPlatform.addPoint(SplinePoint(Point(60, 70), Vector(20, 0)));
midGoalToFarPlatform.addPoint(SplinePoint(Point(75, 70), Vector(20, 0)));
rightNeutralGoalToNearRIghtPlatform.addPoint(SplinePoint(Point(105.7, 80), Vector(25, M_PI)));
rightNeutralGoalToNearRIghtPlatform.addPoint(SplinePoint(Point(80, 60), Vector(20, M_PI_2)));
rightNeutralGoalToNearRIghtPlatform.addPoint(SplinePoint(Point(25, 60), Vector(20, M_PI_2)));
rightNeutralGoalToNearRIghtPlatform.addPoint(SplinePoint(Point(25, 36), Vector(20, -M_PI_2*0.8)));

smoothPath = midGoalToFarPlatform.getPath(0.1);
smoothPath = rightNeutralGoalToNearRIghtPlatform.getPath(0.1);

paths.emplace_back(smoothPath);

Expand Down
Loading

0 comments on commit 165fcc8

Please sign in to comment.