Skip to content

Commit

Permalink
Commented out non-drivetrain motors
Browse files Browse the repository at this point in the history
still doesn't work
  • Loading branch information
x64-bit committed May 4, 2021
1 parent 7790b80 commit 4de4d89
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 29 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2021.1.2"
id "edu.wpi.first.GradleRIO" version "2021.3.1"
}

sourceCompatibility = JavaVersion.VERSION_11
Expand Down Expand Up @@ -38,7 +38,7 @@ deploy {
}

// Set this to true to enable desktop support.
def includeDesktopSupport = false
def includeDesktopSupport = true

// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
// Also defines JUnit 4.
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,12 @@ public Command getAutonomousCommand() {
config.setKinematics(drivetrain.getKinematics());

Trajectory trajectory = TrajectoryGenerator.generateTrajectory(
Arrays.asList(new Pose2d(), new Pose2d(1.0, 0, new Rotation2d())),
Arrays.asList(new Pose2d(),
new Pose2d(0, 1.0, new Rotation2d(0)),
new Pose2d(0, 1.0, new Rotation2d(90)),
new Pose2d(1.0, 1.0, new Rotation2d(90))),
config);

RamseteCommand command = new RamseteCommand(
trajectory,
drivetrain::getPose,
Expand Down
1 change: 0 additions & 1 deletion src/main/java/frc/robot/commands/ArcadeDrive.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public void initialize() {
@Override
public void execute() {
dt.driveWithJoysticks(RobotContainer.controller);
System.out.print("Drive");
}

// Called once the command ends or is interrupted.
Expand Down
1 change: 0 additions & 1 deletion src/main/java/frc/robot/commands/Roll.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public void initialize() {
@Override
public void execute() {
succRoller.intake(RobotContainer.controller);
System.out.print("Execute");
}

// Called once the command ends or is interrupted.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/subsystems/Arm.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import frc.robot.Constants;

public class Arm extends SubsystemBase {
TalonSRX armMotor = new TalonSRX(Constants.MOTOR_ARM_ID);
// TalonSRX armMotor = new TalonSRX(Constants.MOTOR_ARM_ID);
/**
* Creates a new Arm.
*/
Expand All @@ -24,7 +24,7 @@ public Arm() {
}

public void turn(XboxController controller) {
armMotor.set(ControlMode.PercentOutput, controller.getRawAxis(Constants.JOYSTICK_ARM_CONTROL_ID));
// armMotor.set(ControlMode.PercentOutput, controller.getRawAxis(Constants.JOYSTICK_ARM_CONTROL_ID));
}

@Override
Expand Down
31 changes: 16 additions & 15 deletions src/main/java/frc/robot/subsystems/Drivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,28 +77,29 @@ public class Drivetrain extends SubsystemBase {
DifferentialDriveOdometry odometry = new DifferentialDriveOdometry(getHeading());

// Feedforward controller for Ramsete
SimpleMotorFeedforward feedforward = new SimpleMotorFeedforward(0.4, 1, 0.4);
SimpleMotorFeedforward feedforward = new SimpleMotorFeedforward(0.137, 3.24, 0.592);

// how robot turn wheel
PIDController leftPIDController = new PIDController(0.1,0.0,0.05);
PIDController rightPIDController = new PIDController(0.1,0.0,0.05);
PIDController leftPIDController = new PIDController(2.21,0.0,0.0);
PIDController rightPIDController = new PIDController(2.21,0.0,0.0);

Pose2d pose;

DifferentialDrive drive = new DifferentialDrive(leftMotor, rightMotor);

//Create drivetrain simulation
static final double KvLinear = 0;
static final double KaLinear = 0;
static final double KvAngular = 0;
static final double KaAngular = 0;
static final double KvLinear = 3.24;
static final double KaLinear = 0.592;
static final double KvAngular = 1.5;
static final double KaAngular = 0.3;
static final double trackWidthMeters = 0.51;

private DifferentialDrivetrainSim m_driveSim = new DifferentialDrivetrainSim(
LinearSystemId.identifyDrivetrainSystem(KvLinear, KaLinear, KvAngular, KaAngular),
DCMotor.getNEO(2),
0.025,
10.75,
Units.inchesToMeters(3),
10.75,
0.509,
Units.inchesToMeters(3),

// The standard deviations for measurement noise:
// x and y: 0.001 m
Expand Down Expand Up @@ -132,13 +133,13 @@ public void simulationPeriodic(){

// subsystem in a separate thread or have changed the nominal timestep
// of TimedRobot, this value needs to match it.
m_driveSim.update(0.02);
m_driveSim.update(0.07);

//Update sensors
leftPos.set(m_driveSim.getLeftPositionMeters());
leftVel.set(m_driveSim.getLeftVelocityMetersPerSecond());
rightPos.set(m_driveSim.getRightPositionMeters());
rightVel.set(m_driveSim.getRightVelocityMetersPerSecond());
simEncoderLeft.getDouble("Position").set(m_driveSim.getLeftPositionMeters());
simEncoderLeft.getDouble("Velocity").set(m_driveSim.getLeftVelocityMetersPerSecond());
simEncoderRight.getDouble("Position").set(m_driveSim.getRightPositionMeters());
simEncoderRight.getDouble("Velocity").set(m_driveSim.getRightVelocityMetersPerSecond());
//Update gyro
simAngle.set(-m_driveSim.getHeading().getDegrees());
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/subsystems/Roller.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


public class Roller extends SubsystemBase {
VictorSPX rollerMotor = new VictorSPX(Constants.MOTOR_ROLLER_ID);
// VictorSPX rollerMotor = new VictorSPX(Constants.MOTOR_ROLLER_ID);
/**
* Creates a new Roller.
*/
Expand All @@ -37,7 +37,7 @@ public void intake(XboxController controller) {
*/
double intake = controller.getRawAxis(Constants.JOYSTICK_INTAKE_ID);
double output = controller.getRawAxis(Constants.JOYSTICK_OUTPUT_ID);
rollerMotor.set(ControlMode.PercentOutput, intake - output);
// rollerMotor.set(ControlMode.PercentOutput, intake - output);
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/frc/robot/subsystems/Winch.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

package frc.robot.subsystems;

import com.ctre.phoenix.motorcontrol.can.TalonSRX;
// import com.ctre.phoenix.motorcontrol.can.TalonSRX;
import com.ctre.phoenix.motorcontrol.ControlMode;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;
Expand All @@ -16,14 +16,14 @@ public class Winch extends SubsystemBase {
/**
* Creates a new Winch.
*/
TalonSRX winchMotor = new TalonSRX(Constants.MOTOR_CLIMB_WINCH_ID);
// TalonSRX winchMotor = new TalonSRX(Constants.MOTOR_CLIMB_WINCH_ID);

public void winchUp() {
winchMotor.set(ControlMode.PercentOutput, 1.0);
// winchMotor.set(ControlMode.PercentOutput, 1.0);
}

public void winchDown() {
winchMotor.set(ControlMode.PercentOutput, -1.0);
// winchMotor.set(ControlMode.PercentOutput, -1.0);
}

@Override
Expand Down

0 comments on commit 4de4d89

Please sign in to comment.