horrible code
thisi s bad and terrible and bad code, do not use this literally whoever wrote this does not deserve to live
This commit is contained in:
parent
a5a650ca4b
commit
f6062ce58e
@ -3,5 +3,17 @@
|
||||
#include "lemlib/api.hpp"
|
||||
|
||||
namespace globals {
|
||||
extern Controller controller;
|
||||
extern std::shared_ptr<okapi::Controller> controller;
|
||||
|
||||
extern okapi::Motor motor_fl;
|
||||
extern okapi::Motor motor_ml;
|
||||
extern okapi::Motor motor_bl;
|
||||
extern okapi::Motor motor_fr;
|
||||
extern okapi::Motor motor_mr;
|
||||
extern okapi::Motor motor_br;
|
||||
|
||||
extern std::shared_ptr<okapi::MotorGroup> leftDrive;
|
||||
extern std::shared_ptr<okapi::MotorGroup> rightDrive;
|
||||
|
||||
extern std::shared_ptr<okapi::ChassisController> chassis;
|
||||
}
|
||||
@ -1,9 +1,29 @@
|
||||
#include "globals.hpp"
|
||||
|
||||
namespace globals {
|
||||
Controller controller(ControllerId::master);
|
||||
std::shared_ptr<okapi::Controller> controller(new Controller(ControllerId::master));
|
||||
|
||||
// Chassis
|
||||
okapi::Motor motor_fl(1, false, AbstractMotor::gearset::blue, AbstractMotor::encoderUnits::degrees);
|
||||
okapi::Motor motor_ml(2, false, AbstractMotor::gearset::blue, AbstractMotor::encoderUnits::degrees);
|
||||
okapi::Motor motor_bl(3, false, AbstractMotor::gearset::blue, AbstractMotor::encoderUnits::degrees);
|
||||
okapi::Motor motor_fr(4, true, AbstractMotor::gearset::blue, AbstractMotor::encoderUnits::degrees);
|
||||
okapi::Motor motor_mr(5, true, AbstractMotor::gearset::blue, AbstractMotor::encoderUnits::degrees);
|
||||
okapi::Motor motor_br(6, true, AbstractMotor::gearset::blue, AbstractMotor::encoderUnits::degrees);
|
||||
|
||||
std::shared_ptr<okapi::MotorGroup> left_drive(new MotorGroup({motor_fl, motor_ml, motor_bl}));
|
||||
std::shared_ptr<okapi::MotorGroup> right_drive(new MotorGroup({motor_fr, motor_mr, motor_br}));
|
||||
|
||||
std::shared_ptr<okapi::ChassisController> chassis =
|
||||
ChassisControllerBuilder()
|
||||
.withMotors(left_drive, right_drive)
|
||||
.withDimensions({AbstractMotor::gearset::blue, 1.5}, {{3.25_in, 28_cm}, 300 * 1.5})
|
||||
.withGains(
|
||||
{0.45, 0, 5},
|
||||
{11, 0, 20},
|
||||
{0.001, 0, 0.0001}
|
||||
)
|
||||
.build();
|
||||
|
||||
// Electronics / Pneumatics / Sensors
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
#include "main.h"
|
||||
#include "lemlib/api.hpp"
|
||||
#include "globals.hpp"
|
||||
|
||||
using namespace globals;
|
||||
|
||||
/**
|
||||
* A callback function for LLEMU's center button.
|
||||
@ -75,19 +78,10 @@ void autonomous() {}
|
||||
* task, not resume it from where it left off.
|
||||
*/
|
||||
void opcontrol() {
|
||||
pros::Controller master(pros::E_CONTROLLER_MASTER);
|
||||
pros::Motor left_mtr(1);
|
||||
pros::Motor right_mtr(2);
|
||||
|
||||
while (true) {
|
||||
pros::lcd::print(0, "%d %d %d", (pros::lcd::read_buttons() & LCD_BTN_LEFT) >> 2,
|
||||
(pros::lcd::read_buttons() & LCD_BTN_CENTER) >> 1,
|
||||
(pros::lcd::read_buttons() & LCD_BTN_RIGHT) >> 0);
|
||||
int left = master.get_analog(ANALOG_LEFT_Y);
|
||||
int right = master.get_analog(ANALOG_RIGHT_Y);
|
||||
|
||||
left_mtr = left;
|
||||
right_mtr = right;
|
||||
double leftX = globals::controller->getAnalog(ControllerAnalog::leftX);
|
||||
double leftY = globals::controller->getAnalog(ControllerAnalog::leftY);
|
||||
|
||||
pros::delay(20);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user