First I changed the names for the mechanisms to match the current robot setup. I then made a new header file for the mechansims and a new cpp file for the mechanisms. The mechanisms now work the same way a piston works by allowing you to call the functions and input all the different variables inline. I also had to comment out all the old rotation code because of the changed names and not actually useing them, for now i'm just going to keep all the code where it is so I can look back on it for the future.
This commit is contained in:
1 parent
24ee947fd5
commit
94f88d09d6
11 files changed
+370
-84
No files matched your search
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include "api.h"
|
||||
#include "pros/adi.hpp"
|
||||
#include "pros/motors.hpp"
|
||||
#include "pros/motor_group.hpp"
|
||||
|
||||
namespace ez {
|
||||
|
||||
enum class ControlPeriodM {
|
||||
driver,
|
||||
auton
|
||||
};
|
||||
|
||||
enum class ControllerM {
|
||||
master,
|
||||
slave
|
||||
};
|
||||
|
||||
enum class ButtonsM {
|
||||
arrow_buttons,
|
||||
Y_B_buttons,
|
||||
left_shoulder_buttons,
|
||||
right_shoulder_buttons
|
||||
};
|
||||
|
||||
enum class MotorGroups {
|
||||
lift_MG,
|
||||
claw_M,
|
||||
roller_M
|
||||
};
|
||||
|
||||
class Mechanisms {
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
float fw_motor_speed = 0;
|
||||
float rev_motor_speed = 0;
|
||||
|
||||
Mechanisms();
|
||||
|
||||
void motor_control(enum ControlPeriodM, enum ControllerM, enum ButtonsM, enum MotorGroups, float fw_motor_speed, float rev_motor_speed);
|
||||
|
||||
float get_motor_speed();
|
||||
float set_motor_speed(float value);
|
||||
|
||||
};
|
||||
};
|
||||
@@ -33,7 +33,7 @@ namespace ez {
|
||||
* Enumeration to hold all the pistons avalable.
|
||||
*/
|
||||
enum class PistonsP {
|
||||
claw_piston
|
||||
PlaceHolderP
|
||||
};
|
||||
|
||||
class Pneumatics{
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace ez{
|
||||
void arm_auton_control(int pickState);
|
||||
void cycle_states();
|
||||
void reset_state();
|
||||
void hard_reset_arm(); // Once the arm hits a button the rotation sensor value is reset to 0
|
||||
void arm_control(); // Computes the velocity for the arm to move at.
|
||||
|
||||
void set_arm_kp(float _armKP);
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "autons.hpp"
|
||||
#include "subsystems.hpp"
|
||||
#include "EZ-Template/rotation_mechanisms/rotation_calc.hpp"
|
||||
#include "EZ-Template/mechanisms.hpp"
|
||||
#include "EZ-Template/pneumatics.hpp"
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,20 +16,20 @@ inline pros::Controller slave(pros::E_CONTROLLER_PARTNER);
|
||||
/**
|
||||
* Declares mechinism motors and motor groups.
|
||||
*/
|
||||
inline pros::MotorGroup lift({15, -19});
|
||||
inline pros::MotorGroup wrist({1, 9});
|
||||
inline pros::Motor arm({6});
|
||||
inline pros::MotorGroup lift({-1, 2});
|
||||
inline pros::Motor claw({9});
|
||||
inline pros::Motor roller({5});
|
||||
|
||||
/**
|
||||
* Declares piston mechanisms.
|
||||
*/
|
||||
inline ez::Piston claw({'G',true});
|
||||
inline ez::Piston PlaceHolder({'G',true});
|
||||
|
||||
/**
|
||||
* Declare limit switches and other ADI sensors
|
||||
*/
|
||||
inline pros::ADIButton liftReset({'A'});
|
||||
inline pros::ADIButton armReset({'B'});
|
||||
//inline pros::ADIDigitalIn liftReset ('A');
|
||||
//inline pros::ADIDigitalIn armReset('B');
|
||||
|
||||
/**
|
||||
* Declares all sensors.
|
||||
@@ -38,11 +38,11 @@ inline pros::ADIButton armReset({'B'});
|
||||
*
|
||||
* [2] - Color sensors
|
||||
*/
|
||||
inline pros::Rotation liftRotation({17});
|
||||
inline pros::Rotation armRotation({8});
|
||||
inline pros::Rotation wristRotation({21});
|
||||
inline pros::Rotation liftRotation({0});
|
||||
inline pros::Rotation armRotation({0});
|
||||
inline pros::Rotation wristRotation({0});
|
||||
|
||||
inline pros::Optical colorSensorOne({18});
|
||||
inline pros::Optical colorSensorTwo({19});
|
||||
inline pros::Optical colorSensorOne({0});
|
||||
inline pros::Optical colorSensorTwo({0});
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user