Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worlds autons + skills changes 4-15 #252

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/auton.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define AUTON 0
#define AUTON 2
2 changes: 1 addition & 1 deletion include/stateMachine/behaviors/intake/initIntake.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Pronounce {
auto intakeStopped = std::make_shared<Intake>("IntakeStopped", intakeMotors, 0.0);
auto intakeIntaking = std::make_shared<Intake>("IntakeIntaking", intakeMotors, 1.0);
auto intakeHold = std::make_shared<Intake>("IntakeHold", intakeMotors, 0.55);
auto intakeHold = std::make_shared<Intake>("IntakeHold", intakeMotors, 0.65);
auto intakeEject = std::make_shared<Intake>("IntakeEject", intakeMotors, -1.0);

auto intakeStateController = std::make_shared<StateController>("IntakeStateController", intakeStopped);
Expand Down
9 changes: 6 additions & 3 deletions include/stateMachine/state/competition/auton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,18 @@ namespace Pronounce {
class Auton : public Enabled {
private:
pros::task_fn_t auton;
void* args;
pros::Task task;
public:
Auton(pros::task_fn_t auton) : task([=]() -> void { return; }), Enabled("Auton") {
Auton(pros::task_fn_t auton, void* args = nullptr) : task([=]() -> void { return; }), Enabled("Auton") {
this->auton = auton;
this->args = args;
}

void setAuton(pros::task_fn_t auton) {
void setAuton(pros::task_fn_t auton, void* args = nullptr) {
Log("Set auton");
this->auton = auton;
this->args = args;
}

void initialize() override {
Expand All @@ -103,7 +106,7 @@ namespace Pronounce {
if (task.get_state() == 2)
task.remove();

task = pros::Task(auton, nullptr, TASK_PRIORITY_MAX-1, TASK_STACK_DEPTH_DEFAULT, "User auton");
task = pros::Task(auton, args, TASK_PRIORITY_MAX-1, TASK_STACK_DEPTH_DEFAULT, "User auton");
}

void update() override {
Expand Down
141 changes: 72 additions & 69 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
std::shared_ptr<lv_obj_t> tabview;

// SECTION Auton
SMOOTH_SPLINE_PATH_ASSET(close_mid_rush);
SMOOTH_SPLINE_PATH_ASSET(safe_close_awp);
SMOOTH_SPLINE_PATH_ASSET(far_6_1);
SMOOTH_SPLINE_PATH_ASSET(far_6_2);
SMOOTH_SPLINE_PATH_ASSET(far_6_3);
SMOOTH_SPLINE_PATH_ASSET(far_6_4);
SMOOTH_SPLINE_PATH_ASSET(skills_1);
SMOOTH_SPLINE_PATH_ASSET(skills_2);
SMOOTH_SPLINE_PATH_ASSET(skills_3);
SMOOTH_SPLINE_PATH_ASSET(skills_5);
SMOOTH_SPLINE_PATH_ASSET(skills_6);
SMOOTH_SPLINE_PATH_ASSET(skills_6_5);
SMOOTH_SPLINE_PATH_ASSET(skills_7);
SMOOTH_SPLINE_PATH_ASSET(skills_7_5);
SMOOTH_SPLINE_PATH_ASSET(skills_8);
SMOOTH_SPLINE_PATH_ASSET(skills_9);
SMOOTH_SPLINE_PATH_ASSET(close_mid_rush_elim);
SMOOTH_SPLINE_PATH_ASSET(close_rush_mid_2);
SMOOTH_SPLINE_PATH_ASSET(close_rush_mid_awp)
SMOOTH_SPLINE_PATH_ASSET(close_rush_mid_triball)
SMOOTH_SPLINE_PATH_ASSET(close_rush_mid_no_triball)
SMOOTH_SPLINE_PATH_ASSET(safe_close_awp)
SMOOTH_SPLINE_PATH_ASSET(far_6_1)
SMOOTH_SPLINE_PATH_ASSET(far_6_2)
SMOOTH_SPLINE_PATH_ASSET(far_6_3)
SMOOTH_SPLINE_PATH_ASSET(far_6_4)
SMOOTH_SPLINE_PATH_ASSET(skills_1)
SMOOTH_SPLINE_PATH_ASSET(skills_2)
SMOOTH_SPLINE_PATH_ASSET(skills_3)
SMOOTH_SPLINE_PATH_ASSET(skills_5)
SMOOTH_SPLINE_PATH_ASSET(skills_6)
SMOOTH_SPLINE_PATH_ASSET(skills_6_5)
SMOOTH_SPLINE_PATH_ASSET(skills_7)
SMOOTH_SPLINE_PATH_ASSET(skills_7_5)
SMOOTH_SPLINE_PATH_ASSET(skills_8)
SMOOTH_SPLINE_PATH_ASSET(skills_9)

void turnTo(Angle angle, QTime waitTimeMS, RotationOptimizer rotationOptimizer = none, double idleSpeed = 0.0) {
auto angleRotation = std::make_shared<RotationController>("AngleTurn", drivetrain,
Expand All @@ -30,7 +30,7 @@ void turnTo(Angle angle, QTime waitTimeMS, RotationOptimizer rotationOptimizer =

drivetrainStateController->sb(angleRotation);

pros::Task::delay(waitTimeMS.Convert(millisecond));
pros::Task::delay(static_cast<uint32_t>(waitTimeMS.Convert(millisecond)));

drivetrainStateController->ud();
pros::Task::delay(10);
Expand Down Expand Up @@ -61,7 +61,9 @@ void far6Ball(void* args) {

intakeExtensionStateController->sb(deploySequence);

move(51_in, speedProfileConstraints, 0.0, -120.5_deg);
move(56_in, speedProfileConstraints, 0.0, -120.5_deg);

pros::Task::delay(200);

intakeExtensionStateController->ud();

Expand All @@ -70,14 +72,14 @@ void far6Ball(void* args) {

turnTo(-180_deg, 0.4_s);
intakeStateController->sb(intakeIntaking);
move(5_in, speedProfileConstraints, 0.0, -180_deg);
move(7_in, speedProfileConstraints, 0.0, -180_deg);

pathFollower->setMotionProfile(far_6_2);
drivetrainStateController->sb(pathFollower)->wait();

backRightWingStateController->ud();
move(15_in, speedProfileConstraints, 0.0, -250_deg);
turnTo(-430_deg, 0.6_s);
turnTo(-45_deg, 0.6_s, counterclockwise);

frontLeftWingStateController->sb(frontLeftWingOut);

Expand All @@ -88,7 +90,12 @@ void far6Ball(void* args) {

move(-15_in, defaultProfileConstraints, 0.0, -430_deg);

frontLeftWingStateController->ud();
// frontLeftWingStateController->ud();

}

void far6BallElim(void* args) {
far6Ball(args);

pathFollower->setMotionProfile(far_6_3);
drivetrainStateController->sb(pathFollower)->wait();
Expand All @@ -97,7 +104,8 @@ void far6Ball(void* args) {
}

void far6BallAWP(void* args) {
far6Ball(args);
pathFollower->setMotionProfile(far_6_4);
drivetrainStateController->sb(pathFollower)->wait();
}

void skills(void *args) {
Expand Down Expand Up @@ -129,22 +137,24 @@ void skills(void *args) {
frontRightWingStateController->sb(frontRightWingIn);
frontLeftWingStateController->sb(frontLeftWingIn);

turnTo(-15.0_deg, 600_ms, clockwise);
turnTo(180.0_deg, 600_ms, clockwise);

catapultStateController->sb(catapultHoldHigh);

pathFollower->setMotionProfile(skills_3);
drivetrainStateController->sb(pathFollower)->wait();

move(20_in, speedProfileConstraints, 0.0, 100_deg);
move(20_in, speedProfileConstraints, 0.0, -80_deg);

turnTo(115_deg, 1.0_s, closest, -12000);
turnTo(-70_deg, 1.0_s, closest, -12000);

move(20_in, speedProfileConstraints, 0.0, 100_deg);
move(20_in, speedProfileConstraints, 0.0, -80_deg);
backRightWingStateController->ud();
backLeftWingStateController->ud();

turnTo(115_deg, 1.0_s, closest, -12000);
turnTo(-70_deg, 1.0_s, closest, -12000);

turnTo(-170_deg, 0.4_s, closest);

pathFollower->setMotionProfile(skills_5);
drivetrainStateController->sb(pathFollower)->wait();
Expand Down Expand Up @@ -194,22 +204,22 @@ void skills(void *args) {
pushingProfileConstraints)}));
drivetrainStateController->sb(pathFollower)->wait();

turnTo(125_deg, 0.4_s, closest);
turnTo(-55_deg, 0.4_s, closest);

pathFollower->setMotionProfile(skills_8);
drivetrainStateController->sb(pathFollower)->wait();

move(20_in, speedProfileConstraints, 0.0, -100_deg);
move(20_in, speedProfileConstraints, 0.0, 90_deg);

turnTo(-115_deg, 1.0_s, closest, -12000);
turnTo(80_deg, 1.0_s, closest, -12000);

winchStateController->sb(winchUp);

move(20_in, speedProfileConstraints, 0.0, -100_deg);
move(20_in, speedProfileConstraints, 0.0, 90_deg);

backLeftWingStateController->ud();

turnTo(-115_deg, 1.0_s, closest, -12000);
turnTo(80_deg, 1.0_s, closest, -12000);

pathFollower->setMotionProfile(skills_9);
drivetrainStateController->sb(pathFollower)->wait();
Expand Down Expand Up @@ -238,7 +248,7 @@ void safeCloseAWPDelay(void *args) {

}

void closeRushMid(void *args) {
void closeRushMidAwp(void *args) {
imuOrientation.setRotation(-75.7_deg);

frontLeftWingStateController->sb(std::make_shared<Wait>(frontLeftWingOut, 300_ms));
Expand All @@ -247,48 +257,38 @@ void closeRushMid(void *args) {

move(41_in, speedProfileConstraints, 0.0, -75.7_deg);

intakeExtensionStateController->ud();
intakeStateController->sb(intakeIntaking);

move(-13_in, speedProfileConstraints, 0.0, -75.7_deg);

turnTo(104.3_deg, 600_ms);

intakeStateController->sb(intakeEject);

turnTo(104.3_deg, 200_ms);

turnTo(-35.3_deg, 600_ms);

pathFollower->setMotionProfile(PathPlanner::SmoothSplineProfile::build(close_mid_rush_json));
pathFollower->setMotionProfile(close_rush_mid_awp);
drivetrainStateController->sb(pathFollower)->wait();

move(-10_in, speedProfileConstraints, 0.0, 56_deg);

intakeStateController->sb(intakeEject);

pathFollower->setMotionProfile(PathPlanner::SmoothSplineProfile::build(close_rush_mid_2_json));
drivetrainStateController->sb(pathFollower)->wait();
pros::Task::delay(15000);
}

void closeRushMidElim(void *args) {
closeRushMid(args);
imuOrientation.setRotation(-75.7_deg);

turnTo(-180_deg, 800_ms);
frontLeftWingStateController->sb(std::make_shared<Wait>(frontLeftWingOut, 300_ms));

intakeStateController->sb(intakeIntaking);
intakeExtensionStateController->sb(deploySequence);

pathFollower->setMotionProfile(PathPlanner::SmoothSplineProfile::build(close_mid_rush_elim_json));
drivetrainStateController->sb(pathFollower)->wait();
}
move(41_in, speedProfileConstraints, 0.0, -75.7_deg);

void tuneTurnPid(void *args) {
imuOrientation.setRotation(0.0_deg);
for (int i = 0; i < 5; ++i) {
turnTo(180_deg, 2_s);
turnTo(0.0_deg, 2_s);
move(-10_in, speedProfileConstraints, 0.0, -75.7_deg);

if (hopperDistanceSensor.get() * 1_mm < 160_mm) {
// Has triball in the intake
pathFollower->setMotionProfile(close_rush_mid_triball);
turnTo(50_deg, 0.5_s);
drivetrainStateController->sb(pathFollower)->wait();
} else {
// Doesn't have a triball in the intake
pathFollower->setMotionProfile(close_rush_mid_no_triball);
turnTo(0_deg, 0.4_s);
drivetrainStateController->sb(pathFollower)->wait();
}

pros::Task::delay(15000);
}

// !SECTION

// SECTION INIT
Expand Down Expand Up @@ -401,15 +401,18 @@ void initialize() {
#elif AUTON == 1
auton->setAuton(far6BallAWP);
#elif AUTON == 2
auton->setAuton(safeCloseAWPDelay);
auton->setAuton(safeCloseAWP);
#elif AUTON == 3
auton->setAuton(closeRushMidElim);
auton->setAuton(safeCloseAWPDelay);
#elif AUTON == 4
auton->setAuton(closeRushMid);
auton->setAuton(closeRushMidElim);
#elif AUTON == 5
auton->setAuton(closeRushMidAwp);
#elif AUTON == 6
auton->setAuton(skills);
#endif // !1


// Initialize functions
initHardware();
initIntake();
Expand Down
6 changes: 0 additions & 6 deletions static/close_mid_rush.json

This file was deleted.

1 change: 0 additions & 1 deletion static/close_mid_rush_elim.json

This file was deleted.

42 changes: 0 additions & 42 deletions static/close_rush_mid_2.json

This file was deleted.

Loading
Loading