-
Notifications
You must be signed in to change notification settings - Fork 0
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
Yash.claw #4
base: main
Are you sure you want to change the base?
Yash.claw #4
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package org.wildstang.year2023.subsystems; | ||
|
||
import org.apache.commons.math3.ml.neuralnet.twod.NeuronSquareMesh2D.VerticalDirection; | ||
import org.wildstang.framework.io.inputs.Input; | ||
import org.wildstang.framework.subsystems.Subsystem; | ||
import org.wildstang.hardware.roborio.inputs.WsDPadButton; | ||
import org.wildstang.hardware.roborio.inputs.WsJoystickAxis; | ||
import org.wildstang.hardware.roborio.outputs.WsSparkMax; | ||
import org.wildstang.year2023.robot.WSAutoPrograms; | ||
import org.wildstang.year2023.robot.WSInputs; | ||
import org.wildstang.year2023.robot.WSOutputs; | ||
|
||
public class ArmEverybot implements Subsystem | ||
{ | ||
WsSparkMax m1; | ||
WsSparkMax m2; | ||
WsJoystickAxis lefttrigger; | ||
WsJoystickAxis righttrigger; | ||
WsDPadButton dPadButton1; | ||
WsDPadButton dPadButton2; | ||
double mSpeed; | ||
double mSpeed2; | ||
|
||
|
||
@Override | ||
public void inputUpdate(Input sourceInput) { | ||
if (sourceInput == lefttrigger || sourceInput == righttrigger){ | ||
if (sourceInput == lefttrigger) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Get rid of this second level of if statements and merge the 2 3rd levels |
||
if (Math.abs(lefttrigger.getValue()) > 0.3){ | ||
mSpeed = -0.8; | ||
} | ||
else { | ||
mSpeed = 0; | ||
} | ||
} | ||
else if (sourceInput == righttrigger) | ||
{ | ||
if (Math.abs(righttrigger.getValue()) > 0.3){ | ||
mSpeed = 0.8; | ||
} | ||
else { | ||
mSpeed = 0; | ||
YashwantCherukuri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
if (sourceInput == dPadButton1){ | ||
if (dPadButton1.getValue()){ | ||
mSpeed2 = 0.8; | ||
} | ||
if (sourceInput == dPadButton2){ | ||
if (dPadButton2.getValue()){ | ||
mSpeed2 = 0.8; | ||
} | ||
Comment on lines
+46
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do you stop mSpeed2 |
||
} | ||
} | ||
else { | ||
|
||
} | ||
|
||
} | ||
} | ||
} // TODO Auto-generated method stub | ||
|
||
|
||
|
||
@Override | ||
public void init() { | ||
// TODO Auto-generated method stub | ||
lefttrigger = (WsJoystickAxis) WSInputs.MANIPULATOR_LEFT_JOYSTICK_BUTTON.get(); | ||
righttrigger = (WsJoystickAxis) WSInputs.MANIPULATOR_RIGHT_JOYSTICK_BUTTON.get(); | ||
lefttrigger.addInputListener(this); | ||
righttrigger.addInputListener(this); | ||
m1 = (WsSparkMax) WSOutputs.TEST_MOTOR.get(); | ||
m2 = (WsSparkMax) WSOutputs.TEST_MOTOR2.get(); | ||
mSpeed = 0; | ||
dPadButton1 = (WsDPadButton) WSInputs.MANIPULATOR_DPAD_UP.get(); | ||
dPadButton2 = (WsDPadButton) WSInputs.MANIPULATOR_DPAD_DOWN.get(); | ||
dPadButton1.addInputListener(this); | ||
dPadButton2.addInputListener(this); | ||
mSpeed2 = 0; | ||
} | ||
|
||
@Override | ||
public void selfTest() { | ||
// TODO Auto-generated method stub | ||
|
||
}; | ||
@Override | ||
public void update() { | ||
// TODO Auto-generated method stub | ||
m1.setValue(mSpeed); | ||
if (mSpeed == 0){ | ||
m1.setBrake(); | ||
} | ||
else { | ||
m1.setCoast(); | ||
} | ||
m2.setValue(mSpeed2); | ||
if (mSpeed2 == 0) { | ||
m2.setBrake(); | ||
} | ||
else { | ||
m2.setCoast(); | ||
} | ||
}; | ||
|
||
|
||
@Override | ||
public void resetState() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public String getName() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
}; | ||
//The controls would be LT to intake cargo, RT to score cargo, LB to intake | ||
|
||
//cones, RB to score cones, and Dpad up and down to raise and lower the arm | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.wildstang.year2023.subsystems; | ||
import org.wildstang.framework.io.inputs.Input; | ||
import org.wildstang.framework.subsystems.Subsystem; | ||
import org.wildstang.hardware.roborio.inputs.WsJoystickAxis; | ||
import org.wildstang.hardware.roborio.outputs.WsSparkMax; | ||
import org.wildstang.year2023.robot.WSInputs; | ||
import org.wildstang.year2023.robot.WSOutputs; | ||
|
||
public class Claw implements Subsystem | ||
YashwantCherukuri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
WsSparkMax motor; | ||
WsJoystickAxis forwardButton; | ||
WsJoystickAxis reverseButton; | ||
double motorSpeed; | ||
|
||
|
||
@Override | ||
public void init(){ | ||
forwardButton = (WsJoystickAxis) WSInputs.MANIPULATOR_LEFT_TRIGGER.get(); | ||
reverseButton = (WsJoystickAxis) WSInputs.MANIPULATOR_RIGHT_TRIGGER.get(); | ||
forwardButton.addInputListener(this); | ||
reverseButton.addInputListener(this); | ||
motor = (WsSparkMax) WSOutputs.TEST_MOTOR.get(); | ||
motorSpeed = 0; | ||
}; | ||
@Override | ||
public void resetState(){}; | ||
@Override | ||
public void update(){ | ||
motor.setValue(motorSpeed); | ||
if (motorSpeed == 0){ | ||
motor.setBrake(); | ||
} | ||
else { | ||
motor.setCoast(); | ||
} | ||
}; | ||
@Override | ||
public void inputUpdate(Input sourceInput){ | ||
if (sourceInput == forwardButton){ | ||
if (Math.abs(forwardButton.getValue())> 0.3){ | ||
motorSpeed = 0.8; | ||
} | ||
else { | ||
motorSpeed = 0; | ||
} | ||
} | ||
else if (sourceInput == reverseButton){ | ||
if (Math.abs(reverseButton.getValue()) < 0.3){ | ||
motorSpeed = -0.8; | ||
} | ||
else { | ||
motorSpeed = 0; | ||
} | ||
} | ||
} | ||
@Override | ||
public void selfTest(){}; | ||
@Override | ||
public String getName(){return "Claw";}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package org.wildstang.year2023.subsystems; | ||
import org.wildstang.framework.io.inputs.Input; | ||
import org.wildstang.framework.subsystems.Subsystem; | ||
import org.wildstang.hardware.roborio.inputs.WsJoystickAxis; | ||
import org.wildstang.hardware.roborio.outputs.WsSparkMax; | ||
import org.wildstang.year2023.robot.WSInputs; | ||
import org.wildstang.year2023.robot.WSOutputs; | ||
|
||
public class TankDriveEverybot implements Subsystem | ||
{ | ||
WsSparkMax motor; | ||
WsSparkMax motor2; | ||
WsJoystickAxis forwardTrigger; | ||
WsJoystickAxis backTrigger; | ||
double motorSpeed; | ||
@Override | ||
public void inputUpdate(Input sourceInput) { | ||
// TODO Auto-generated method stub | ||
if (sourceInput == forwardTrigger || sourceInput == backTrigger){ | ||
if (sourceInput == forwardTrigger){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Get rid of this second level of if statements and merge the 2 3rd levels |
||
if (Math.abs(forwardTrigger.getValue()) > 0.2){ | ||
motorSpeed = 0.8; | ||
} | ||
else { | ||
motorSpeed = 0; | ||
}} | ||
|
||
else if (sourceInput == backTrigger){ | ||
if (Math.abs(backTrigger.getValue()) > 0.2){ | ||
motorSpeed = -0.8; | ||
} | ||
else { | ||
motorSpeed = 0; | ||
YashwantCherukuri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} | ||
} | ||
@Override | ||
public void init() { | ||
// TODO Auto-generated method stub | ||
forwardTrigger = (WsJoystickAxis) WSInputs.MANIPULATOR_RIGHT_TRIGGER.get(); | ||
backTrigger = (WsJoystickAxis) WSInputs.MANIPULATOR_LEFT_TRIGGER.get(); | ||
forwardTrigger.addInputListener(this); | ||
backTrigger.addInputListener(this); | ||
motor = (WsSparkMax) WSOutputs.TEST_MOTOR.get(); | ||
motor2 = (WsSparkMax) WSOutputs.TEST_MOTOR2.get(); | ||
motorSpeed = 0; | ||
} | ||
@Override | ||
public void selfTest() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
@Override | ||
public void update() { | ||
// TODO Auto-generated method stub | ||
motor.setValue(motorSpeed); | ||
YashwantCherukuri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (motorSpeed == motor.getValue() || motorSpeed == motor2.getValue()){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this trying to accomplish? |
||
if (motorSpeed == 0){ | ||
motor.setBrake(); | ||
} | ||
else { | ||
motor.setCoast(); | ||
} | ||
if (motorSpeed == 0){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You probably want 2 different speeds for left and right |
||
motor2.setBrake(); | ||
} | ||
else { | ||
motor.setCoast(); | ||
} | ||
} | ||
}; | ||
@Override | ||
public void resetState() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
@Override | ||
public String getName() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming you missed adding this file