Skip to content
This repository has been archived by the owner on Dec 19, 2021. It is now read-only.

Control Panel Subsystem #16

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open

Conversation

jwaters3457
Copy link
Contributor

@jwaters3457 jwaters3457 commented Jan 25, 2020

#16

Copy link
Member

@fruzyna fruzyna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove 2019_robot_software submodule

Comment on lines 19 to 22




Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra lines

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump

Comment on lines 64 to 67
private DigitalInput CpDpadL;
private DigitalInput CpDpadR;
private DigitalInput CpA;
private DigitalInput Cpjoy;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not initialized, not used?

Comment on lines 120 to 127
switch(CpDeployOn){
case 0:
CpDeployOn = 1;
break;
case 1:
CpDeployOn = 1;
break;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need the switch here
CpDeployOn = 1 looks like it is all you need

Comment on lines 120 to 138
switch(CpDeployOn){
case 0:
CpDeployOn = 1;
break;
case 1:
CpDeployOn = 1;
break;
}
}
if ((source == CpDpadDWN) && CpDWNbool){
switch(CpDeployOn){
case 3:
CpDeployOn = 2;
break;
case 2:
CpDeployOn = 2;
break;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the 4 cases? (0-3)

Comment on lines 131 to 135
case 3:
CpDeployOn = 2;
break;
case 2:
CpDeployOn = 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Comment on lines 198 to 199
if (IsDown == true){
if (CpDeployOn == 2){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a single if statement

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for the 2 below

Comment on lines 68 to 71
private DigitalInput CpFWDspin;
private DigitalInput CpBWDspin;
private DigitalInput CpINTspin;
private DigitalInput CpENCspin;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to avoid abbreviating variables names, this can be confusing

Also remove the Cp s they are unnecessary

@fruzyna fruzyna changed the title Control panel development Control Panel Subsystem Jan 25, 2020
@fruzyna fruzyna added the enhancement New feature or request label Jan 25, 2020
Comment on lines 19 to 22




Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump

import org.wildstang.framework.io.inputs.DigitalInput;
import org.wildstang.framework.CoreUtils;

public class Turret implements Subsystem {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The turret does not belong in this pull request... please remove


//other booleans/ints
private int DeployOn;
// 1 = Up, 0 = Off-Down, 2 = Down, 3 = Off-Up
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cp doesn't have to be fully deployed or retracted, so there is no need for the up and down states

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best practice would be to use an enum for these states

Comment on lines 99 to 114
if ((source == DpadUP) && UPbool){
switch(DeployOn){
case 0:
case 1:
DeployOn = 1;
break;
}
}
if ((source == DpadDWN) && DWNbool){
switch(DeployOn){
case 3:
case 2:
DeployOn = 2;
break;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the comment above this should really be if down is pressed retract, if up is pressed deploy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If neither there should also be an idle state

Comment on lines 93 to 98
UPbool = DpadUP.getValue();
DWNbool = DpadDWN.getValue();
FWDbool = FWDspin.getValue();
BWDbool = BWDspin.getValue();
ENCbool = ENCspin.getValue();
INTbool = INTspin.getValue();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are going to predefine values for the button state, use descriptive names. Never use the variable type in a name. For example downPressed would be a decent name

private double UPWAIT = 5.25;
private int Spins = 0;
private boolean start = false;
private double CMDspin;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems mixed between being a state and a speed. I recommend using a speed for the motor for the control panel mech

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then is we are running in encoder controlled mode, have another variable that tracks the number of encoder cycles remaining

Comment on lines 116 to 127
if (FWDbool){
CMDspin = 1; //if FWD, spin forward
}
else{
if(BWDbool){
CMDspin = -1; //otherwise, if BWD, spin backwards
}
else{
if (CMDspin != 6) //CMD 6 means encoder is running
CMDspin = 0; //if nothing pressed and encoder not running, turn motor off
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As recommended above have 2 variables, one for speed and one for number of encoder ticks remaining

Comment on lines 136 to 141
if ((source == ENCspin) && ENCbool){
Spins += (1500);
spinOn = true;
CMDspin = 6;
Spinner.getSensorCollection().setQuadraturePosition(0, 0);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be with the other spin mech code
Also recommend adjusting the speed as you approach the goal

}

@Override
public void update() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should really just be setting the motors to their appropriate speeds. Also the encoder and limit switched will be attached through the Talons

@fruzyna
Copy link
Member

fruzyna commented Jan 31, 2020

Code doesn't compile, please determine the error and resolve

Comment on lines 143 to 151
if (booldeployUp&&(!booldeployDown)){
deploySpeed = 1; //deploy goes up
}
if (booldeployDown&&(!booldeployUp)){
deploySpeed = -1; //deploy goes down
}
if ((!booldeployDown)&&(!booldeployUp)){
deploySpeed = 0;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens here if you have 2 buttons pressed?
I'd remove the checks for the opposite button not being pressed and switch to and if-elseif-else block.
Regardless, it shouldn't really be possible to press both on the d-pad.

Comment on lines 155 to 165
if (boolforwardSpin&&(!boolbackwardSpin)){
spinSpeed = 1;
presetSpins = 0;
}
if (boolbackwardSpin&&(!boolforwardSpin)){
spinSpeed = -1;
presetSpins = 0;
}
if ((!boolbackwardSpin)&&(!boolforwardSpin)){
spinSpeed = 0;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above comment

jwaters3457 and others added 6 commits February 7, 2020 19:35
Before it would have not spun when the presser spin was pressed unless it had passed the preset spin point, in which case it would get stuck spinning.
the color spin would have been automatically overridden.
More changes expected. hopefully no errors.
they were important.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants