Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/org/wildstang/year2023/robot/CANConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public final class CANConstants {
public static final int ANGLE3 = 16;
public static final int DRIVE4 = 17;
public static final int ANGLE4 = 18;
public static final int EVERYBOT1 = 0;
public static final int EBOT2 = 0;


}
2 changes: 2 additions & 0 deletions src/main/java/org/wildstang/year2023/robot/WSOutputs.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public enum WSOutputs implements Outputs {
ANGLE3("Module 3 Angle Motor", new WsSparkMaxConfig(CANConstants.ANGLE3, true)),
DRIVE4("Module 4 Drive Motor", new WsSparkMaxConfig(CANConstants.DRIVE4, true)),
ANGLE4("Module 4 Angle Motor", new WsSparkMaxConfig(CANConstants.ANGLE4, true)),
EVERYBOT1("Module 4 Angle Motor", new WsSparkMaxConfig(CANConstants.EVERYBOT1, true)),
EBOT2("Module 4 Angle Motor", new WsSparkMaxConfig(CANConstants.EBOT2, true)),
Copy link
Member

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



// ---------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/wildstang/year2023/robot/WSSubsystems.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.wildstang.year2023.robot;

import org.wildstang.framework.core.Subsystems;
import org.wildstang.year2023.subsystems.Claw;
import org.wildstang.year2023.subsystems.SampleSubsystem;
import org.wildstang.year2023.subsystems.swerve.SwerveDrive;
import org.wildstang.year2023.subsystems.targeting.AimHelper;
Expand All @@ -13,6 +14,7 @@ public enum WSSubsystems implements Subsystems {

// enumerate subsystems
SWERVE_DRIVE("Swerve Drive", SwerveDrive.class),
CLAW("Claw", Claw.class),
//AIM_HELPER("Aim Helper", AimHelper.class),
//SAMPLE("Sample", SampleSubsystem.class)
;
Expand Down
121 changes: 121 additions & 0 deletions src/main/java/org/wildstang/year2023/subsystems/ArmEverybot.java
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) {
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The 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
}

61 changes: 61 additions & 0 deletions src/main/java/org/wildstang/year2023/subsystems/Claw.java
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){
Copy link
Member

Choose a reason for hiding this comment

The 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()){
Copy link
Member

Choose a reason for hiding this comment

The 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){
Copy link
Member

Choose a reason for hiding this comment

The 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;
}

}