mirror of
https://github.com/Team4388/RiseOfRidgebotics2020.git
synced 2026-06-09 00:38:00 -06:00
Drivetrain smoother acceleration
This commit is contained in:
+1
-2
@@ -11,8 +11,7 @@ def ROBOT_MAIN_CLASS = "frc4388.robot.Main"
|
|||||||
// Define my targets (RoboRIO) and artifacts (deployable files)
|
// Define my targets (RoboRIO) and artifacts (deployable files)
|
||||||
// This is added by GradleRIO's backing project EmbeddedTools.
|
// This is added by GradleRIO's backing project EmbeddedTools.
|
||||||
deploy {
|
deploy {
|
||||||
targets {
|
targets { roboRIO("roborio") {
|
||||||
roboRIO("roborio") {
|
|
||||||
// Team number is loaded either from the .wpilib/wpilib_preferences.json
|
// Team number is loaded either from the .wpilib/wpilib_preferences.json
|
||||||
// or from command line. If not found an exception will be thrown.
|
// or from command line. If not found an exception will be thrown.
|
||||||
// You can use getTeamOrDefault(team) instead of getTeamNumber if you
|
// You can use getTeamOrDefault(team) instead of getTeamNumber if you
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class Robot extends TimedRobot {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void teleopInit() {
|
public void teleopInit() {
|
||||||
m_robotContainer.setDriveNeutralMode(NeutralMode.Brake);
|
m_robotContainer.setDriveNeutralMode(NeutralMode.Coast);
|
||||||
|
|
||||||
// This makes sure that the autonomous stops running when
|
// This makes sure that the autonomous stops running when
|
||||||
// teleop starts running. If you want the autonomous to
|
// teleop starts running. If you want the autonomous to
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import edu.wpi.first.wpilibj2.command.InstantCommand;
|
|||||||
import edu.wpi.first.wpilibj2.command.RunCommand;
|
import edu.wpi.first.wpilibj2.command.RunCommand;
|
||||||
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
|
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
|
||||||
import frc4388.robot.Constants.*;
|
import frc4388.robot.Constants.*;
|
||||||
|
import frc4388.robot.commands.DriveWithJoystick;
|
||||||
import frc4388.robot.commands.RunIntakeWithTriggers;
|
import frc4388.robot.commands.RunIntakeWithTriggers;
|
||||||
import frc4388.robot.subsystems.Drive;
|
import frc4388.robot.subsystems.Drive;
|
||||||
import frc4388.robot.subsystems.Intake;
|
import frc4388.robot.subsystems.Intake;
|
||||||
@@ -48,9 +49,7 @@ public class RobotContainer {
|
|||||||
|
|
||||||
/* Default Commands */
|
/* Default Commands */
|
||||||
// drives the robot with a two-axis input from the driver controller
|
// drives the robot with a two-axis input from the driver controller
|
||||||
m_robotDrive.setDefaultCommand(new RunCommand(() -> m_robotDrive.driveWithInput(
|
m_robotDrive.setDefaultCommand(new DriveWithJoystick(m_robotDrive, getDriverController()));
|
||||||
getDriverController().getLeftYAxis(),
|
|
||||||
getDriverController().getRightXAxis()), m_robotDrive));
|
|
||||||
// drives motor with input from triggers on the opperator controller
|
// drives motor with input from triggers on the opperator controller
|
||||||
m_robotIntake.setDefaultCommand(new RunIntakeWithTriggers(m_robotIntake, getOperatorController()));
|
m_robotIntake.setDefaultCommand(new RunIntakeWithTriggers(m_robotIntake, getOperatorController()));
|
||||||
// continually sends updates to the Blinkin LED controller to keep the lights on
|
// continually sends updates to the Blinkin LED controller to keep the lights on
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||||
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||||
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||||
|
/* the project. */
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
package frc4388.robot.commands;
|
||||||
|
|
||||||
|
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||||
|
import frc4388.robot.subsystems.Drive;
|
||||||
|
import frc4388.utility.controller.IHandController;
|
||||||
|
|
||||||
|
public class DriveWithJoystick extends CommandBase {
|
||||||
|
private Drive m_drive;
|
||||||
|
private IHandController m_controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new DriveWithJoystick.
|
||||||
|
*/
|
||||||
|
public DriveWithJoystick(Drive subsystem, IHandController controller) {
|
||||||
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
|
m_drive = subsystem;
|
||||||
|
m_controller = controller;
|
||||||
|
addRequirements(m_drive);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the command is initially scheduled.
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
double moveInput = m_controller.getLeftYAxis();
|
||||||
|
double steerInput = m_controller.getRightXAxis();
|
||||||
|
double moveOutput = 0;
|
||||||
|
double steerOutput = 0;
|
||||||
|
if (moveInput >= 0){
|
||||||
|
moveOutput = -Math.cos(1.571*moveInput)+1;
|
||||||
|
} else {
|
||||||
|
moveOutput = Math.cos(1.571*moveInput)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
double cosMultiplier = .45;
|
||||||
|
double deadzone = .2;
|
||||||
|
if (steerInput > 0){
|
||||||
|
steerOutput = -cosMultiplier*Math.cos(1.571*steerInput)+(cosMultiplier+deadzone);
|
||||||
|
} else {
|
||||||
|
steerOutput = cosMultiplier*Math.cos(1.571*steerInput)-(cosMultiplier+deadzone);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_drive.driveWithInput(moveOutput, steerOutput);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called once the command ends or is interrupted.
|
||||||
|
@Override
|
||||||
|
public void end(boolean interrupted) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true when the command should end.
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user