mirror of
https://github.com/team2059/Dent
synced 2025-01-07 22:14:14 -05:00
Fixed the driving
This commit is contained in:
parent
213464dd64
commit
d61da0b436
@ -7,17 +7,22 @@ Drive::Drive() : Command("Drive"){
|
|||||||
void Drive::Initialize(){
|
void Drive::Initialize(){
|
||||||
}
|
}
|
||||||
void Drive::Execute(){
|
void Drive::Execute(){
|
||||||
static float sens=0.7;
|
double x,y,z;
|
||||||
float x, y, twist;
|
//Code to lock the x axis when not holding button 1
|
||||||
x=DentRobot::oi->GetLeftStick()->GetRawAxis(0);
|
if (DentRobot::oi->GetLeftStick()->GetRawButton(1)){
|
||||||
y=DentRobot::oi->GetLeftStick()->GetRawAxis(1);
|
x = DentRobot::oi->GetLeftStick()->GetRawAxis(0);
|
||||||
twist=DentRobot::oi->GetLeftStick()->GetRawAxis(2);
|
x /= 1.3;
|
||||||
if(true){
|
}else{
|
||||||
x=sens*std::pow(x, 3)+(1.0f-sens)*x;
|
x = 0;
|
||||||
y=sens*std::pow(y, 3)+(1.0f-sens)*y;
|
|
||||||
}
|
}
|
||||||
//DentRobot::drivetrain->DriveMecanum(DentRobot::oi->GetLeftStick()->GetRawAxis(2), DentRobot::oi->GetLeftStick()->GetRawAxis(1), DentRobot::oi->GetLeftStick()->GetRawAxis(0));
|
z = DentRobot::oi->GetLeftStick()->GetRawAxis(2);
|
||||||
DentRobot::drivetrain->DriveMecanum(x, y, twist);
|
y = DentRobot::oi->GetLeftStick()->GetRawAxis(1);
|
||||||
|
if (DentRobot::oi->GetLeftStick()->GetRawAxis(3)<=0.5){
|
||||||
|
y /= 2;
|
||||||
|
z /= 2;
|
||||||
|
}
|
||||||
|
//X axis, Y axis, Z axis, sensitivity, speed threshold (usually throttle), gyro
|
||||||
|
DentRobot::drivetrain->DriveMecanum(x,y,z,0.9,0);
|
||||||
}
|
}
|
||||||
bool Drive::IsFinished(){
|
bool Drive::IsFinished(){
|
||||||
return false;
|
return false;
|
||||||
|
@ -3,18 +3,21 @@
|
|||||||
#include "../Commands/Drive.h"
|
#include "../Commands/Drive.h"
|
||||||
|
|
||||||
Drivetrain::Drivetrain() : Subsystem("Drivetrain"){
|
Drivetrain::Drivetrain() : Subsystem("Drivetrain"){
|
||||||
frontLeft=new CANTalon(40);
|
rightFront = new CANTalon(40);
|
||||||
frontRight=new CANTalon(41);
|
leftFront = new CANTalon(41);
|
||||||
backLeft=new CANTalon(42);
|
rightRear = new CANTalon(42);
|
||||||
backRight=new CANTalon(43);
|
leftRear = new CANTalon(43);
|
||||||
drive=new RobotDrive(frontLeft, frontRight, backLeft, backRight);
|
|
||||||
}
|
}
|
||||||
void Drivetrain::InitDefaultCommand(){
|
void Drivetrain::InitDefaultCommand(){
|
||||||
SetDefaultCommand(new Drive());
|
SetDefaultCommand(new Drive());
|
||||||
}
|
}
|
||||||
void Drivetrain::DriveMecanum(float x, float y, float rotation){
|
void Drivetrain::DriveMecanum(float x, float y, float z, float sensitivity, float gyro){
|
||||||
drive->MecanumDrive_Cartesian(x, y, rotation);
|
double correctY = (sensitivity*(pow(y,3))+(1-sensitivity)*y);
|
||||||
}
|
double correctX = -(sensitivity*(pow(x,3))+(1-sensitivity)*x);
|
||||||
void Drivetrain::DriveArcade(float x, float y){
|
double correctZ = -z *.5;
|
||||||
drive->ArcadeDrive(x, y);
|
double slowfactor = 2.5;
|
||||||
|
rightFront->Set((-correctX + correctY - correctZ));
|
||||||
|
leftFront->Set((correctX + correctY + correctZ)*-1);
|
||||||
|
rightRear->Set((correctX + correctY - correctZ));
|
||||||
|
leftRear->Set((-correctX + correctY + correctZ)*-1);
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
class Drivetrain: public Subsystem
|
class Drivetrain: public Subsystem
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
CANTalon *frontLeft, *frontRight, *backLeft, *backRight;
|
CANTalon *rightFront, *leftFront, *rightRear, *leftRear;
|
||||||
RobotDrive *drive;
|
RobotDrive *drive;
|
||||||
public:
|
public:
|
||||||
Drivetrain();
|
Drivetrain();
|
||||||
void InitDefaultCommand();
|
void InitDefaultCommand();
|
||||||
void DriveMecanum(float, float, float);
|
void DriveMecanum(float,float,float,float,float);
|
||||||
void DriveArcade(float, float);
|
void DriveArcade(float, float);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "Elevator.h"
|
#include "Elevator.h"
|
||||||
#include "../RobotMap.h"
|
#include "../RobotMap.h"
|
||||||
Elevator::Elevator() : PIDSubsystem("Elevator", kP_real, kI_real, 0.0){
|
Elevator::Elevator()/* : PIDSubsystem("Elevator", kP_real, kI_real, 0.0)*/{
|
||||||
pot=new AnalogPotentiometer(0);
|
pot=new AnalogPotentiometer(0);
|
||||||
leftMotor=new Talon(1);
|
leftMotor=new Talon(1);
|
||||||
rightMotor=new Talon(0);
|
rightMotor=new Talon(0);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "WPILib.h"
|
#include "WPILib.h"
|
||||||
#include "Commands/PIDSubsystem.h"
|
#include "Commands/PIDSubsystem.h"
|
||||||
class Elevator: public PIDSubsystem{
|
class Elevator/*: public PIDSubsystem*/{
|
||||||
private:
|
private:
|
||||||
AnalogPotentiometer *pot;
|
AnalogPotentiometer *pot;
|
||||||
Talon *leftMotor, *rightMotor;
|
Talon *leftMotor, *rightMotor;
|
||||||
|
1
src/hhlib
Submodule
1
src/hhlib
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 181fb1556d4cc96daa430bfce0fb6ce26c7c90c9
|
Loading…
x
Reference in New Issue
Block a user