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/misc.h"
#include "pros/rtos.hpp"
#include <cmath>
#include <sys/types.h>
#include "colorSort.h"
#include "IntakeAntiJam.h"
#include "ltv.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 26 of file autonFunctions.cpp.

26 {
27 while (true) {
28 jamManager.update();
29 pros::delay(10);
30 }
31}
IntakeAntiJam jamManager(intakeMotor, outtakeMotor, storageMotor, 55)

References jamManager().

Referenced by initialize().

◆ calculateAngle()

double calculateAngle ( double robotHeading)

Definition at line 134 of file autonFunctions.cpp.

134 {
135 double d1 = frontDistance.get();
136 double d2 = frontDistance2.get() + 10;
137
138 if (d1 > 1800 || d2 > 1800) return -1;
139 double wallAngleDeg = atan2((d1 - d2) * 0.0393701, 10.75) * 180.0 / M_PI;
140
141 if ((robotHeading >= 315 && robotHeading < 360) || (robotHeading >= 0 && robotHeading < 45)) {
142 return wallAngleDeg;
143 }
144 else if (robotHeading >= 45 && robotHeading < 135) {
145 return 90 + wallAngleDeg;
146 }
147 else if (robotHeading >= 135 && robotHeading < 225) {
148 return 180 + wallAngleDeg;
149 }
150 else if (robotHeading >= 225 && robotHeading < 315) {
151 return 270 + wallAngleDeg;
152 }
153
154 return -1;
155}
pros::Distance frontDistance(8)

References frontDistance().

◆ intake()

void intake ( int power)

Definition at line 33 of file autonFunctions.cpp.

34{
35 if(hood.is_extended()) { hood.retract(); }
36 jamManager.set_velocities((int)power/3, -(int)power/3, power);
37}
pros::adi::Pneumatics hood('B', false)

References hood(), and jamManager().

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

◆ intake_stop()

void intake_stop ( bool hood_state)

Definition at line 51 of file autonFunctions.cpp.

52{
53 jamManager.stop();
54 if(!hood_state) hood.retract();
55 else hood.extend();
56
57 if(intake_lift.is_extended()) { intake_lift.retract(); }
58}
pros::adi::Pneumatics intake_lift('A', false)

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

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

◆ intake_to_basket()

void intake_to_basket ( )

Definition at line 105 of file autonFunctions.cpp.

106{
107
108}

◆ matchload_state()

void matchload_state ( bool state)

Definition at line 110 of file autonFunctions.cpp.

111{
112 if(state)
113 {
114 if(!matchloader.is_extended()) {matchloader.extend();}
115 }
116 else
117 {
118 if(matchloader.is_extended()) {matchloader.retract();}
119 }
120}
pros::adi::Pneumatics matchloader('C', false)

References matchloader().

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

◆ outtake()

void outtake ( int power)

Definition at line 39 of file autonFunctions.cpp.

40{
41 if(!intake_lift.is_extended()) { intake_lift.extend(); }
42 jamManager.set_velocities(-((int)power/3), ((int)power/3), -power);
43}

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 123 of file autonFunctions.cpp.

124{
125 lemlib::Pose targetPose(
126 expected_x + distance * std::sin(lemlib::degToRad(expected_theta)),
127 expected_y + distance * std::cos(lemlib::degToRad(expected_theta)),
128 expected_theta
129 );
130
131 chassis.moveToPoint(targetPose.x, targetPose.y, timeout_ms, {.forwards = forw, .earlyExitRange = earlyExit});
132}
Chassis chassis(drivebase, lateral_controller, angular_controller, sensors, &throttle_curve, &steer_curve)

References chassis().

Referenced by left_auton_split(), and skills_auton().

◆ score_longgoal()

void score_longgoal ( int power,
Color allianceColor )

Definition at line 45 of file autonFunctions.cpp.

46{
47 if(!hood.is_extended()) { hood.extend(); }
48 jamManager.set_velocities((int)power/3, -(int)power/3, power);
49}

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

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

◆ score_longgoal_auton()

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

Definition at line 79 of file autonFunctions.cpp.

80{
81 u_int32_t start_time = pros::millis();
82 if(!hood.is_extended()) {hood.extend();}
83 if(time != -1) {
84 while(pros::millis() - start_time < (u_int32_t)time) {
85 if(allianceColor != Color::NONE)
86 {
87 Color detected = get_color();
88 if(detected != Color::NONE && detected != allianceColor && color_sort_enable)
89 {
91 jamManager.set_velocities(-200, 600, -200);
92 pros::delay(100);
94 break;
95 }
96 }
97 jamManager.set_velocities((int)power/3, -(int)power/3, power);
98 chassis.tank(-20, -20);
99 pros::delay(10);
100 }
101 }
102 chassis.brake();
103 intake_stop();
104}
void intake_stop(bool hood_state)
Color get_color()
Definition colorSort.cpp:8
bool color_sort_enable
Definition globals.cpp:104
Color allianceColor
Definition globals.cpp:103

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

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

◆ score_midgoal()

void score_midgoal ( int power)

Definition at line 60 of file autonFunctions.cpp.

61{
62 jamManager.set_velocities((int)power/3, (int)power/3, power);
63}

References jamManager().

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

◆ score_midgoal_auton()

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

Definition at line 65 of file autonFunctions.cpp.

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

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

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 16 of file autonFunctions.cpp.

16 {
175.09498070723,
180.23396112183,
191.22496514644,
200.964796393603,
210.522291806997,
2210.933332351,
2344.6788428062,
24};

Referenced by awp_auton(), left_auton_split(), ltv(), right_7_wing(), right_auton_split(), skills_auton(), and test_auton().