Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Java Paramter Type (http://www.chiefdelphi.com/forums/showthread.php?t=143157)

nlt5 04-02-2016 14:26

Java Paramter Type
 
In robot builder under commands there is a parameter section. Could someone explain when to use each type of parameter?

Thank you

SamCarlberg 04-02-2016 19:02

Re: Java Paramter Type
 
Quick recap on command parameters:

Parameters are there so you can have one command perform multiple actions (rather than one command per action).

For example: there's a mechanism on your robot to kick boulders into the low goal, powered by a pneumatic piston and solenoid. In previous years, you would need a command for kicking and another for retracting the kicker, with their constructors looking something like this:

Code:

public KickCommand() {
    // constructor code
}
...
public RetractKickerCommand() {
    // constructor code
}

With parameters, you can have one command perform either action based on the parameter you give it

Code:

private final boolean m_extending;
public ControlKickerCommand(boolean extending) {
    m_extending = extending;
    // other constructor code
}



If a command sets one of two states, you would use a boolean parameter, like in the example above.

If a command needs a certain setpoint (like a PIDCommand), that should be a double or int

Strings don't have much use for robot control, but may see use in logging/debugging

nlt5 05-02-2016 08:05

Re: Java Paramter Type
 
Thank you for taking the time to explain that.


All times are GMT -5. The time now is 17:31.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi