public class LineFollowerConfig
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
LineFollowerConfig.Behavior |
static class |
LineFollowerConfig.Color |
static class |
LineFollowerConfig.ColorPattern
The combination of a color pattern is made up of 1-3 colors:
Color.RED, Color.GREEN, and Color.BLUE. |
static class |
LineFollowerConfig.ColorRule |
| Constructor and Description |
|---|
LineFollowerConfig()
Construct a configuration of line following with default settings inside.
|
LineFollowerConfig(java.lang.String configure)
Construct initialization of line following configuration according to the
specified JSON string.
|
| Modifier and Type | Method and Description |
|---|---|
RobotErrorCode |
addRule(LineFollowerConfig.Color color,
LineFollowerConfig.Behavior behavior,
java.lang.Object[] args)
Change the configuration of line following
|
RobotErrorCode |
addRule(LineFollowerConfig.ColorPattern colorPattern,
LineFollowerConfig.Behavior behavior,
java.lang.Object[] args)
Change the configuration of line following
|
java.lang.String |
build()
Returns a string that representing the configuration.
|
static RobotErrorCode |
checkRule(LineFollowerConfig.Color color,
LineFollowerConfig.Behavior behavior,
java.lang.Object[] args)
To check if the settings can be changed to line following configuration.
|
static RobotErrorCode |
checkRule(LineFollowerConfig.ColorPattern colorPattern,
LineFollowerConfig.Behavior behavior,
java.lang.Object[] args)
To check if the settings can be changed to line following configuration.
|
LineFollowerConfig.ColorRule |
getRule(LineFollowerConfig.Color color)
Return the settings of specific color.
|
LineFollowerConfig.ColorRule |
getRule(LineFollowerConfig.ColorPattern colorPattern)
Return the settings of specific color pattern.
|
java.util.List |
getRuleList()
Get the configuration list.
|
void |
removeRule(LineFollowerConfig.Color color)
Remove the settings of specific color.
|
void |
removeRule(LineFollowerConfig.ColorPattern colorPattern)
Remove the settings of specific color pattern.
|
public LineFollowerConfig()
public LineFollowerConfig(java.lang.String configure)
throws org.json.JSONException
configure - the line following configuration to default settings.org.json.JSONExceptionpublic RobotErrorCode addRule(LineFollowerConfig.Color color, LineFollowerConfig.Behavior behavior, java.lang.Object[] args)
color - Color Color.BLACK can only support the settings of
Behavior.SPEED_LEVEL.
Can't change the settings ofColor.WHITE,
Color.YELLOW and Color.UNKNOWNbehavior - The default settings of the configuration is
Behavior.NOTHING.
Can't change the setting of Behavior.UNKNOWN.args - The settings of Behavior.SPEED_LEVEL and
Behavior.ROTATION require third parameter
SpeedLevel.LineFollower.
The settings of Behavior.ROTATION require inputting
rotational angle (in degree).RobotErrorCode.NO_ERROR if successfully change the
settings. Otherwise, it will return a certain error code.MotionControl.SpeedLevel.LineFollowerpublic RobotErrorCode addRule(LineFollowerConfig.ColorPattern colorPattern, LineFollowerConfig.Behavior behavior, java.lang.Object[] args)
colorPattern - Color Patternbehavior - The default settings of the configuration is
Behavior.NOTHING.
Can't change the setting of Behavior.UNKNOWN.args - The settings of Behavior.SPEED_LEVEL and
Behavior.ROTATION require third parameter
SpeedLevel.LineFollower.
The settings of Behavior.ROTATION requires
inputting rotational angle (in degree).RobotErrorCode.NO_ERROR if successfully change the
settings. Otherwise, it will return a certain error code.LineFollowerConfig.ColorPattern,
MotionControl.SpeedLevel.LineFollowerpublic java.lang.String build()
public static RobotErrorCode checkRule(LineFollowerConfig.Color color, LineFollowerConfig.Behavior behavior, java.lang.Object[] args)
color - Color Color.BLACK can only support the settings of
Behavior.SPEED_LEVEL.
Can't change the settings of Color.WHITE,
Color.YELLOW and Color.UNKNOWNbehavior - The default settings of the configuration is
Behavior.NOTHING.
Can't change the setting of Behavior.UNKNOWN.args - The settings of Behavior.SPEED_LEVEL and
Behavior.ROTATION require third parameter
SpeedLevel.LineFollower.
The settings of Behavior.ROTATION requires inputting
rotational angle (in degree).RobotErrorCode.NO_ERROR if it can successfully change
the settings. Otherwise, it will return a certain error code.MotionControl.SpeedLevel.LineFollowerpublic static RobotErrorCode checkRule(LineFollowerConfig.ColorPattern colorPattern, LineFollowerConfig.Behavior behavior, java.lang.Object[] args)
colorPattern - Color Color.BLACK can only support the settings of
Behavior.SPEED_LEVEL.
Can't change the settings ofColor.WHITE,
Color.YELLOW and Color.UNKNOWNbehavior - The default settings of the configuration is
Behavior.NOTHING.
Can't change the setting of Behavior.UNKNOWN.args - The settings of Behavior.SPEED_LEVEL and
Behavior.ROTATION require third parameter
SpeedLevel.LineFollower.
The settings of Behavior.ROTATION requires
inputting rotational angle (in degree).RobotErrorCode.NO_ERROR if successfully change the
settings. Otherwise, it will return a certain error code.LineFollowerConfig.ColorPattern,
MotionControl.SpeedLevel.LineFollowerpublic LineFollowerConfig.ColorRule getRule(LineFollowerConfig.Color color)
color - specific colorColorRule for specific color.
Otherwise, it will return null if the color doesn't have any settings.LineFollowerConfig.ColorRulepublic LineFollowerConfig.ColorRule getRule(LineFollowerConfig.ColorPattern colorPattern)
colorPattern - color patternColorRule for specific color, Otherwise, it will return
null if the color pattern doesn't have any settings.public java.util.List getRuleList()
public void removeRule(LineFollowerConfig.Color color)
color - specific colorpublic void removeRule(LineFollowerConfig.ColorPattern colorPattern)
colorPattern - specific color pattern