Made a new pneumatics class and implemented it in driver control, also made a few different classes for the rotation sensors. Got all the rotation classes implemented with connection to the physical rotation sensors and the motors. Added another controller to be implemented later.
This commit is contained in:
1 parent
bd0e77e240
commit
b7af93220d
14 files changed
+452
-101
No files matched your search
@@ -22,9 +22,6 @@ namespace ez {
|
||||
class color_sorter {
|
||||
public:
|
||||
|
||||
|
||||
color_sorter();
|
||||
|
||||
/**
|
||||
*
|
||||
* \param sensorNum
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include "api.h"
|
||||
#include "pros/adi.hpp"
|
||||
#include "pros/serial.hpp"
|
||||
#include "EZ-Template/piston.hpp"
|
||||
|
||||
namespace ez {
|
||||
|
||||
enum class Pistons {
|
||||
claw_piston
|
||||
};
|
||||
enum class ControlPeriod {
|
||||
driver,
|
||||
auton
|
||||
};
|
||||
enum class Controller {
|
||||
master,
|
||||
slave
|
||||
};
|
||||
enum class Buttons {
|
||||
arrow_buttons,
|
||||
Y_B_buttons,
|
||||
left_shoulder_buttons,
|
||||
right_shoulder_buttons
|
||||
};
|
||||
|
||||
class Pneumatics{
|
||||
|
||||
private:
|
||||
bool pistonState;
|
||||
|
||||
public:
|
||||
|
||||
Pneumatics();
|
||||
|
||||
void control_piston(enum Pistons, enum ControlPeriod, enum Controller, enum Buttons);
|
||||
|
||||
bool get_piston_state();
|
||||
void set_piston_state(bool value);
|
||||
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,80 @@
|
||||
#pragma once
|
||||
|
||||
#include "api.h"
|
||||
#include "pros/adi.hpp"
|
||||
#include "pros/rotation.hpp"
|
||||
|
||||
namespace ez{
|
||||
|
||||
class ArmMech{
|
||||
private:
|
||||
std::vector<int> armStates;
|
||||
int numArmStates;
|
||||
float armKP;
|
||||
|
||||
public:
|
||||
int currArmState;
|
||||
int armTarget;
|
||||
float armError;
|
||||
float armVelocity;
|
||||
|
||||
ArmMech();
|
||||
ArmMech(std::initializer_list<int> armStates, int numArmStates);
|
||||
|
||||
void cycle_states();
|
||||
void reset_state();
|
||||
void arm_control();
|
||||
|
||||
int get_arm_state();
|
||||
int get_num_arm_states();
|
||||
int get_arm_kp();
|
||||
};
|
||||
|
||||
class LiftMech {
|
||||
private:
|
||||
std::vector<int> liftStates;
|
||||
int numLiftStates;
|
||||
float liftKP;
|
||||
|
||||
public:
|
||||
int currLiftState;
|
||||
int liftTarget;
|
||||
float liftError;
|
||||
float liftVelocity;
|
||||
|
||||
LiftMech();
|
||||
LiftMech(std::initializer_list<int> liftStates, int numLiftStates);
|
||||
|
||||
void cycle_states();
|
||||
void reset_state();
|
||||
void lift_control();
|
||||
|
||||
int get_lift_state();
|
||||
int get_num_lift_states();
|
||||
int get_lift_kp();
|
||||
};
|
||||
|
||||
class WristMech {
|
||||
private:
|
||||
std::vector<int> wristStates;
|
||||
int numWristStates;
|
||||
float wristKP;
|
||||
|
||||
public:
|
||||
int currWristState;
|
||||
int wristTarget;
|
||||
float wristError;
|
||||
float wristVelocity;
|
||||
|
||||
WristMech();
|
||||
WristMech(std::initializer_list<int> wristStates, int numWristStates);
|
||||
|
||||
void cycle_states();
|
||||
void reset_state();
|
||||
void wrist_control();
|
||||
|
||||
int get_wrist_state();
|
||||
int get_num_wrist_states();
|
||||
int get_wrist_kp();
|
||||
};
|
||||
};
|
||||
@@ -18,11 +18,6 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
using namespace okapi::literals;
|
||||
|
||||
/**
|
||||
* Controller.
|
||||
*/
|
||||
extern pros::Controller master;
|
||||
|
||||
namespace ez {
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,22 @@
|
||||
|
||||
void default_constants();
|
||||
|
||||
/**
|
||||
* Personal auton routes
|
||||
*/
|
||||
void leftMain(std::string side);
|
||||
void rightMain(std::string side);
|
||||
void Skills();
|
||||
void BlueRight();
|
||||
void BlueLeft();
|
||||
void RedRight();
|
||||
void RedLeft();
|
||||
void testMain(std::string side);
|
||||
void Test();
|
||||
|
||||
/**
|
||||
* Template auton routes
|
||||
*/
|
||||
void drive_example();
|
||||
void turn_example();
|
||||
void drive_and_turn();
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
// More includes here...
|
||||
#include "autons.hpp"
|
||||
#include "subsystems.hpp"
|
||||
#include "EZ-Template/rotation_mechanisms/rotation_calc.hpp"
|
||||
#include "EZ-Template/pneumatics.hpp"
|
||||
|
||||
/**
|
||||
* If you find doing pros::Motor() to be tedious and you'd prefer just to do
|
||||
|
||||
@@ -7,73 +7,32 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
extern bool gotRed;
|
||||
extern bool gotBlue;
|
||||
extern double currentColor;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
inline pros::Controller master;
|
||||
inline pros::Controller slave;
|
||||
|
||||
extern Drive chassis;
|
||||
/**
|
||||
* Declare mechinism motors
|
||||
*/
|
||||
inline pros::MotorGroup lift({10, 11});
|
||||
inline pros::MotorGroup wrist({13, 14});
|
||||
inline pros::Motor arm({12});
|
||||
|
||||
// Declares the left side motors
|
||||
extern pros::Motor FrontLeft;
|
||||
extern pros::Motor MiddleLeft;
|
||||
extern pros::Motor BackLeft;
|
||||
/**
|
||||
* Declare pistons here
|
||||
*/
|
||||
inline ez::Piston claw({'A',true});
|
||||
|
||||
// Declares the right side motors
|
||||
extern pros::Motor FrontRight;
|
||||
extern pros::Motor MiddleRight;
|
||||
extern pros::Motor BackRight;
|
||||
/**
|
||||
* Declare sensors here
|
||||
*/
|
||||
inline pros::Rotation liftRotation({15});
|
||||
inline pros::Rotation armRotation({16});
|
||||
inline pros::Rotation wristRotatio({17});
|
||||
|
||||
// Declares the left and right drive motor groups.
|
||||
extern pros::MotorGroup RightSide;
|
||||
extern pros::MotorGroup LeftSide;
|
||||
|
||||
// Declares all the drive motors as a group.
|
||||
extern pros::MotorGroup FullDrive;
|
||||
|
||||
// Declaring the Intake motors.
|
||||
inline pros::Motor stage1({14});
|
||||
inline pros::Motor stage2({16});
|
||||
inline pros::Motor stage3({12});
|
||||
|
||||
//
|
||||
inline ez::Piston ramp({'H',true});
|
||||
|
||||
// Declaring the piston used to guide the balls into the basket.
|
||||
inline ez::Piston deScorer({'G',false});
|
||||
|
||||
// Declaring the piston used to get the balls out of the tube.
|
||||
inline ez::Piston matchLoader({'F',false});
|
||||
|
||||
//
|
||||
inline pros::Optical colorSensorOne({20});
|
||||
inline pros::Optical colorSensorTwo({11});
|
||||
inline pros::Optical colorSensorThree({18});
|
||||
|
||||
//
|
||||
inline pros::Distance frontDistance({5});
|
||||
|
||||
//inline pros::MotorGroup fillingGroup({20, 17, 18});
|
||||
//inline pros::MotorGroup scoringGroup({20, 17, 18, 19});
|
||||
|
||||
// Function used for the Intake control
|
||||
void IntakePresets();
|
||||
void ToggleButtons();
|
||||
|
||||
// Function used for the color sorter
|
||||
void ColorDisplay();
|
||||
void CheckRed(std::string Sensor, std::string controlPeriod, bool loop);
|
||||
void CheckBlue(std::string Sensor, std::string controlPeriod, bool loop);
|
||||
void ColorDetection(std::string wantedColor, bool checkForColor);
|
||||
|
||||
// Auton voids
|
||||
void leftMain(std::string side);
|
||||
void rightMain(std::string side);
|
||||
void Skills();
|
||||
void BlueRight();
|
||||
void BlueLeft();
|
||||
void RedRight();
|
||||
void RedLeft();
|
||||
void testMain(std::string side);
|
||||
void Test();
|
||||
inline pros::Optical colorSensorOne({18});
|
||||
inline pros::Optical colorSensorTwo({19});
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user