1516X Push Back 1.0
1516X's robot code for the 2025-2026 VEX Robotics Competition
Loading...
Searching...
No Matches
autonFunctions.cpp File Reference
#include "autonFunctions.h"
#include "globals.h"
#include "lemlib/util.hpp"
#include "pros/rtos.hpp"
#include <cmath>
#include <sys/types.h>
#include "colorSort.h"
#include "IntakeAntiJam.h"

Go to the source code of this file.

Functions

void antiJamTask ()
void intake (int power)
void outtake (int power)
void score_longgoal (int power, Color allianceColor)
void intake_stop (bool hood_state)
void score_midgoal (int power)
void score_midgoal_auton (int power, Color allianceColor, int time)
void score_longgoal_auton (int power, Color allianceColor, int time)
void intake_to_basket ()
void matchload_state (bool state)
void relativeMotion (float expected_x, float expected_y, float expected_theta, float distance, int timeout_ms, bool forw, float earlyExit)
double calculateAngle (double robotHeading)

Variables

const VelocityControllerConfig config

Function Documentation

◆ antiJamTask()

void antiJamTask ( )

Definition at line 21 of file autonFunctions.cpp.

21 {
22 while (true) {
23 jamManager.update();
24 pros::delay(10);
25 }
26}
IntakeAntiJam jamManager(intakeMotor, outtakeMotor, storageMotor, 55)

References jamManager().

Referenced by initialize().

◆ calculateAngle()

double calculateAngle ( double robotHeading)

Definition at line 118 of file autonFunctions.cpp.

118 {
119 double d1 = frontDistance.get();
120 double d2 = frontDistance2.get() + 10;
121
122 if (d1 > 1800 || d2 > 1800) return -1;
123 double wallAngleDeg = atan2((d1 - d2) * 0.0393701, 10.75) * 180.0 / M_PI;
124
125 if ((robotHeading >= 315 && robotHeading < 360) || (robotHeading >= 0 && robotHeading < 45)) {
126 return wallAngleDeg;
127 }
128 else if (robotHeading >= 45 && robotHeading < 135) {
129 return 90 + wallAngleDeg;
130 }
131 else if (robotHeading >= 135 && robotHeading < 225) {
132 return 180 + wallAngleDeg;
133 }
134 else if (robotHeading >= 225 && robotHeading < 315) {
135 return 270 + wallAngleDeg;
136 }
137
138 return -1;
139}
pros::Distance frontDistance(8)

References frontDistance().

◆ intake()

void intake ( int power)

Definition at line 29 of file autonFunctions.cpp.

30{
31 if(hood.is_extended()) { hood.retract(); }
32 jamManager.set_velocities((int)power/3, -(int)power/3, power);
33}
pros::adi::Pneumatics hood('B', false)

References hood(), and jamManager().

Referenced by awp_auton(), left_auton_split(), left_rush(), opcontrol(), right_7_hood(), right_7_wing(), right_auton_split(), right_rush(), and skills_auton().

◆ intake_stop()

void intake_stop ( bool hood_state)

Definition at line 47 of file autonFunctions.cpp.

48{
49 jamManager.stop();
50 if(!hood_state) hood.retract();
51 else hood.extend();
52
53 if(intake_lift.is_extended()) { intake_lift.retract(); }
54}
pros::adi::Pneumatics intake_lift('A', false)

References hood(), intake_lift(), and jamManager().

Referenced by awp_auton(), left_auton_split(), opcontrol(), right_7_hood(), right_auton_split(), score_longgoal_auton(), score_midgoal_auton(), and skills_auton().

◆ intake_to_basket()

void intake_to_basket ( )

Definition at line 89 of file autonFunctions.cpp.

90{
91
92}

◆ matchload_state()

void matchload_state ( bool state)

Definition at line 94 of file autonFunctions.cpp.

95{
96 if(state)
97 {
98 if(!matchloader.is_extended()) {matchloader.extend();}
99 }
100 else
101 {
102 if(matchloader.is_extended()) {matchloader.retract();}
103 }
104}
pros::adi::Pneumatics matchloader('C', false)

References matchloader().

Referenced by awp_auton(), left_auton_split(), left_rush(), right_7_hood(), right_7_wing(), right_auton_split(), right_rush(), and skills_auton().

◆ outtake()

void outtake ( int power)

Definition at line 35 of file autonFunctions.cpp.

36{
37 if(!intake_lift.is_extended()) { intake_lift.extend(); }
38 jamManager.set_velocities(-((int)power/3), ((int)power/3), -power);
39}

References intake_lift(), and jamManager().

Referenced by opcontrol(), and right_auton_split().

◆ relativeMotion()

void relativeMotion ( float expected_x,
float expected_y,
float expected_theta,
float distance,
int timeout_ms,
bool forw,
float earlyExit )

Definition at line 107 of file autonFunctions.cpp.

108{
109 lemlib::Pose targetPose(
110 expected_x + distance * std::sin(lemlib::degToRad(expected_theta)),
111 expected_y + distance * std::cos(lemlib::degToRad(expected_theta)),
112 expected_theta
113 );
114
115 chassis.moveToPoint(targetPose.x, targetPose.y, timeout_ms, {.forwards = forw, .earlyExitRange = earlyExit});
116}
Chassis chassis(drivebase, lateral_controller, angular_controller, sensors, &throttle_curve, &steer_curve)

References chassis().

◆ score_longgoal()

void score_longgoal ( int power,
Color allianceColor )

Definition at line 41 of file autonFunctions.cpp.

42{
43 if(!hood.is_extended()) { hood.extend(); }
44 jamManager.set_velocities((int)power/3, -(int)power/3, power);
45}

References allianceColor, hood(), and jamManager().

Referenced by awp_auton(), and opcontrol().

◆ score_longgoal_auton()

void score_longgoal_auton ( int power,
Color allianceColor,
int time )

Definition at line 75 of file autonFunctions.cpp.

76{
77 u_int32_t start_time = pros::millis();
78 if(time != -1) {
79 while(pros::millis() - start_time < (u_int32_t)time) {
80 if(!hood.is_extended()) { hood.extend(); }
81 jamManager.set_velocities((int)power/3, -(int)power/3, power);
82 chassis.tank(-20, -20);
83 pros::delay(10);
84 }
85 }
86 chassis.brake();
88}
void intake_stop(bool hood_state)

References allianceColor, chassis(), hood(), intake_stop(), and jamManager().

Referenced by awp_auton(), left_auton_split(), left_rush(), right_7_hood(), right_7_wing(), right_auton_split(), right_rush(), and skills_auton().

◆ score_midgoal()

void score_midgoal ( int power)

Definition at line 56 of file autonFunctions.cpp.

57{
58 jamManager.set_velocities((int)power/3, (int)power/3, power);
59}

References jamManager().

Referenced by opcontrol().

◆ score_midgoal_auton()

void score_midgoal_auton ( int power,
Color allianceColor,
int time )

Definition at line 61 of file autonFunctions.cpp.

62{
63 u_int32_t start_time = pros::millis();
64 if(time != -1) {
65 while(pros::millis() - start_time < (u_int32_t)time) {
66 jamManager.set_velocities((int)power/3, (int)power/3, power);
67 chassis.tank(-20, -20);
68 pros::delay(10);
69 }
70 }
71 chassis.brake();
73}

References allianceColor, chassis(), intake_stop(), and jamManager().

Referenced by awp_auton(), left_auton_split(), and skills_auton().

Variable Documentation

◆ config

const VelocityControllerConfig config
Initial value:
{
5.09498070723,
0.23396112183,
1.22496514644,
0.964796393603,
0.522291806997,
10.933332351,
44.6788428062,
}

Definition at line 11 of file autonFunctions.cpp.

11 {
125.09498070723,
130.23396112183,
141.22496514644,
150.964796393603,
160.522291806997,
1710.933332351,
1844.6788428062,
19};

Referenced by awp_auton(), left_auton_split(), left_rush(), ltv(), right_7_hood(), right_7_wing(), right_auton_split(), right_rush(), and skills_auton().