Skip to content

Commit

Permalink
Cleaned up example project
Browse files Browse the repository at this point in the history
  • Loading branch information
ssejrog committed Jun 9, 2024
1 parent 7c3a386 commit e7c6b2a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
2 changes: 2 additions & 0 deletions EZ-Template-Example-Project/include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

// More includes here...
#include "autons.hpp"
#include "subsystems.hpp"


/**
* If you find doing pros::Motor() to be tedious and you'd prefer just to do
Expand Down
8 changes: 8 additions & 0 deletions EZ-Template-Example-Project/include/subsystems.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include "api.h"

// Your motors, sensors, etc. should go here. Below are examples

// inline pros::Motor intake(1);
// inline pros::adi::DigitalIn limit_switch('A');
4 changes: 2 additions & 2 deletions EZ-Template-Example-Project/src/autons.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "main.h"

/////
// For installation, upgrading, documentations and tutorials, check out our website!
// For installation, upgrading, documentations, and tutorials, check out our website!
// https://ez-robotics.github.io/EZ-Template/
/////

Expand Down Expand Up @@ -144,7 +144,7 @@ void motion_chaining() {
// This works by exiting while the robot is still moving a little bit.
// To use this, replace pid_wait with pid_wait_quick_chain.
chassis.pid_drive_set(24_in, DRIVE_SPEED, true);
chassis.pid_wait_quick_chain();
chassis.pid_wait();

chassis.pid_turn_set(45_deg, TURN_SPEED);
chassis.pid_wait_quick_chain();
Expand Down
26 changes: 15 additions & 11 deletions EZ-Template-Example-Project/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "main.h"

/////
// For installation, upgrading, documentations and tutorials, check out our website!
// For installation, upgrading, documentations, and tutorials, check out our website!
// https://ez-robotics.github.io/EZ-Template/
/////

Expand Down Expand Up @@ -29,15 +29,15 @@ void initialize() {

// Configure your chassis controls
chassis.opcontrol_curve_buttons_toggle(true); // Enables modifying the controller curve with buttons on the joysticks
chassis.opcontrol_drive_activebrake_set(0); // Sets the active brake kP. We recommend 2.
chassis.opcontrol_drive_activebrake_set(0); // Sets the active brake kP. We recommend ~2. 0 will disable.
chassis.opcontrol_curve_default_set(0, 0); // Defaults for curve. If using tank, only the first parameter is used. (Comment this line out if you have an SD card!)

// Set the drive to your own constants from autons.cpp!
default_constants();

// These are already defaulted to these buttons, but you can change the left/right curve buttons here!
// chassis.opcontrol_curve_buttons_left_set (pros::E_CONTROLLER_DIGITAL_LEFT, pros::E_CONTROLLER_DIGITAL_RIGHT); // If using tank, only the left side is used.
// chassis.opcontrol_curve_buttons_right_set(pros::E_CONTROLLER_DIGITAL_Y, pros::E_CONTROLLER_DIGITAL_A);
// chassis.opcontrol_curve_buttons_left_set(pros::E_CONTROLLER_DIGITAL_LEFT, pros::E_CONTROLLER_DIGITAL_RIGHT); // If using tank, only the left side is used.
// chassis.opcontrol_curve_buttons_right_set(pros::E_CONTROLLER_DIGITAL_Y, pros::E_CONTROLLER_DIGITAL_A);

// Autonomous Selector using LLEMU
ez::as::auton_selector.autons_add({
Expand Down Expand Up @@ -114,7 +114,9 @@ void autonomous() {
*/
void opcontrol() {
// This is preference to what you like to drive on
chassis.drive_brake_set(MOTOR_BRAKE_COAST);
pros::motor_brake_mode_e_t driver_preference_brake = MOTOR_BRAKE_COAST;

chassis.drive_brake_set(driver_preference_brake);

while (true) {
// PID Tuner
Expand All @@ -128,22 +130,24 @@ void opcontrol() {
chassis.pid_tuner_toggle();

// Trigger the selected autonomous routine
if (master.get_digital_new_press(DIGITAL_B) && master.get_digital(DIGITAL_DOWN))
if (master.get_digital(DIGITAL_B) && master.get_digital(DIGITAL_DOWN)) {
autonomous();
chassis.drive_brake_set(driver_preference_brake);
}

chassis.pid_tuner_iterate(); // Allow PID Tuner to iterate
}

chassis.opcontrol_tank(); // Tank control
// chassis.opcontrol_arcade_standard(ez::SPLIT); // Standard split arcade
// chassis.opcontrol_arcade_standard(ez::SINGLE); // Standard single arcade
// chassis.opcontrol_arcade_flipped(ez::SPLIT); // Flipped split arcade
// chassis.opcontrol_arcade_flipped(ez::SINGLE); // Flipped single arcade
// chassis.opcontrol_arcade_standard(ez::SPLIT); // Standard split arcade
// chassis.opcontrol_arcade_standard(ez::SINGLE); // Standard single arcade
// chassis.opcontrol_arcade_flipped(ez::SPLIT); // Flipped split arcade
// chassis.opcontrol_arcade_flipped(ez::SINGLE); // Flipped single arcade

// . . .
// Put more user control code here!
// . . .

pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
}

0 comments on commit e7c6b2a

Please sign in to comment.