View Single Post
  #3   Spotlight this post!  
Unread 09-07-2016, 16:09
yedidya03 yedidya03 is offline
Registered User
FRC #3211
 
Join Date: Apr 2016
Location: Yeruham, Israel
Posts: 3
yedidya03 is an unknown quantity at this point
Re: Command ataching issue

the first problem was when I added a command group to a button action.

the command group was :
Code:
public class DropAndCollect extends CommandGroup{

	public DropAndCollect() {
		// TODO Auto-generated constructor stub
		addSequential(new DropAndCollect());
		addSequential(new Collect());
	}
	
}
the OI was :
Code:
public class OI {
	public Joystick stick = new Joystick(0);
	public Button[] btns = new Button[11];{
		for (int i = 0; i < 11; i ++){
			btns[i] = new JoystickButton(stick, i + 1);
		}
	}
	
    public OI(){
    	btns[0].whileHeld(new DropAndCollect());
    }
}
the second problem was when trying to have 2 commands at different actions of a button (in this case I also had no communication)

OI code :
Code:
public class OI {
	public Joystick stick = new Joystick(0);
	public Button[] btns = new Button[11];{
		for (int i = 0; i < 11; i ++){
			btns[i] = new JoystickButton(stick, i + 1);
		}
	}
	
    public OI(){
    	btns[0].whenPressed(new DropCollector());
    	btns[0].whileHeld(new Collect());
    }
}
the third problem was when I tried to define a trigger and run a command with it.

trigger code:
Code:
public class ThrottleTrigger extends Trigger{

	@Override
	public boolean get() {
		// TODO Auto-generated method stub
		return Robot.oi.stick.getThrottle() > 0;
	}

}
OI code:
Code:
public class OI {
	public Joystick stick = new Joystick(0);
	public Button[] btns = new Button[11];{
		for (int i = 0; i < 11; i ++){
			btns[i] = new JoystickButton(stick, i + 1);
		}
	}
	public ThrottleTrigger throttleTrigger = new ThrottleTrigger();
	
    public OI(){
    	throttleTrigger.whenActive(new RaiseCollectorArm());
    }
}
if someone knows why is that happening it will be very helpful.
Reply With Quote