View Single Post
  #1   Spotlight this post!  
Unread 28-04-2016, 20:38
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 192
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
How simple should commands be? And how should they be structured?

Hello everyone,

I was wondering how other people structured or put together commands in their command-based robots. I am always struggling with myself on how to structure them and how simple they should be.

For example, lets say I want to open and close a solenoid. Should I make a command that opens it, and a command that closes it, or just have a single command that gets passed a value to tell which valve I want to open?

I think the first way of doing that is way too "separated", so in my code I use the second method.

However, one issue I always run into is when I want to use "axis" values on a joystick in a command. For example, on our shooter, we use the right trigger on the xbox 360 controller for spinning up our shooter, but that leads to a weird situation where I had to write a special condition where if the time parameter passed in was exactly 0, it would assume it was in teleoperated mode. Here is what I am talking about:

Code:
	
        timeCurrent = timer->Get();
	if(timeTarget == 0) {
		if(rightTrigger2 > 0.2) {
			//Robot::shooterSubsystem->Shoot(12);
			Robot::shooterSubsystem->Shoot(6000);
			Robot::intakeSubsystem->Intake(-1);
		}
		else if(leftTrigger2 > 0.2) {
			Robot::shooterSubsystem->Shoot(-1500);
			Robot::intakeSubsystem->Intake(1);
			Robot::shooterSubsystem->SetAngleLeftServo(0);
			Robot::shooterSubsystem->SetAngleRightServo(200);
		}
		else {
			Robot::shooterSubsystem->Shoot(0);
			Robot::intakeSubsystem->Intake(0);
			Robot::shooterSubsystem->SetAngleLeftServo(70);
			Robot::shooterSubsystem->SetAngleRightServo(110);
		}
		isDone = true;
	}
	else {
		if(timeCurrent >= timeTarget) {
			Robot::shooterSubsystem->Shoot(0);
			isDone = true;
		}
		else {
			Robot::shooterSubsystem->Shoot(inputSpeed);
			isDone = false;
		}
	}
That way of doing it seems wrong, but I'm not sure. Opinions and suggestions would be greatly appreciated!

Thanks,
Drew
Reply With Quote