public class RateControlRobot extends TeamRobot
You can set the rate for:
Note: When calling setVelocityRate()
, setTurnRate()
, setGunRotationRate()
,
setRadarRotationRate()
and variants, Any previous calls to "movement" functions outside of
RateControlRobot
, such as setAhead()
, setTurnLeft()
,
setTurnRadarRightRadians()
and similar will be overridden when calling the
execute()
on this robot class.
Look into the source code for the sample.VelociRobot
in order to see how to use this
robot type.
JuniorRobot
,
Robot
,
AdvancedRobot
,
TeamRobot
,
Droid
,
BorderSentry
out
Constructor and Description |
---|
RateControlRobot() |
Modifier and Type | Method and Description |
---|---|
void |
execute()
Executes any pending actions, or continues executing actions that are
in process.
|
double |
getGunRotationRate()
Gets the gun's clockwise rotation per turn, in degrees.
|
double |
getGunRotationRateRadians()
Gets the gun's clockwise rotation per turn, in radians.
|
double |
getRadarRotationRate()
Gets the radar's clockwise rotation per turn, in degrees.
|
double |
getRadarRotationRateRadians()
Gets the radar's clockwise rotation per turn, in radians.
|
double |
getTurnRate()
Gets the robot's clockwise rotation per turn, in degrees.
|
double |
getTurnRateRadians()
Gets the robot's clockwise rotation per turn, in radians.
|
double |
getVelocityRate()
Returns the speed the robot will move, in pixels per turn.
|
void |
setGunRotationRate(double gunRotationRate)
Sets the gun's clockwise (right) rotation per turn, in degrees.
|
void |
setGunRotationRateRadians(double gunRotationRate)
Sets the gun's clockwise (right) rotation per turn, in radians.
|
void |
setRadarRotationRate(double radarRotationRate)
Sets the radar's clockwise (right) rotation per turn, in degrees.
|
void |
setRadarRotationRateRadians(double radarRotationRate)
Sets the radar's clockwise (right) rotation per turn, in radians.
|
void |
setTurnRate(double turnRate)
Sets the robot's clockwise (right) rotation per turn, in degrees.
|
void |
setTurnRateRadians(double turnRate)
Sets the robot's clockwise (right) rotation per turn, in radians.
|
void |
setVelocityRate(double velocityRate)
Sets the speed the robot will move (forward), in pixels per turn.
|
broadcastMessage, getMessageEvents, getTeamEventListener, getTeammates, isTeammate, onMessageReceived, sendMessage
addCustomEvent, clearAllEvents, getAdvancedEventListener, getAllEvents, getBulletHitBulletEvents, getBulletHitEvents, getBulletMissedEvents, getDataDirectory, getDataFile, getDataQuotaAvailable, getDistanceRemaining, getEventPriority, getGunHeadingRadians, getGunTurnRemaining, getGunTurnRemainingRadians, getHeadingRadians, getHitByBulletEvents, getHitRobotEvents, getHitWallEvents, getRadarHeadingRadians, getRadarTurnRemaining, getRadarTurnRemainingRadians, getRobotDeathEvents, getScannedRobotEvents, getStatusEvents, getTurnRemaining, getTurnRemainingRadians, isAdjustGunForRobotTurn, isAdjustRadarForGunTurn, isAdjustRadarForRobotTurn, onCustomEvent, onDeath, onSkippedTurn, removeCustomEvent, setAhead, setBack, setEventPriority, setFire, setFireBullet, setInterruptible, setMaxTurnRate, setMaxVelocity, setResume, setStop, setStop, setTurnGunLeft, setTurnGunLeftRadians, setTurnGunRight, setTurnGunRightRadians, setTurnLeft, setTurnLeftRadians, setTurnRadarLeft, setTurnRadarLeftRadians, setTurnRadarRight, setTurnRadarRightRadians, setTurnRight, setTurnRightRadians, turnGunLeftRadians, turnGunRightRadians, turnLeftRadians, turnRadarLeftRadians, turnRadarRightRadians, turnRightRadians, waitFor
endTurn, getGunHeadingDegrees, getHeadingDegrees, getMaxWaitCount, getRadarHeadingDegrees, getWaitCount, setTurnGunLeftDegrees, setTurnGunRightDegrees, setTurnLeftDegrees, setTurnRadarLeftDegrees, setTurnRadarRightDegrees, setTurnRightDegrees, turnGunLeftDegrees, turnGunRightDegrees, turnLeftDegrees, turnRadarLeftDegrees, turnRadarRightDegrees, turnRightDegrees
ahead, back, doNothing, fire, fireBullet, getBasicEventListener, getBattleFieldHeight, getBattleFieldWidth, getEnergy, getGraphics, getGunCoolingRate, getGunHeading, getGunHeat, getHeading, getHeight, getInteractiveEventListener, getName, getNumRounds, getNumSentries, getOthers, getPaintEventListener, getRadarHeading, getRobotRunnable, getRoundNum, getSentryBorderSize, getTime, getVelocity, getWidth, getX, getY, onBattleEnded, onBulletHit, onBulletHitBullet, onBulletMissed, onHitByBullet, onHitRobot, onHitWall, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragged, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onMouseWheelMoved, onPaint, onRobotDeath, onRoundEnded, onScannedRobot, onStatus, onWin, resume, run, scan, setAdjustGunForRobotTurn, setAdjustRadarForGunTurn, setAdjustRadarForRobotTurn, setAllColors, setBodyColor, setBulletColor, setColors, setColors, setDebugProperty, setGunColor, setRadarColor, setScanColor, stop, stop, turnGunLeft, turnGunRight, turnLeft, turnRadarLeft, turnRadarRight, turnRight
getBattleNum, getGunCharge, getGunImageName, getLife, getNumBattles, getRadarImageName, getRobotImageName, setGunImageName, setRadarImageName, setRobotImageName
finalize, setOut, setPeer, toString
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAdvancedEventListener
getBasicEventListener, getRobotRunnable, setOut, setPeer
public void setVelocityRate(double velocityRate)
This call returns immediately, and will not execute until you call execute() or take an action that executes.
Note that both positive and negative values can be given as input, where negative values means that the robot will move backwards
Example:
// Set the robot to move forward 2 pixels per turn setVelocityRate(2); // Set the robot to move backwards 8 pixels per turn // (overrides the previous order) setVelocityRate(-8); ... // Executes the last setVelocityRate() execute();Note: This method overrules
AdvancedRobot.setAhead(double)
and
AdvancedRobot.setBack(double)
.velocityRate
- pixels per turn the robot will move.getVelocityRate()
,
setTurnRate(double)
,
setGunRotationRate(double)
,
setRadarRotationRate(double)
,
AdvancedRobot.setAhead(double)
,
AdvancedRobot.setBack(double)
public double getVelocityRate()
setVelocityRate(double)
public void setTurnRate(double turnRate)
This call returns immediately, and will not execute until you call execute() or take an action that executes.
Note that both positive and negative values can be given as input, where negative values means that the robot turns counterclockwise (left)
Example:
// Set the robot to turn right 10 degrees per turn setTurnRate(10); // Set the robot to turn left 4 degrees per turn // (overrides the previous order) setTurnRate(-5); ... // Executes the last setTurnRate() execute();
turnRate
- angle of the clockwise rotation, in degrees.getTurnRate()
,
setVelocityRate(double)
,
setGunRotationRate(double)
,
setRadarRotationRate(double)
,
AdvancedRobot.setTurnRight(double)
,
AdvancedRobot.setTurnLeft(double)
public double getTurnRate()
setTurnRate(double)
public void setTurnRateRadians(double turnRate)
This call returns immediately, and will not execute until you call execute() or take an action that executes.
Note that both positive and negative values can be given as input, where negative values means that the robot turns counterclockwise (left)
Example:
// Set the robot to turn right pi / 32 radians per turn setTurnRateRadians(Math.PI / 32); // Set the robot to turn left pi / 20 radians per turn // (overrides the previous order) setTurnRateRadians(-Math.PI / 20); ... // Executes the last setTurnRateRadians() execute();
turnRate
- angle of the clockwise rotation, in radians.getTurnRateRadians()
,
setVelocityRate(double)
,
setGunRotationRateRadians(double)
,
setRadarRotationRateRadians(double)
,
AdvancedRobot.setTurnRightRadians(double)
,
AdvancedRobot.setTurnLeftRadians(double)
public double getTurnRateRadians()
getTurnRateRadians()
public void setGunRotationRate(double gunRotationRate)
This call returns immediately, and will not execute until you call execute() or take an action that executes.
Note that both positive and negative values can be given as input, where negative values means that the gun turns counterclockwise (left)
Example:
// Set the gun to turn right 15 degrees per turn setGunRotationRate(15); // Set the gun to turn left 9 degrees per turn // (overrides the previous order) setGunRotationRate(-9); ... // Executes the last setGunRotationRate() execute();
gunRotationRate
- angle of the clockwise rotation, in degrees.getGunRotationRate()
,
setVelocityRate(double)
,
setTurnRate(double)
,
setRadarRotationRate(double)
,
AdvancedRobot.setTurnGunRight(double)
,
AdvancedRobot.setTurnGunLeft(double)
public double getGunRotationRate()
setGunRotationRate(double)
public void setGunRotationRateRadians(double gunRotationRate)
This call returns immediately, and will not execute until you call execute() or take an action that executes.
Note that both positive and negative values can be given as input, where negative values means that the gun turns counterclockwise (left)
Example:
// Set the gun to turn right pi / 16 radians per turn setGunRotationRateRadians(Math.PI / 16); // Set the gun to turn left pi / 12 radians per turn // (overrides the previous order) setGunRotationRateRadians(-Math.PI / 12); ... // Executes the last setGunRotationRateRadians() execute();
gunRotationRate
- angle of the clockwise rotation, in radians.getGunRotationRateRadians()
,
setVelocityRate(double)
,
setTurnRateRadians(double)
,
setRadarRotationRateRadians(double)
,
AdvancedRobot.setTurnGunRightRadians(double)
,
AdvancedRobot.setTurnGunLeftRadians(double)
public double getGunRotationRateRadians()
setGunRotationRateRadians(double)
public void setRadarRotationRate(double radarRotationRate)
This call returns immediately, and will not execute until you call execute() or take an action that executes.
Note that both positive and negative values can be given as input, where negative values means that the radar turns counterclockwise (left)
Example:
// Set the radar to turn right 45 degrees per turn setRadarRotationRate(45); // Set the radar to turn left 15 degrees per turn // (overrides the previous order) setRadarRotationRate(-15); ... // Executes the last setRadarRotationRate() execute();
radarRotationRate
- angle of the clockwise rotation, in degrees.getRadarRotationRate()
,
setVelocityRate(double)
,
setTurnRate(double)
,
setGunRotationRate(double)
,
AdvancedRobot.setTurnRadarRight(double)
,
AdvancedRobot.setTurnRadarLeft(double)
public double getRadarRotationRate()
setRadarRotationRate(double)
public void setRadarRotationRateRadians(double radarRotationRate)
This call returns immediately, and will not execute until you call execute() or take an action that executes.
Note that both positive and negative values can be given as input, where negative values means that the radar turns counterclockwise (left)
Example:
// Set the radar to turn right pi / 4 radians per turn setRadarRotationRateRadians(Math.PI / 4); // Set the radar to turn left pi / 8 radians per turn // (overrides the previous order) setRadarRotationRateRadians(-Math.PI / 8); ... // Executes the last setRadarRotationRateRadians() execute();
radarRotationRate
- angle of the clockwise rotation, in radians.getRadarRotationRateRadians()
,
setVelocityRate(double)
,
setTurnRateRadians(double)
,
setGunRotationRateRadians(double)
,
AdvancedRobot.setTurnRadarRightRadians(double)
,
AdvancedRobot.setTurnRadarLeftRadians(double)
public double getRadarRotationRateRadians()
setRadarRotationRateRadians(double)
public void execute()
Note that advanced robots must call this function in order to
execute pending set* calls like e.g. setVelocityRate()
, setFire()
,
setTurnRate()
etc. Otherwise, these calls will never get executed.
Any previous calls to "movement" functions outside of RateControlRobot
,
such as setAhead()
, setTurnLeft()
, setTurnRadarLeftRadians()
etc. will be overridden when this method is called on this robot class.
In this example the robot will move while turning:
setVelocityRate(6); setTurnRate(7); while (true) { execute(); }
execute
in class AdvancedRobot
Copyright © 2021 Robocode. All Rights Reserved.