diff --git a/README.md b/README.md index aa6c9639..60280517 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ --- layout: default -title: 404 -nav_exclude: true +title: EZ-Template +nav_order: 1 +permalink: / --- -# EZ-Template +[![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0) -[![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0) +# EZ-Template Simple plug-and-play PROS template that handles drive base functions for VEX robots. @@ -15,13 +16,8 @@ Simple plug-and-play PROS template that handles drive base functions for VEX rob [Autonomous routines that used EZ-Template](https://photos.app.goo.gl/yRwuvmq7hDoM4f6EA) -## Downloading - -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 example project [here](https://github.com/EZ-Robotics/EZ-Template-Example/releases/latest). Extract it, and open it in PROS. +## Download and Installation +1) Download the latest example project [here](https://github.com/EZ-Robotics/EZ-Template-Example/releases/latest). Extract the zip, 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! @@ -29,8 +25,8 @@ Download the latest example project [here](https://github.com/EZ-Robotics/EZ-Tem 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). +*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 EZ-Template@2.0.0.zip`. 4) `cd` into your pros project directory in your terminal. @@ -45,7 +41,7 @@ Note* this only works for 2.0.0 and beyond. You cannot upgrade from 1.X.X to 2. ## Additing Autonomous Routines -[Check out the tutorial on adding new autonomous routines here!](/docs/autons.md) +[Check out the tutorial on adding new autonomous routines here!]([/docs](https://ez-robotics.github.io/EZ-Template/docs/Tutorials/autons.html) ## License diff --git a/docs/Tutorials/activebrake.md b/docs/Tutorials/activebrake.md index e9434bdf..39ddb338 100644 --- a/docs/Tutorials/activebrake.md +++ b/docs/Tutorials/activebrake.md @@ -2,7 +2,7 @@ layout: default title: Active Brake parent: Tutorials -nav_order: 3 +nav_order: 4 --- diff --git a/docs/Tutorials/example_autons.md b/docs/Tutorials/example_autons.md new file mode 100644 index 00000000..fe454373 --- /dev/null +++ b/docs/Tutorials/example_autons.md @@ -0,0 +1,223 @@ +--- +layout: default +title: Example Autonomous Routines +parent: Tutorials +nav_order: 2 +--- + + +# **Adding Autonomous Routines** +{: .no_toc } + +## Table of contents +{: .no_toc .text-delta } + +1. TOC +{:toc} + + +--- + + + +## Assumed Constants +```cpp +const int DRIVE_SPEED = 110; +const int TURN_SPEED = 90; +const int SWING_SPEED = 90; +``` + + +--- + + +## Drive +```cpp +void drive_example() { + // The first parameter is target inches + // The second parameter is max speed the robot will drive at + // The third parameter is a boolean (true or false) for enabling/disabling a slew at the start of drive motions + // for slew, only enable it when the drive distance is greater then the slew distance + a few inches + + + chassis.set_drive_pid(24, DRIVE_SPEED, true); + chassis.wait_drive(); + + chassis.set_drive_pid(-12, DRIVE_SPEED); + chassis.wait_drive(); + + chassis.set_drive_pid(-12, DRIVE_SPEED); + chassis.wait_drive(); +} +``` + + +--- + + +## Turn +```cpp +void turn_example() { + // The first parameter is target degrees + // The second parameter is max speed the robot will drive at + + + chassis.set_turn_pid(90, TURN_SPEED); + chassis.wait_drive(); + + chassis.set_turn_pid(45, TURN_SPEED); + chassis.wait_drive(); + + chassis.set_turn_pid(0, TURN_SPEED); + chassis.wait_drive(); +} +``` + + +--- + + +## Drive and Turn +```cpp +void drive_and_turn() { + chassis.set_drive_pid(24, DRIVE_SPEED, true); + chassis.wait_drive(); + + chassis.set_turn_pid(45, TURN_SPEED); + chassis.wait_drive(); + + chassis.set_turn_pid(-45, TURN_SPEED); + chassis.wait_drive(); + + chassis.set_turn_pid(0, TURN_SPEED); + chassis.wait_drive(); + + chassis.set_drive_pid(-24, DRIVE_SPEED, true); + chassis.wait_drive(); +} +``` + + +--- + + +## Wait Until and Changing Speed +```cpp +void wait_until_change_speed() { + // wait_until will wait until the robot gets to a desired position + + + // When the robot gets to 12 inches, the robot will travel the remaining distance at a max speed of 40 + chassis.set_drive_pid(24, DRIVE_SPEED, true); + chassis.wait_until(6); + chassis.set_max_speed(40); // After driving 12 inches at DRIVE_SPEED, the robot will go the remaining distance at 40 speed + chassis.wait_drive(); + + chassis.set_turn_pid(45, TURN_SPEED); + chassis.wait_drive(); + + chassis.set_turn_pid(-45, TURN_SPEED); + chassis.wait_drive(); + + chassis.set_turn_pid(0, TURN_SPEED); + chassis.wait_drive(); + + // When the robot gets to -12 inches, the robot will travel the remaining distance at a max speed of 40 + chassis.set_drive_pid(-24, DRIVE_SPEED, true); + chassis.wait_until(-6); + chassis.set_max_speed(40); // After driving 12 inches at DRIVE_SPEED, the robot will go the remaining distance at 40 speed + chassis.wait_drive(); +} +``` + + +--- + + +## Swing Turns +```cpp +void swing_example() { + // The first parameter is ez::LEFT_SWING or ez::RIGHT_SWING + // The second parameter is target degrees + // The third parameter is speed of the moving side of the drive + + + chassis.set_swing_pid(ez::LEFT_SWING, 45, SWING_SPEED); + chassis.wait_drive(); + + chassis.set_drive_pid(24, DRIVE_SPEED, true); + chassis.wait_until(12); + + chassis.set_swing_pid(ez::RIGHT_SWING, 0, SWING_SPEED); + chassis.wait_drive(); +} +``` + + +--- + + +## Combining All Movements +```cpp +void combining_movements() { + chassis.set_drive_pid(24, DRIVE_SPEED, true); + chassis.wait_drive(); + + chassis.set_turn_pid(45, TURN_SPEED); + chassis.wait_drive(); + + chassis.set_drive_pid(ez::RIGHT_SWING, -45, TURN_SPEED); + chassis.wait_drive(); + + chassis.set_turn_pid(0, TURN_SPEED); + chassis.wait_drive(); + + chassis.set_drive_pid(-24, DRIVE_SPEED, true); + chassis.wait_drive(); +} +``` + + +--- + + +## Interference +```cpp +void tug (int attempts) { + for (int i=0; i #include "main.h" -#include "filesystem" namespace ez { namespace as { @@ -23,12 +22,6 @@ void update_auto_sd() { fclose(usd_file_write); } -bool is_file_exist(const char *fileName) -{ - std::ifstream infile(fileName); - return infile.good(); -} - void init_auton_selector() { // If no SD card, return if (!ez::util::IS_SD_CARD) return; diff --git a/src/autons.cpp b/src/autons.cpp index 47a2bd0c..3003c31b 100644 --- a/src/autons.cpp +++ b/src/autons.cpp @@ -54,8 +54,7 @@ void two_mogo_constants() { /// // Drive Example /// -void -drive_example() { +void drive_example() { // The first parameter is target inches // The second parameter is max speed the robot will drive at // The third parameter is a boolean (true or false) for enabling/disabling a slew at the start of drive motions @@ -77,8 +76,7 @@ drive_example() { /// // Turn Example /// -void -turn_example() { +void turn_example() { // The first parameter is target degrees // The second parameter is max speed the robot will drive at @@ -98,8 +96,7 @@ turn_example() { /// // Combining Turn + Drive /// -void -drive_and_turn() { +void drive_and_turn() { chassis.set_drive_pid(24, DRIVE_SPEED, true); chassis.wait_drive(); @@ -121,8 +118,7 @@ drive_and_turn() { /// // Wait Until and Changing Max Speed /// -void -wait_until_change_speed() { +void wait_until_change_speed() { // wait_until will wait until the robot gets to a desired position @@ -153,8 +149,7 @@ wait_until_change_speed() { /// // Swing Example /// -void -swing_example() { +void swing_example() { // The first parameter is ez::LEFT_SWING or ez::RIGHT_SWING // The second parameter is target degrees // The third parameter is speed of the moving side of the drive @@ -175,8 +170,7 @@ swing_example() { /// // Auto that tests everything /// -void -combining_movements() { +void combining_movements() { chassis.set_drive_pid(24, DRIVE_SPEED, true); chassis.wait_drive();