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

47 lines
1.4 KiB
C++
Raw Normal View History

2015-01-16 19:29:55 -05:00
#include "Drivetrain.h"
#include "../RobotMap.h"
#include "../Commands/Drivetrain/Drive.h"
2015-01-16 19:29:55 -05:00
2015-01-17 12:21:16 -05:00
Drivetrain::Drivetrain() : Subsystem("Drivetrain"){
2015-02-02 19:56:27 -05:00
rightFront = new CANTalon(DRIVE_FRONT_RIGHT_CAN);
leftFront = new CANTalon(DRIVE_FRONT_LEFT_CAN);
rightRear = new CANTalon(DRIVE_BACK_RIGHT_CAN);
leftRear = new CANTalon(DRIVE_BACK_LEFT_CAN);
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 correctX = -(sensitivity*(pow(x, 3))+(1-sensitivity)*x);
2015-02-27 16:42:11 -05:00
double correctY = -(sensitivity*(pow(y, 3))+(1-sensitivity)*y);
double correctZ = -z * 0.5;
2015-02-28 03:13:26 -05:00
if (DentRobot::oi->GetLeftStick()->GetRawButton(9)){
correctY /= SmartDashboard::GetNumber("DriveSpeedReductionThresh");
}
2015-02-02 19:56:27 -05:00
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
}
2015-02-07 09:17:20 -05:00
//Used in pretest
void Drivetrain::TestMotor(e_motors motor, float power){
switch(motor){
case FRONTRIGHT:
rightFront->Set(power);
break;
case FRONTLEFT:
leftFront->Set(power);
break;
case BACKRIGHT:
rightRear->Set(power);
break;
case BACKLEFT:
leftRear->Set(power);
break;
default:
break;
}
}
2015-02-08 12:26:15 -05:00
// vim: ts=2:sw=2:et