View Single Post
  #4   Spotlight this post!  
Unread 27-06-2016, 18:24
euhlmann's Avatar
euhlmann euhlmann is online now
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 312
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Is my code good?

Just some git/project related things:

I recommend you name your project something that includes the year and/or game. If you're going to be making another robot program next year, having separate names will allow you to store both projects on GitHub. For example, naming it PLS5618-Stronghold-2016 will allow you to make another project next year: PLS5618-WaterGame-2017

Make sure you allow your .gitignore to take effect. On your local copy of the project, commit anything if necessary, then run
Code:
git rm -r --cached .
git add .
git commit -a -m "Untrack gitignored files"
---

Instead of having the command pair InBallon/OutBallon, which are very similar, I think it makes more sense to have a single command handle both, eg
Code:
public class MoveBall extends Command {
	public enum MoveBallDirection {
		IN,
		OUT
	}

	MoveBallDirection whichDirection;
	public MoveBall (MoveBallDirection whichDirection) {
		requires(Robot.pelle);
		this.whichDirection = whichDirection;
	}

	protected void initialize() {

	}

	protected void execute() {
		if (whichDirection == MoveBallDirection.OUT) {
			Robot.pelle.outBallon();
		} else {
			Robot.pelle.inBallon();
		}
		Timer.delay(0.08);
	}

	protected boolean isFinished() {
		if (whichDirection == MoveBallDirection.OUT) {
			return !Robot.oi.stick.getRawButton(4);
		} else {
			return Robot.pelle.limitFond();
		}
	}
}
Similarly, you could even refactor Pelle.in/outBallon into a single function.
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote