-
Notifications
You must be signed in to change notification settings - Fork 0
Merge pull request #1 from FRCTeam1024/Projects #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
1024Programming
wants to merge
31
commits into
Projects
Choose a base branch
from
master
base: Projects
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RobotBuilder Version: 2.0 // // This file was generated by RobotBuilder. It contains sections of // code that are automatically generated and assigned by robotbuilder. // These sections will be updated in the future when you export to // Java from RobotBuilder. Do not put any code or make any change in // the blocks indicating autogenerated code or it will be lost on an // update. Deleting the comments indicating the section will prevent // it from being updated in the future. package frc.robot.subsystems; import frc.robot.commands.*; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.command.Subsystem; import edu.wpi.first.wpilibj.PIDOutput; import edu.wpi.first.wpilibj.PIDSource; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import com.kauailabs.navx.frc.AHRS; import edu.wpi.first.wpilibj.AnalogGyro; import com.ctre.phoenix.motorcontrol.ControlMode; import edu.wpi.first.wpilibj.SerialPort; // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=IMPORTS import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; import edu.wpi.first.wpilibj.CounterBase.EncodingType; import edu.wpi.first.wpilibj.SPI; import edu.wpi.first.wpilibj.Encoder; import edu.wpi.first.wpilibj.I2C; import edu.wpi.first.wpilibj.I2C.Port; // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=IMPORTS /** * */ public class DriveTrain extends Subsystem { // public Encoder encoder = new Encoder(0, 1, false, EncodingType.k4X); // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTANTS // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTANTS // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS private WPI_TalonSRX frontRight; private WPI_TalonSRX middleRight; private WPI_TalonSRX rearRight; public WPI_TalonSRX frontLeft; // This is being used as the encoder private WPI_TalonSRX middleLeft; private WPI_TalonSRX rearLeft; private AnalogGyro navx; private I2C i2c; public AHRS ahrs; // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS public DriveTrain() { // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS frontRight = new WPI_TalonSRX(5); middleRight = new WPI_TalonSRX(8); rearRight = new WPI_TalonSRX(9); frontLeft = new WPI_TalonSRX(2); middleLeft = new WPI_TalonSRX(3); rearLeft = new WPI_TalonSRX(4); // private final I2C.Port i2cPort = I2C.Port.kMXP; // navx = new AnalogGyro(Port.kMXP); ahrs = new AHRS(SerialPort.Port.kMXP); // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS //encoder.setDistancePerPulse((1.0 / 71.0) * 4.0); } @OverRide public void initDefaultCommand() { // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DEFAULT_COMMAND setDefaultCommand(new DriveWithJoysticks()); // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DEFAULT_COMMAND // Set the default command for a subsystem here. // setDefaultCommand(new MySpecialCommand()); } @OverRide public void periodic() { // Put code here to be run every loop outputToSmartDashboard(); //SmartDashboard.putBoolean("Reset Encoder", resetOpticalEncoder()); } // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CMDPIDGETTERS public void drive(double leftPower, double rightPower) { frontLeft.set(ControlMode.PercentOutput, leftPower); middleLeft.set(ControlMode.PercentOutput, leftPower); rearLeft.set(ControlMode.PercentOutput, leftPower); frontRight.set(ControlMode.PercentOutput, -rightPower); middleRight.set(ControlMode.PercentOutput, -rightPower); rearRight.set(ControlMode.PercentOutput, -rightPower); } // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CMDPIDGETTERS // Put methods for controlling this subsystem // here. Call these from Commands. /**public double getRawRightEncoder() { outputToSmartDashboard(); return encoder.get(); }**/ public double getOpticalDistanceInches() { /*//getWheelRotation() = distance / (Math.PI * RobotMap.WHEEL_DIAMETER) * RobotMap.ENCODER_COUNTS_PER_REVOLUTION; return (((getRawMagneticEncoder() / RobotMap.ENCODER_RATIO_TO_WHEEL * Math.PI * RobotMap.WHEEL_DIAMETER) / RobotMap.OPTICAL_ENCODER_COUNTS_PER_REVOLUTION)/ 4) * 3 * 3;*/ //return encoder.getDistance(); //must have a specified distance per pulse set return frontLeft.getSelectedSensorPosition() * 1/70; //(1.0 / 71.0) * 4.0; //wheel diameter: 6 in } public void resetOpticalEncoder() { frontLeft.setSelectedSensorPosition(0); } public void outputToSmartDashboard() { SmartDashboard.putNumber("Optical Encoder Distance (IN)", -getOpticalDistanceInches()); SmartDashboard.putNumber("Optical Encoder Raw", -frontLeft.getSelectedSensorPosition()); SmartDashboard.putNumber("IMU_CompassHeading", ahrs.getCompassHeading()); SmartDashboard.putNumber("IMU_Yaw", ahrs.getYaw()); } public void stop() { frontLeft.set(ControlMode.PercentOutput, 0.0); middleLeft.set(ControlMode.PercentOutput, 0.0); rearLeft.set(ControlMode.PercentOutput, 0.0); frontRight.set(ControlMode.PercentOutput, 0.0); middleRight.set(ControlMode.PercentOutput, 0.0); rearRight.set(ControlMode.PercentOutput, 0.0); } }
…although not quite working
Bloomington event (merge to master)
PIDGyroAim: - Takes in a given angle and uses the AHRS gyro to aim to it using the PID formula ResetGyro: - Class used by the SmartDashboard to reset the Gyro Sensor's angle RobotContainer: - Added the Smart Dashboard Button for the PIDGyroAim at a preset angle of 65 degrees - Added a view of the current Gyro Angle - Added a button to reset the gyro sensor on the Smart Dashboard Drivetrain: - Added an AHRS controller and resetGyro() method
Auto aim and shoot
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
// RobotBuilder Version: 2.0
//
// This file was generated by RobotBuilder. It contains sections of
// code that are automatically generated and assigned by robotbuilder.
// These sections will be updated in the future when you export to
// Java from RobotBuilder. Do not put any code or make any change in
// the blocks indicating autogenerated code or it will be lost on an
// update. Deleting the comments indicating the section will prevent
// it from being updated in the future.
package frc.robot.subsystems;
import frc.robot.commands.*;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.PIDOutput;
import edu.wpi.first.wpilibj.PIDSource;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import com.kauailabs.navx.frc.AHRS;
import edu.wpi.first.wpilibj.AnalogGyro;
import com.ctre.phoenix.motorcontrol.ControlMode;
import edu.wpi.first.wpilibj.SerialPort;
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=IMPORTS
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
import edu.wpi.first.wpilibj.CounterBase.EncodingType;
import edu.wpi.first.wpilibj.SPI;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.I2C;
import edu.wpi.first.wpilibj.I2C.Port;
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=IMPORTS
/**
*
*/
public class DriveTrain extends Subsystem {
}