Skip to content

Commit

Permalink
Made work with general purpose code
Browse files Browse the repository at this point in the history
  • Loading branch information
stebb1976 committed Mar 6, 2021
1 parent 107f423 commit 73a1a25
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 100 deletions.
7 changes: 3 additions & 4 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ public class Constants {
//Shooter
public static final int SHOOTER_LEFT_MASTER_ID = 1;
public static final int SHOOTER_RIGHT_SLAVE_ID = 1;
public static final int SHOOTER_KP = 0;
public static final int SHOOTER_KI = 0;
public static final int SHOOTER_KFF = 0;
public static final int SHOOTER_KD = 0;
public static final double SHOOTER_KS = 0;
public static final double SHOOTER_KV = 0;
public static final double SHOOTER_KA = 0;
public static final int SPIN_UP_RPM = 0;


Expand Down
29 changes: 0 additions & 29 deletions src/main/java/frc/robot/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,6 @@ Any new differential drive subsystems should implement this feature (view TalonS
New differential drive subsystems will need new code for motor creation, motor configuration, motor output, and PID configuration.
*/

/**
* TODO
*
* Make a shuffle board interface
*
* Make more differential drivetrain commands
* -arcade drive- done
*
* Make manipulator Subsystem
*
* Make a recording mode for the manipulator mover
* -test
*
*
* Add support for max velocity and acceleration for TalonSRX_Drivetrain
*
* Make a unity testing branch for github
*
* Make unity testing tools
* -make a dedicated utility class
*
* Make tests to ensure the code actually works on a robot
*
* Ramsete might spin because setting the voltage might be affected by the motor controller inversion setting
*
* test drivetrain commands to ensure everything is inverted properly
*
*/

package frc.robot;

import edu.wpi.first.wpilibj.RobotBase;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.commands.Shoot;
import frc.robot.subsystems.Kicker;
import frc.robot.subsystems.Shooter;
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/frc/robot/Utility/Motor.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ public void follow(Motor master){
follow(master, false);
}

/**
* If motor is a follower, then this does nothing.
* Set follower inversion from master when setting master.
* @param isInverted
*/
public void setInverted(boolean isInverted){
if (m_motorType == MotorType.TalonSRX) {
if(m_talonSRX.getControlMode() != com.ctre.phoenix.motorcontrol.ControlMode.Follower)
Expand All @@ -247,7 +252,8 @@ public void setInverted(boolean isInverted){
}

if (m_motorType == MotorType.CANSparkMax) {
m_canSparkMax.setInverted(isInverted);
if(!m_canSparkMax.isFollower())
m_canSparkMax.setInverted(isInverted);
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/frc/robot/subsystems/Feeder.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@

package frc.robot.subsystems;

import com.revrobotics.CANSparkMaxLowLevel.MotorType;

import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;
import frc.robot.Utility.Motor;

public class Feeder extends SubsystemBase {
Motor m_feederMotor = new Motor(Constants.FEEDER_MOTOR_ID, "CANSparkMax");
Motor m_serializerMotor = new Motor(Constants.SERIALIZER_MOTOR_ID, "CANSparkMax");
Motor m_feederMotor = new Motor(Constants.FEEDER_MOTOR_ID, Motor.MotorType.CANSparkMax);
Motor m_serializerMotor = new Motor(Constants.SERIALIZER_MOTOR_ID, Motor.MotorType.CANSparkMax);
/**
* Creates a new Feeder.
*/
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/frc/robot/subsystems/Kicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@

package frc.robot.subsystems;

//import com.ctre.phoenix.motorcontrol.InvertType;
import com.revrobotics.CANSparkMaxLowLevel.MotorType;

import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;
import frc.robot.Utility.Motor;

public class Kicker extends SubsystemBase {
Motor m_kickerMotor = new Motor(Constants.KICKER_MOTOR_ID, "CANSparkMax");
Motor m_kickerMotor = new Motor(Constants.KICKER_MOTOR_ID, Motor.MotorType.CANSparkMax);



Expand Down
65 changes: 7 additions & 58 deletions src/main/java/frc/robot/subsystems/Shooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,76 +7,25 @@

package frc.robot.subsystems;

import com.ctre.phoenix.motorcontrol.NeutralMode;

import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;
import frc.robot.Utility.Motor;

public class Shooter extends SubsystemBase {
Motor m_leftMaster = new Motor(Constants.SHOOTER_LEFT_MASTER_ID, "TalonFX");
Motor m_rightSlave = new Motor(Constants.SHOOTER_RIGHT_SLAVE_ID, "TalonFX");
Motor m_leftMaster = new Motor(Constants.SHOOTER_LEFT_MASTER_ID, Motor.MotorType.TalonFX);
Motor m_rightSlave = new Motor(Constants.SHOOTER_RIGHT_SLAVE_ID, Motor.MotorType.TalonFX);
/**
* Creates a new Shooter.
*/
public Shooter() {
/*
m_leftMaster.SetP_velocity(Constants.SHOOTER_KP);
m_leftMaster.SetFF_velocity(Constants.SHOOTER_KFF);
m_leftMaster.SetI_velocity(Constants.SHOOTER_KI);
m_leftMaster.SetD_velocity(Constants.SHOOTER_KD);
m_rightSlave.SetP_velocity(Constants.SHOOTER_KP);
m_rightSlave.SetFF_velocity(Constants.SHOOTER_KFF);
m_rightSlave.SetI_velocity(Constants.SHOOTER_KI);
m_rightSlave.SetD_velocity(Constants.SHOOTER_KD);
*/

//TODO configure shooter feedforward
m_leftMaster.configFeedforward(Constants.SHOOTER_KS, Constants.SHOOTER_KV, Constants.SHOOTER_KA);

// m_leftMaster.ConfigFactoryDefault();
// m_rightSlave.ConfigFactoryDefault();

m_rightSlave.follow(m_leftMaster, false);
m_rightSlave.follow(m_leftMaster, true);
m_leftMaster.setInverted(false);
m_rightSlave.setInverted(true);

/*
m_leftMaster.setNeutralMode(NeutralMode.Coast);
m_rightSlave.setNeutralMode(NeutralMode.Coast);
*/

// motorcontrol::SupplyCurrentLimitConfiguration supply_config_ {
// true, constants::shooter::kMaxCurrentDraw.to<double>(),
// constants::shooter::kMaxCurrentDraw.to<double>(),
// constants::shooter::kCurrentLimitingTriggerTime.to<double>()
// };

// m_leftMaster.ConfigIntegratedSensorInitializationStrategy(ctre::phoenix::sensors::SensorInitializationStrategy::BootToZero);
// m_leftMaster.ConfigSupplyCurrentLimit(supply_config_);
// m_rightSlave.ConfigIntegratedSensorInitializationStrategy(ctre::phoenix::sensors::SensorInitializationStrategy::BootToZero);
// m_rightSlave.ConfigSupplyCurrentLimit(supply_config_);

// m_leftMaster.ConfigOpenloopRamp(1.8);
// m_rightSlave.ConfigOpenloopRamp(1.8);

// m_leftMaster.ConfigClosedloopRamp(1.8);
// m_rightSlave.ConfigClosedloopRamp(1.8);

// m_leftMaster.Config_kP(0, constants::shooter::kP);
// m_leftMaster.Config_kI(0, 0);
// m_leftMaster.Config_kD(0, constants::shooter::kD);
// m_leftMaster.Config_kF(0, constants::shooter::kFF);
// m_leftMaster.Config_kF(0, 0.05);

// m_rightSlave.Config_kP(0, constants::shooter::kP);
// m_rightSlave.Config_kI(0, 0);
// m_rightSlave.Config_kD(0, constants::shooter::kD);
// m_rightSlave.Config_kF(0, constants::shooter::kFF);
// m_rightSlave.Config_kF(0, 0.05);

// m_leftMaster.ConfigSelectedFeedbackSensor(FeedbackDevice::IntegratedSensor, 0, 0);
// m_rightSlave.ConfigSelectedFeedbackSensor(FeedbackDevice::IntegratedSensor, 0, 0);

m_leftMaster.enableBrakeMode(false);
m_rightSlave.enableBrakeMode(false);
}

@Override
Expand Down

0 comments on commit 73a1a25

Please sign in to comment.