Skip to content

Commit

Permalink
EZ-Template 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ssejrog committed Dec 9, 2021
1 parent e5737f7 commit 2cecaf7
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# Executables
*.bin
*.elf
.cache/

# PROS
.cache/
bin/
.vscode/
compile_commands.json
Expand Down
Binary file renamed [email protected][email protected]
Binary file not shown.
108 changes: 26 additions & 82 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,97 +1,41 @@
# EZ-Template-Example
### This is the example project for the EZ-Template library.

EZ-Template is a simple plug-and-play PROS template that handles drive base functions for VEX robots.

EZ-Template Version: 2.0.0-RC4
Example Project Version: 1.0.0-RC1
[EZ-Template Version](https://github.com/EZ-Robotics/EZ-Template): 2.0.0
[Example Project Version](https://github.com/EZ-Robotics/EZ-Template-Example): 1.0.0

[Autonomous routines that used EZ-Template](https://photos.app.goo.gl/yRwuvmq7hDoM4f6EA)

## Downloading

Download the latest released [here](https://github.com/EZ-Robotics/EZ-Template-Example/releases/latest) and open it as a new project in PROS.

## Features
<details closed>
<summary><bold>Joystick Curve</bold></summary>
<br>

> Using the [5225 curves from 2018](https://www.desmos.com/calculator/rcfjjg83zx), (explained [here](https://www.vexforum.com/t/team-5225a-in-the-zone-code-release-yes-you-read-that-right/63199/10)). The x-axis is the joystick input and the y-axis is the motor output.
> Normally, pushing the joystick half way means the robot goes half speed. With an input curve, pushing the joystick half way may only move the robot at 1/4 power. This means more of the joystick movement goes to lower speeds, giving you more control of the robot.
> When the robot is on, tapping/holding the left/right arrows will increase/decrease how large the curve is. When arcade is enabled, each stick will have it's own curve. The y/a buttons will increase/decrease the curve for the right stick.
> After you find values you like, in `src/main.cpp` set `chassis.set_curve_default(0, 0)` to whatever you liked! The first parameter is left stick, second is right stick.
</details>



<details closed>

<summary><bold>Active Brake</bold></summary>
<br>

> If you put the motors on brake type hold, a robot can still push the robot a bit, and when you let go of the joysticks the robot just locks in place. Active brake runs a P loop on the drive when you let go of the joysticks. By adjusting the kP, you adjust how hard the robot fights back. If you make it smaller, there will be a larger deadzone and you'll coast a little bit. Active brake vs brake type is personal preference.
> To adjust the kP, in `src/main.cpp` change `chassis.set_active_brake(0)` to whatever you like! We suggest around 0.1.
</details>



<details closed>

<summary><bold>Autonomous Drive PID with Slew</bold></summary>
<br>

> In autonomous, you input inches, the code converts that to ticks and that's our target position, the robot gets to that position using PD. The robot also uses the IMU to maintain a heading while driving straight.
> The robot also ramps up from a minimum speed to a maximum speed for X inches, that can be adjusted in `src/autons.cpp` in `default_constants()`. Make sure to uncomment `default_constants` in `src/main.cpp` too!.
> [Check out the tutorial on adding new autonomous routines here!](https://ez-robotics.github.io/EZ-Template/docs/Tutorials/autons.html)
</details>



<details closed>

<summary><bold>Turns and Simple Swing Turns</bold></summary>
<br>

> In autonomous, you input degrees and the robot turns to that angle using PID.
> The swing turns are `ez::LEFT_SWING` and `ez::RIGHT_SWING`, these functions turn using one side of the drive.
> [Check out the tutorial on adding new autonomous routines here!](https://ez-robotics.github.io/EZ-Template/docs/Tutorials/autons.html)
</details>



<details closed>

<summary><bold>Autonomous Selector</bold></summary>
<br>

> While the robot is in disabled, you can select an autonomous routine by pressing the left/right buttons on the brain! The page it's on when autonomous is enabled is the routine that will run.
> [Check out the tutorial on adding new autonomous routines here!](https://ez-robotics.github.io/EZ-Template/docs/Tutorials/autons.html)
</details>
Download the latest example project [here](https://github.com/EZ-Robotics/EZ-Template-Example/releases/latest) and open it as a new project in PROS.


## Setup
1) Download the latest release [here](https://github.com/EZ-Robotics/EZ-Template-Example/releases/latest). Extract it, and open it in PROS.
2) In `src/main.cpp`, configure drive and IMU ports to what they are on your robot. Be sure to read the comments!
3) Configure your wheel size and cartrige. Remember that 4" omni wheels are actually 4.125!
4) In `src/main.cpp`, at the bottom in `void opcontrol()`, decide how you'd like to control your robot! Any flavor of arcade or tank!
5) Turn the robot on and use it in driver control. Make sure the ports are correct and reversed correctly!
6) To test the test autonomous modes, plug into a competition switch and select the autonomous mode on the brain screen by pressing the left and right buttons! The current page will be the autonomous that runs. For making new autonomous routines, check `src/autons.cpp` for examples on how to use the drive functions.
1) Download the latest example project [here](https://github.com/EZ-Robotics/EZ-Template-Example/releases/latest). Extract it, and open it in PROS.
2) In `src/main.cpp`, configure drive and IMU ports to what they are on your robot. Be sure to read the comments!
3) Configure your wheel size and cartrige. Remember that 4" omni wheels are actually 4.125!
4) In `src/main.cpp`, at the bottom in `void opcontrol()`, decide how you'd like to control your robot! Any flavor of arcade or tank!
5) Turn the robot on and use it in driver control. Make sure the ports are correct and reversed correctly!
6) To test the test autonomous modes, plug into a competition switch and select the autonomous mode on the brain screen by pressing the left and right buttons! The current page will be the autonomous that runs. For making new autonomous routines, check `src/autons.cpp` for examples on how to use the drive functions.

## Upgrading
Note* this only works for 2.0.0 and beyond. You cannot upgrade from 1.X.X to 2.X.X.
1) Download the most recent [EZ-Template here](https://github.com/EZ-Robotics/EZ-Template/releases/latest).
2) In your terminal, `cd` into the directory you downloaded the file.
3) Run this command from terminal `prosv5 c fetch [email protected]`.
4) `cd` into your pros project directory in your terminal.
5) Apply the library to the project `prosv5 c apply EZ-Template`.
6) Put `#include "EZ-Template/api.hpp"` in your `include/main.h`.

## Tutorials
[Check out our tutorials here!](https://ez-robotics.github.io/EZ-Template/tutorials)

## Docs
[Read the docs here!](https://ez-robotics.github.io/EZ-Template/docs)

## Additing Autonomous Routines
[Check out the tutorial on adding new autonomous routines here!](https://ez-robotics.github.io/EZ-Template/docs/Tutorials/autons.html)

## License

Expand Down
Binary file modified firmware/EZ-Template.a
Binary file not shown.
11 changes: 11 additions & 0 deletions include/EZ-Template/drive/drive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ class Drive {
PID backward_drivePID;
PID swingPID;


/**
* Calibrates imu and initializes sd card to curve.
*/
void initialize();

/**
* Tasks for autonomous.
*/
Expand Down Expand Up @@ -343,6 +349,11 @@ class Drive {
*/
bool imu_calibrate();

/**
* Loading display whlie the IMU calibrates.
*/
void imu_loading_display(int iter);

/////
//
// Autonomous Functions
Expand Down
22 changes: 21 additions & 1 deletion include/EZ-Template/sdcard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,30 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.

namespace ez {
namespace as {
extern AutonSelector autoSelector;
extern AutonSelector auton_selector;
/**
* Sets sd card to current page.
*/
void init_auton_selector();
/**
* Sets the sd card to current page.
*/
void update_auto_sd();
/**
* Increases the page by 1.
*/
void page_up();
/**
* Decreases the page by 1.
*/
void page_down();
/**
* Initializes LLEMU and sets up callbacks for auton selector.
*/
void initialize();
/**
* Wrapper for pros::lcd::shutdown.
*/
void shutdown();
} // namespace as
} // namespace ez
16 changes: 8 additions & 8 deletions project.pros
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
"target": "v5",
"templates": {
"EZ-Template": {
"location": "C:\\Users\\union\\AppData\\Roaming\\PROS\\templates\\[email protected]-RC4",
"location": "C:\\Users\\union\\AppData\\Roaming\\PROS\\templates\\[email protected]",
"metadata": {
"origin": "local"
},
"name": "EZ-Template",
"py/object": "pros.conductor.templates.local_template.LocalTemplate",
"supported_kernels": "^3.5.3",
"supported_kernels": "^3.5.4",
"system_files": [
"firmware\\EZ-Template.a",
"include\\EZ-Template\\api.hpp",
"include\\EZ-Template\\auton.hpp",
"include\\EZ-Template\\drive\\drive.hpp",
"include\\EZ-Template\\sdcard.hpp",
"include\\EZ-Template\\util.hpp",
"include\\EZ-Template\\PID.hpp",
"include\\EZ-Template\\auton_selector.hpp"
"include\\EZ-Template\\auton_selector.hpp",
"include\\EZ-Template\\auton.hpp",
"include\\EZ-Template\\util.hpp",
"include\\EZ-Template\\sdcard.hpp",
"firmware\\EZ-Template.a"
],
"target": "v5",
"user_files": [],
"version": "2.0.0-RC4"
"version": "2.0.0"
},
"kernel": {
"location": "C:\\Users\\union\\AppData\\Roaming\\PROS\\templates\\[email protected]",
Expand Down
43 changes: 15 additions & 28 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@
Drive chassis (
// Left Chassis Ports (negative port will reverse it!)
// the first port is the sensored port (when trackers are not used!)
{-11, -5, -7}
{1, -2, 3}

// Right Chassis Ports (negative port will reverse it!)
// the first port is the sensored port (when trackers are not used!)
,{3, 2, 17}
,{-4, 5, -6}

// IMU Port
,18
,7

// Wheel Diameter (Remember, 4" wheels are actually 4.125!)
// (or tracking wheel diameter)
,3.25
,4.125

// Cartridge RPM
// (or tick per rotation if using tracking wheels)
,600

,200

// External Gear Ratio (MUST BE DECIMAL)
// (or gear ratio of tracking wheel)
// eg. if your drive is 84:36 where the 36t is powered, your RATIO would be 2.333.
// eg. if your drive is 36:60 where the 60t is powered, your RATIO would be 0.6.
,1.66666666667
,1

// Uncomment if using tracking wheels
/*
// Left Tracking Wheel Ports (negative port will reverse it!)
,{1, 2}
// Right Tracking Wheel Ports (negative port will reverse it!)
,{3, 4}
*/
Expand All @@ -57,22 +57,18 @@ void initialize() {

pros::delay(500); // Stop the user from doing anything while legacy ports configure.

// Check if SD card is pluged in
if (!ez::util::IS_SD_CARD) printf("No SD Card Found!\n");

// Configure your chassis controls
chassis.init_curve_sd(); // Initialize the input curves with what's on the SD card (this does nothing if there's no SD card)
chassis.toggle_modify_curve_with_controller(true); // Enables modifying the controller curve with buttons on the joysticks
chassis.set_active_brake(0); // Sets the active brake kP. We recommend 0.1.
chassis.set_curve_default(0, 0); // Defaults for curve
// default_constants(); // Set the drive to your own constants!
chassis.set_curve_default(0, 0); // Defaults for curve. (Comment this line out if you have an SD card!)
// default_constants(); // Set the drive to your own constants from autons.cpp!

// These are already defaulted to these buttons, but you can change the left/right curve buttons here!
// chassis.set_left_curve_buttons (pros::E_CONTROLLER_DIGITAL_LEFT, pros::E_CONTROLLER_DIGITAL_RIGHT);
// chassis.set_right_curve_buttons(pros::E_CONTROLLER_DIGITAL_Y, pros::E_CONTROLLER_DIGITAL_A);

// Autonomous Selector using LLEMMU
ez::as::autoSelector.add_autons({
ez::as::auton_selector.add_autons({
Auton("Example Drive\n\nDrive forward and come back.", drive_example),
Auton("Example Turn\n\nTurn 3 times.", turn_example),
Auton("Drive and Turn\n\nDrive forward, turn, come back. ", drive_and_turn),
Expand All @@ -82,18 +78,9 @@ void initialize() {
Auton("Interference\n\nAfter driving forward, robot performs differently if interfered or not.", interfered_example),
});

// Initialize auto selector and LLEMU
pros::lcd::initialize();
ez::as::init_auton_selector();

// Callbacks for auto selector
ez::as::autoSelector.print_selected_auton();
pros::lcd::register_btn0_cb(ez::as::page_down);
pros::lcd::register_btn2_cb(ez::as::page_up);

// Calibrate IMU
if (!chassis.imu_calibrate())
pros::lcd::set_text(7, "IMU failed to calibrate!");
// Initialize chassis and auton selector
chassis.initialize();
ez::as::initialize();
}


Expand Down Expand Up @@ -140,7 +127,7 @@ void autonomous() {
chassis.reset_drive_sensor(); // Reset drive sensors to 0
chassis.set_drive_brake(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency.

ez::as::autoSelector.call_selected_auton(); // Calls selected auton from autonomous selector.
ez::as::auton_selector.call_selected_auton(); // Calls selected auton from autonomous selector.
}


Expand Down Expand Up @@ -176,4 +163,4 @@ void opcontrol() {

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

0 comments on commit 2cecaf7

Please sign in to comment.