Skip to content

Commit

Permalink
Remove unused configuration files and update motor configurations for…
Browse files Browse the repository at this point in the history
… improved functionality
  • Loading branch information
NoozAbooz committed Jan 24, 2025
1 parent dcfd4c0 commit 9d475c3
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 46 deletions.
11 changes: 0 additions & 11 deletions .clang-format

This file was deleted.

2 changes: 0 additions & 2 deletions .clangd

This file was deleted.

2 changes: 1 addition & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ LIBRARIES+=$(wildcard $(FWDIR)/*.a)
EXCLUDE_COLD_LIBRARIES+=$(FWDIR)/libc.a $(FWDIR)/libm.a
COLD_LIBRARIES=$(filter-out $(EXCLUDE_COLD_LIBRARIES), $(LIBRARIES))
wlprefix=-Wl,$(subst $(SPACE),$(COMMA),$1)
LNK_FLAGS=--gc-sections --start-group $(strip $(LIBRARIES)) -lgcc -lstdc++ --end-group -T$(FWDIR)/v5-common.ld
LNK_FLAGS=--gc-sections --start-group $(strip $(LIBRARIES)) -lgcc -lstdc++ --end-group -T$(FWDIR)/v5-common.ld --no-warn-rwx-segments

ASMFLAGS=$(MFLAGS) $(WARNFLAGS)
CFLAGS=$(MFLAGS) $(CPPFLAGS) $(WARNFLAGS) $(GCCFLAGS) --std=$(C_STANDARD)
Expand Down
1 change: 1 addition & 0 deletions include/abstractGlobals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ void rdconfig_init();

extern std::string alliance;
extern std::string field_status;
extern bool intakeLock;
extern void competitionTelemtryRefresh();

/* Functions */
Expand Down
12 changes: 6 additions & 6 deletions include/deviceGlobals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ inline pros::Controller controller(pros::E_CONTROLLER_MASTER);
// inline pros::MotorGroup rightDrive({-12, 13, -17});

// v1
inline pros::MotorGroup leftDrive({-18, 19, 20});
inline pros::MotorGroup rightDrive({-11, 12, 13});
inline pros::MotorGroup leftDrive({11, -12, -13});
inline pros::MotorGroup rightDrive({18, -19, 20});

// Intake
inline pros::Motor intake(-14);
inline pros::MotorGroup wallStake({-13, 14});
inline pros::MotorGroup intake({-17, -8});
inline pros::Motor wallStake(21);

// Pneumatics
inline pros::adi::Pneumatics clampPiston('A', false);
inline pros::adi::Pneumatics doinkerPiston('B', false);

/* Declare sensors */
inline pros::Optical optical(14);
inline pros::Optical optical(2);
inline pros::Imu inertial1(17);
inline pros::Imu inertial2(15);
inline pros::Rotation wallStakeRotationSensor(12);
inline pros::Rotation wallStakeRotationSensor(10);

inline pros::Rotation verticalEncoder(4);
inline pros::Rotation horizontalEncoder(-5);
Expand Down
2 changes: 1 addition & 1 deletion include/libKS/drivetrain/chassis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
namespace ks {
void moveRaw(int voltage, int time);
double driveCurve(double input, double curve);
void arcadeDrive(int linCurve, int rotCurve, double turnScale);
void arcadeDrive(int linCurve = 0, int rotCurve = 0, double turnScale = 1);
}
11 changes: 7 additions & 4 deletions src/init/initialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ void initialize() {
// chassis.calibrate();
// });
ks::initializeOdom();
initializeColourSort();

optical.set_led_pwm(75); // enable led on optical sensor for accuracy
optical.set_integration_time(10); // refresh every 10ms
wallStake.set_brake_mode(pros::E_MOTOR_BRAKE_HOLD);
intake.get_brake_mode(pros::E_MOTOR_BRAKE_BRAKE);

inertial1.set_data_rate(5);
inertial2.set_data_rate(5);
Expand All @@ -46,17 +48,18 @@ void disabled() {
* This task will exit when the robot is enabled and autonomous or opcontrol
* starts.
*/
void competitionTelemtryRefresh(std::optional<rd::Selector::routine_t> routine) {
if (!routine.has_value()) return;
controller.print(0, 0, "%s |%s| %.0lf", alliance.c_str(), routine.value().action, chassis.getPose().theta);
void competitionTelemtryRefresh() {
auto auton = gui_selector.get_auton();
const char* auton_name = auton->name.c_str();
controller.print(0, 0, "%s|%s|%.0lf", alliance.c_str(), auton_name, chassis.getPose().theta);
}

void competition_initialize() {
rd_view_focus(allianceview);
field_status = "competition";

gui_selector.on_select([](std::optional<rd::Selector::routine_t> routine) {
competitionTelemtryRefresh(routine);
competitionTelemtryRefresh();
});

// pros::Task([] { // legacy way of doing above
Expand Down
11 changes: 8 additions & 3 deletions src/libKS/drivetrain/chassis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ double ks::driveCurve(double input, double curve) {
}

void ks::arcadeDrive(int linCurve, int rotCurve, double turnScale) {
// poll joystick input and convert to mv, then run through drivecurve function
int power = ks::driveCurve(controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y), linCurve);
int turn = ks::driveCurve(controller.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_X), rotCurve);
int power = controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
int turn = controller.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_X) * turnScale;

if (linCurve != 0 && rotCurve != 0) {
// poll joystick input and convert to mv, then run through drivecurve function
power = ks::driveCurve(controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y), linCurve);
turn = ks::driveCurve(controller.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_X), rotCurve) * turnScale;
}

// move motors based on direction (eg move left more when turn is positive)
leftDrive.move_voltage((power + turn) * (12000.0 / 127));
Expand Down
4 changes: 4 additions & 0 deletions src/libKS/drivetrain/odom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ double avg_heading;
double deltaXLocal;
double deltaYLocal;

void ks::initializeOdom() {
pros::Task odom_task(ks::odomUpdate);
}

void ks::setOdomPosition(double x_new, double y_new, double theta_new) {
x = 0;
y = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void opcontrol() {

while (true) { // Main continuous loop
/* Drive */
ks::arcadeDrive(0, 0, 1);
ks::arcadeDrive(0, 0, 1.2);

/* Subsystem Listeners */
refreshIntake();
Expand Down
25 changes: 14 additions & 11 deletions src/subsystem/colourSort.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
#include "main.h"

bool sortToggle = true;
bool lock = false;
bool intakeLock = false;

// Colour Sorter


void initializeColourSort() {
pros::Task([] {
while (true) {
if (alliance == "red" && optical.get_hue() > 100 && optical.get_hue() < 200 && lock == false && sortToggle == true) {
//console.printf("Hue: %d\n", optical.get_hue());
if (alliance == "red" && optical.get_hue() > 100 && optical.get_hue() < 230) {
// eject blue rings
console.println("eject blue impostor");
intakeLock = true;
intake.brake();
pros::delay(600);
intake.move_voltage(12000);
intakeLock = false;
}
if (alliance == "blue" && optical.get_hue() > 15 && optical.get_hue() < 40 && lock == false && sortToggle == true) {
if (alliance == "blue" && optical.get_hue() > 15 && optical.get_hue() < 40) {
// eject red rings
intake.brake();
console.println("eject red impostor");
}

if (controller.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_B)) {
sortToggle = !sortToggle;
optical.set_led_pwm((sortToggle == true ? 75 : 0)); // Turn off LED if not sorting
}

pros::delay(10);
}
});
}
17 changes: 11 additions & 6 deletions src/subsystem/opcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

// Intake (hold down button to spin motor)
void refreshIntake() {
if(controller.get_digital(pros::E_CONTROLLER_DIGITAL_L1)) {
intake.move_voltage(12000);
} else if (controller.get_digital(pros::E_CONTROLLER_DIGITAL_L2)) {
intake.move_voltage(-12000);
} else {
intake.move_voltage(0);
if (intakeLock == false) {
if(controller.get_digital(pros::E_CONTROLLER_DIGITAL_L1)) {
intake.move_voltage(12000);

// stuff anti-jam system here too

} else if (controller.get_digital(pros::E_CONTROLLER_DIGITAL_L2)) {
intake.move_voltage(-12000);
} else {
intake.move_voltage(0);
}
}
}

Expand Down

0 comments on commit 9d475c3

Please sign in to comment.