r
This commit is contained in:
parent
a7404de94c
commit
5f8419afad
|
@ -36,7 +36,21 @@
|
|||
+ Opposing side
|
||||
+ Scores 9 points
|
||||
+ Can counter other teams
|
||||
+ Currently a legacy auton
|
||||
6. AUTON 6
|
||||
Push auton. Moves 2ft backward then 0.5ft forward.
|
||||
Push auton. Moves the same amount as auton 0 forward, then reverses.
|
||||
+ Utility auton
|
||||
|
||||
7. AUTON 7
|
||||
Allows us to bowl triballs off the top of the robot, then drives forward to push them into goal.
|
||||
+ Skills auton
|
||||
8. AUTON 8
|
||||
Drives forward, grabs triball, then turns around and pushes two field triballs to other side.
|
||||
+ Opposing Side
|
||||
+ Elim auton
|
||||
+ Refined version of AUTON 5
|
||||
+ Can counter other teams
|
||||
9. AUTON 9
|
||||
Drives forward and pushes three triballs into the goal. Also attempts to score our match load.
|
||||
+ Our side
|
||||
+ Can counter other teams
|
||||
+ Elim auton
|
||||
|
|
235
src/main.cpp
235
src/main.cpp
|
@ -9,7 +9,9 @@
|
|||
/**
|
||||
* You should add more #includes here
|
||||
*/
|
||||
#include "display/lv_core/lv_obj.h"
|
||||
#include "display/lv_misc/lv_task.h"
|
||||
#include "display/lv_objx/lv_img.h"
|
||||
#include "okapi/api.hpp"
|
||||
#include "okapi/api/device/motor/abstractMotor.hpp"
|
||||
#include "okapi/api/units/QLength.hpp"
|
||||
|
@ -27,6 +29,62 @@
|
|||
// 1 2 3 5 //left
|
||||
// 7 8 9 10 //right
|
||||
|
||||
// FILE HANDLE CODE:
|
||||
|
||||
typedef FILE *pc_file_t;
|
||||
|
||||
static lv_fs_res_t pcfs_open(void *file_p, const char *fn, lv_fs_mode_t mode) {
|
||||
errno = 0;
|
||||
const char *flags = "";
|
||||
if (mode == LV_FS_MODE_WR)
|
||||
flags = "wb";
|
||||
else if (mode == LV_FS_MODE_RD)
|
||||
flags = "rb";
|
||||
else if (mode == (LV_FS_MODE_WR | LV_FS_MODE_RD))
|
||||
flags = "a+";
|
||||
|
||||
char buf[256];
|
||||
sprintf(buf, "/%s", fn);
|
||||
pc_file_t f = fopen(buf, flags);
|
||||
|
||||
if (f == NULL)
|
||||
return LV_FS_RES_UNKNOWN;
|
||||
else {
|
||||
fseek(f, 0, SEEK_SET);
|
||||
pc_file_t *fp = (pc_file_t *)file_p;
|
||||
*fp = f;
|
||||
}
|
||||
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
static lv_fs_res_t pcfs_close(void *file_p) {
|
||||
pc_file_t *fp = (pc_file_t *)file_p;
|
||||
fclose(*fp);
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
static lv_fs_res_t pcfs_read(void *file_p, void *buf, uint32_t btr,
|
||||
uint32_t *br) {
|
||||
pc_file_t *fp = (pc_file_t *)file_p;
|
||||
*br = fread(buf, 1, btr, *fp);
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
static lv_fs_res_t pcfs_seek(void *file_p, uint32_t pos) {
|
||||
pc_file_t *fp = (pc_file_t *)file_p;
|
||||
fseek(*fp, pos, SEEK_SET);
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
static lv_fs_res_t pcfs_tell(void *file_p, uint32_t *pos_p) {
|
||||
pc_file_t *fp = (pc_file_t *)file_p;
|
||||
*pos_p = ftell(*fp);
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
// end file drivers
|
||||
|
||||
int autonpick = 0;
|
||||
int automod = 0;
|
||||
lv_res_t sa0(lv_obj_t *btn) {
|
||||
|
@ -125,7 +183,8 @@ bool is_held(bool *log, bool ap) {
|
|||
* to keep execution time for this mode under a few seconds.
|
||||
*/
|
||||
void initialize() {
|
||||
pros::lcd::initialize();
|
||||
// pros::lcd::initialize();
|
||||
|
||||
// pros::lcd::set_text(1, "Hello PROS User!");
|
||||
|
||||
pros::lcd::register_btn1_cb(on_center_button);
|
||||
|
@ -226,7 +285,7 @@ void autonomous() {
|
|||
upflap.set_value(false);
|
||||
|
||||
pros::Imu IMU(19);
|
||||
//IMU.reset(true);
|
||||
// IMU.reset(true);
|
||||
IMU.tare();
|
||||
pros::delay(200);
|
||||
|
||||
|
@ -247,7 +306,8 @@ void autonomous() {
|
|||
std::printf("yaw: %f\n", yaw);
|
||||
// double turn = -92 - yaw;
|
||||
double turn = 45 - yaw;
|
||||
std:printf("turn: %f\n", turn);
|
||||
std:
|
||||
printf("turn: %f\n", turn);
|
||||
drive->setMaxVelocity(300);
|
||||
drive->turnAngle(turn * 1_deg);
|
||||
drive->moveDistanceAsync(4.1_ft);
|
||||
|
@ -316,7 +376,7 @@ void autonomous() {
|
|||
(900 -
|
||||
temp), // pull.moveRelative((1800
|
||||
//-
|
||||
//std::fmod(pull.getPosition(), 1800)),
|
||||
// std::fmod(pull.getPosition(), 1800)),
|
||||
|
||||
10000000);
|
||||
reqtopull = false;
|
||||
|
@ -395,8 +455,8 @@ void autonomous() {
|
|||
pros::delay(500);
|
||||
|
||||
auto starttime = Timer().millis();
|
||||
while (Timer().millis() < starttime + 1.5_s ) {
|
||||
drive->getModel()->curvature(-12000 , IMU.get_rotation() * -0.04);
|
||||
while (Timer().millis() < starttime + 1.5_s) {
|
||||
drive->getModel()->curvature(-12000, IMU.get_rotation() * -0.04);
|
||||
|
||||
// printf("%i\n", distforward.get());
|
||||
pros::delay(10);
|
||||
|
@ -408,12 +468,12 @@ void autonomous() {
|
|||
|
||||
drive->moveDistance(1_in);
|
||||
// drive->turnAngle(15_deg);
|
||||
//drive->moveDistance(-3.8_ft);
|
||||
//drive->turnAngle(90_deg);
|
||||
// drive->moveDistance(-3.8_ft);
|
||||
// drive->turnAngle(90_deg);
|
||||
bool imuholdarray[10];
|
||||
|
||||
while (!is_held(imuholdarray, (abs(68.0 - IMU.get_rotation()) < 1)) ) {
|
||||
drive->getModel()->rotate((68.0 - IMU.get_rotation()) * 0.008 );
|
||||
while (!is_held(imuholdarray, (abs(68.0 - IMU.get_rotation()) < 1))) {
|
||||
drive->getModel()->rotate((68.0 - IMU.get_rotation()) * 0.008);
|
||||
pros::delay(10);
|
||||
}
|
||||
|
||||
|
@ -432,10 +492,9 @@ void autonomous() {
|
|||
}
|
||||
|
||||
if (autonpick == 6) {
|
||||
drive->setMaxVelocity(600);
|
||||
float x = 2;
|
||||
drive->moveDistance(x * -1_ft);
|
||||
pros::delay(500);
|
||||
float x = -2.7;
|
||||
drive->moveDistanceAsync(x * 1_ft);
|
||||
pros::delay(2500);
|
||||
drive->moveDistance(0.5_ft);
|
||||
}
|
||||
|
||||
|
@ -443,17 +502,19 @@ void autonomous() {
|
|||
drive->moveDistance(-1_ft);
|
||||
piston.set_value(true);
|
||||
pros::delay(44500);
|
||||
|
||||
drive->moveDistance(1_ft);
|
||||
piston.set_value(true);
|
||||
|
||||
piston.set_value(false);
|
||||
drive->turnAngle(-45_deg);
|
||||
funnypiston.set_value(true);
|
||||
pros::delay(500);
|
||||
drive->moveDistance(6.5_ft);
|
||||
drive->moveDistance(7.5_ft);
|
||||
drive->turnAngle(-45_deg);
|
||||
drive->moveDistance(1_ft);
|
||||
drive->moveDistance(-1_ft);
|
||||
drive->moveDistance(1_ft);
|
||||
drive->moveDistance(-1_ft);
|
||||
drive->moveDistance(2_ft);
|
||||
drive->moveDistance(-2_ft);
|
||||
drive->moveDistance(2_ft);
|
||||
drive->moveDistance(-2_ft);
|
||||
}
|
||||
if (autonpick == 8) {
|
||||
pros::Distance distforward(17);
|
||||
|
@ -475,8 +536,8 @@ void autonomous() {
|
|||
pros::delay(500);
|
||||
|
||||
auto starttime = Timer().millis();
|
||||
while (Timer().millis() < starttime + 1.5_s ) {
|
||||
drive->getModel()->curvature(-6000 , IMU.get_rotation() * -0.04);
|
||||
while (Timer().millis() < starttime + 1.5_s) {
|
||||
drive->getModel()->curvature(-6000, IMU.get_rotation() * -0.04);
|
||||
|
||||
// printf("%i\n", distforward.get());
|
||||
pros::delay(10);
|
||||
|
@ -488,12 +549,12 @@ void autonomous() {
|
|||
|
||||
drive->moveDistance(1_in);
|
||||
// drive->turnAngle(15_deg);
|
||||
//drive->moveDistance(-3.8_ft);
|
||||
//drive->turnAngle(90_deg);
|
||||
// drive->moveDistance(-3.8_ft);
|
||||
// drive->turnAngle(90_deg);
|
||||
bool imuholdarray[10];
|
||||
|
||||
while (!is_held(imuholdarray, (abs(70.0 - IMU.get_rotation()) < 1)) ) {
|
||||
drive->getModel()->rotate((70.0 - IMU.get_rotation()) * 0.008 );
|
||||
while (!is_held(imuholdarray, (abs(70.0 - IMU.get_rotation()) < 1))) {
|
||||
drive->getModel()->rotate((70.0 - IMU.get_rotation()) * 0.008);
|
||||
pros::delay(10);
|
||||
}
|
||||
|
||||
|
@ -514,8 +575,104 @@ void autonomous() {
|
|||
// drive->moveDistance(-1.5_ft);
|
||||
}
|
||||
|
||||
if (autonpick == 9) {
|
||||
piston.set_value(true);
|
||||
pros::delay(300);
|
||||
piston.set_value(false);
|
||||
pros::Distance distforward(17);
|
||||
// drive->moveDistanceAsync(500_ft);
|
||||
drive->getModel()->setBrakeMode(okapi::AbstractMotor::brakeMode::hold);
|
||||
// piston.set_value(true);
|
||||
// NEED TO WRTIE IMU CENTER CODE
|
||||
// update IMU each cycle to get true rotation
|
||||
while (distforward.get() > 300) {
|
||||
drive->getModel()->curvature(12000, IMU.get_rotation() * -0.04);
|
||||
|
||||
// printf("%i\n", distforward.get());
|
||||
pros::delay(10);
|
||||
}
|
||||
drive->stop();
|
||||
funnypiston.set_value(true);
|
||||
pros::delay(500);
|
||||
|
||||
drive->setMaxVelocity(200);
|
||||
drive->moveDistance(-1_in);
|
||||
|
||||
bool imuholdarray[10];
|
||||
|
||||
drive->setMaxVelocity(600);
|
||||
|
||||
// while (!is_held(imuholdarray, (abs(100.0 - IMU.get_rotation()) < 1))) {
|
||||
// drive->getModel()->rotate((100.0 - IMU.get_rotation()) * 0.008);
|
||||
// pros::delay(10);
|
||||
// }
|
||||
|
||||
drive->turnAngle(100_deg);
|
||||
|
||||
drive->getModel()->stop();
|
||||
|
||||
funnypiston.set_value(false);
|
||||
|
||||
drive->moveDistanceAsync(2_ft);
|
||||
|
||||
pros::delay(1000);
|
||||
|
||||
drive->moveDistance(-1_ft);
|
||||
|
||||
while (!is_held(imuholdarray, (abs(-110.0 - IMU.get_rotation()) < 3))) {
|
||||
drive->getModel()->rotate((-110.0 - IMU.get_rotation()) * 0.008);
|
||||
pros::delay(10);
|
||||
}
|
||||
|
||||
drive->getModel()->stop();
|
||||
while (distforward.get() > 300) {
|
||||
drive->getModel()->curvature(12000, (IMU.get_rotation()+110) * -0.04);
|
||||
|
||||
// printf("%i\n", distforward.get());
|
||||
pros::delay(10);
|
||||
}
|
||||
drive->stop();
|
||||
funnypiston.set_value(true);
|
||||
pros::delay(500);
|
||||
|
||||
drive->moveDistance(-1_ft);
|
||||
|
||||
while (!is_held(imuholdarray, (abs(75.0 - IMU.get_rotation()) < 3))) {
|
||||
drive->getModel()->rotate((75.0 - IMU.get_rotation()) * 0.008);
|
||||
pros::delay(10);
|
||||
}
|
||||
|
||||
drive->getModel()->stop();
|
||||
|
||||
funnypiston.set_value(false);
|
||||
|
||||
drive->moveDistanceAsync(3_ft);
|
||||
|
||||
pros::delay(1000);
|
||||
|
||||
drive->moveDistance(-1_ft);
|
||||
|
||||
while (!is_held(imuholdarray, (abs(-70.0 - IMU.get_rotation()) < 3))) {
|
||||
drive->getModel()->rotate((-70.0 - IMU.get_rotation()) * 0.008);
|
||||
pros::delay(10);
|
||||
}
|
||||
|
||||
drive->getModel()->stop();
|
||||
|
||||
drive->moveDistance(1_ft);
|
||||
|
||||
funnypiston.set_value(true);
|
||||
pros::delay(300);
|
||||
|
||||
drive->turnAngle(180_deg);
|
||||
funnypiston.set_value(false);
|
||||
|
||||
drive->moveDistanceAsync(3_ft);
|
||||
pros::delay(1000);
|
||||
drive->moveDistanceAsync(-1_ft);
|
||||
|
||||
// piston.set_value(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -694,6 +851,31 @@ void opcontrol() {
|
|||
bool intakebool;
|
||||
intakebool = false;
|
||||
|
||||
lv_fs_drv_t pcfs_drv; /*A driver descriptor*/
|
||||
memset(&pcfs_drv, 0, sizeof(lv_fs_drv_t)); /*Initialization*/
|
||||
|
||||
pcfs_drv.file_size = sizeof(pc_file_t); /*Set up fields...*/
|
||||
pcfs_drv.letter = 'S';
|
||||
pcfs_drv.open = pcfs_open;
|
||||
pcfs_drv.close = pcfs_close;
|
||||
pcfs_drv.read = pcfs_read;
|
||||
pcfs_drv.seek = pcfs_seek;
|
||||
pcfs_drv.tell = pcfs_tell;
|
||||
lv_fs_add_drv(&pcfs_drv);
|
||||
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
lv_obj_t *img_var = lv_img_create(lv_scr_act(), NULL);
|
||||
lv_obj_t *dog_var = lv_img_create(lv_scr_act(), NULL);
|
||||
lv_img_set_src(img_var, "S:/usd/raa.bin");
|
||||
|
||||
lv_obj_set_pos(img_var, 200, 0);
|
||||
lv_obj_set_size(img_var, 200, 200);
|
||||
|
||||
lv_img_set_src(dog_var, "S:/usd/dog2.bin");
|
||||
lv_obj_set_pos(dog_var, 200, 0);
|
||||
lv_obj_set_size(dog_var, 200, 200);
|
||||
|
||||
while (true) {
|
||||
// Tank drive with left and right sticks.
|
||||
drive->getModel()->tank(controller.getAnalog(ControllerAnalog::leftY),
|
||||
|
@ -753,6 +935,7 @@ void opcontrol() {
|
|||
|
||||
if (is_tapped(funnyarr, L2.isPressed())) {
|
||||
funnypistonstatus = !funnypistonstatus;
|
||||
lv_obj_set_hidden(dog_var, !funnypistonstatus);
|
||||
}
|
||||
|
||||
if (is_tapped(upflaparr, R2.isPressed())) {
|
||||
|
|
Loading…
Reference in a new issue