2
0
mirror of https://github.com/team2059/Dent synced 2024-12-18 20:52:29 -05:00
dent/Subsystems/Drivetrain.cpp

23 lines
816 B
C++
Raw Normal View History

2015-01-16 19:29:55 -05:00
#include "Drivetrain.h"
#include "../RobotMap.h"
2015-01-17 12:55:51 -05:00
#include "../Commands/Drive.h"
2015-01-16 19:29:55 -05:00
2015-01-17 12:21:16 -05:00
Drivetrain::Drivetrain() : Subsystem("Drivetrain"){
2015-01-19 12:08:25 -05:00
rightFront = new CANTalon(40);
leftFront = new CANTalon(41);
rightRear = new CANTalon(42);
leftRear = new CANTalon(43);
2015-01-16 19:29:55 -05:00
}
2015-01-17 12:21:16 -05:00
void Drivetrain::InitDefaultCommand(){
2015-01-17 12:55:51 -05:00
SetDefaultCommand(new Drive());
2015-01-16 19:29:55 -05:00
}
2015-01-19 12:08:25 -05:00
void Drivetrain::DriveMecanum(float x, float y, float z, float sensitivity, float gyro){
double correctY = (sensitivity*(pow(y,3))+(1-sensitivity)*y);
double correctX = -(sensitivity*(pow(x,3))+(1-sensitivity)*x);
double correctZ = -z *.5;
rightFront->Set((-correctX + correctY - correctZ));
leftFront->Set((correctX + correctY + correctZ)*-1);
rightRear->Set((correctX + correctY - correctZ));
leftRear->Set((-correctX + correctY + correctZ)*-1);
2015-01-17 10:34:08 -05:00
}