|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectch.hei.kart.Kart
public class Kart
Kart model. Once connected, the kart model allows to manipulate the kart developed during the first year's summer school remotely.
Field Summary | |
---|---|
static int |
MAXIMAL_SPEED
Maximal drive speed. |
static int |
MINIMAL_SPEED
Minimal drive speed (maximal backwards). |
Constructor Summary | |
---|---|
Kart()
Constructs a new unconnected kart object with the default setup values. |
|
Kart(KartSetup setup)
Constructs a new kart object with the given setup. |
Method Summary | |
---|---|
void |
addKartListener(KartListener listener)
Adds the given kart listener to the kart. |
void |
addStatusRegisterListener(KartStatusRegisterListener listener)
Adds the given status listener to the kart. |
void |
connect(ch.hei.kart.comm.discovery.DiscoveryEntity entity)
Tries to establish a connection to the given kart entity. |
void |
decreaseDriveSpeed()
Decreases the drive speed (throttle) by the smallest possible increment. |
void |
disconnect()
Disconnects from the kart. |
float |
getBatteryLevel()
Returns the battery level from 0.0 (empty) to 1.0 (full). |
int |
getControlRegister(KartControlRegister register)
Returns the actual value of the control register. |
int |
getControlRegisterUnsigned(KartControlRegister register)
Returns the actual value of the control register. |
int |
getDriveSpeed()
Returns the actual absolute drive speed (throttle) in the range [-15, 15]. |
float |
getDriveSpeedNormalized()
Returns the actual normalized drive speed (throttle) in the range [-1.0, 1.0]. |
boolean |
getLed(int index)
Gets the status if the led at the given index. |
int |
getStatusRegister(KartStatusRegister register)
Returns the actual value of the status register. |
int |
getStatusRegisterUnsigned(KartStatusRegister register)
Returns the actual value of the status register. |
int |
getSteeringControlPosition()
Returns the actual absolute steering control position. |
float |
getSteeringControlPositionNormalized()
Returns the actual normalized steering control position. |
int |
getSteeringPosition()
Returns the actual absolute steering position (not the setpoint). |
float |
getSteeringPositionNormalized()
Returns the actual normalized steering position (not the setpoint) in the range [-1.0, 1.0]. |
void |
increaseDriveSpeed()
Increases the drive speed (throttle) by the smallest possible increment. |
boolean |
isSteeringEndContactTriggered()
Returns true if the steering end contact is closed, false otherwise. |
boolean |
isSteeringPositionReached()
Returns true if the kart has reached the target steering position, false otherwise. |
void |
removeKartListener(KartListener listener)
Removes the kart listener. |
void |
removeStatusRegisterListener(KartStatusRegisterListener listener)
Removes the given status register listener. |
void |
setControlRegister(KartControlRegister register,
int value)
Sets the given control register to the given value. |
void |
setDriveSpeed(int speed)
Sets the drive speed (throttle) to the given absolute value. |
void |
setDriveSpeedNormalized(float speed)
Sets the drive speed (throttle) to the given normalized value. |
void |
setLed(int index,
boolean on)
Sets the LED at the give index [0,3] to the given value (true=on). |
void |
setSteeringPosition(int position)
Sets the steering position on the kart to the given absolute value. |
void |
setSteeringPositionNormalized(float position)
Sets the steering position on the kart to the given normalized value. |
KartSetup |
setup()
Returns a reference to the kart setup. |
void |
toggleLed(int index)
Toggles the LED at the given index. |
void |
turnSteeringBy(int amount)
Turns the steering position by the given absolute amount of steps, but not further as the left and right end positions. |
void |
turnSteeringNormalizedBy(float amount)
Turns the steering position by the given normalized amount, but not further as the left and right end positions, whereas 1.0 would match the complete steering range. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAXIMAL_SPEED
public static final int MINIMAL_SPEED
Constructor Detail |
---|
public Kart()
public Kart(KartSetup setup)
setup
- Kart setup to apply.Method Detail |
---|
public KartSetup setup()
public void connect(ch.hei.kart.comm.discovery.DiscoveryEntity entity)
entity
- Kart communication entity to connect to, a such entity can be found using
the method startDiscovery() on the class CommunicationSetup.public void disconnect()
public void setDriveSpeed(int speed)
speed
- Absolute drive speed (throttle).public void setDriveSpeedNormalized(float speed)
speed
- Normalized drive speed (throttle).public void increaseDriveSpeed()
public void decreaseDriveSpeed()
public int getDriveSpeed()
public float getDriveSpeedNormalized()
public void setSteeringPosition(int position)
position
- Absolute steering position.public void setSteeringPositionNormalized(float position)
position
- Normalized steering position.public int getSteeringControlPosition()
public float getSteeringControlPositionNormalized()
public void turnSteeringBy(int amount)
amount
- Absolute number of steps to turn.public void turnSteeringNormalizedBy(float amount)
amount
- Normalized amount to turn.public int getSteeringPosition()
public float getSteeringPositionNormalized()
public boolean isSteeringPositionReached()
public boolean isSteeringEndContactTriggered()
public float getBatteryLevel()
public void setLed(int index, boolean on)
index
- LED index [0, 3].on
- If true the LED is set on, if false the LED is set off.public boolean getLed(int index)
index
- LED index [0, 3]
public void toggleLed(int index)
index
- LED index [0, 3]public void setControlRegister(KartControlRegister register, int value)
register
- The register to set.value
- The value to set for the register.KartControlRegister
public int getControlRegister(KartControlRegister register)
register
- The control register to read.
public int getControlRegisterUnsigned(KartControlRegister register)
register
- The control register to read.
public int getStatusRegister(KartStatusRegister register)
register
- The status register to read.
public int getStatusRegisterUnsigned(KartStatusRegister register)
register
- The status register to read.
public void addStatusRegisterListener(KartStatusRegisterListener listener)
listener
- Reference to the listener to add.public void removeStatusRegisterListener(KartStatusRegisterListener listener)
listener
- Reference to the listener to remove.public void addKartListener(KartListener listener)
listener
- Reference to the object implementing the kart listener interface.public void removeKartListener(KartListener listener)
listener
- Reference to the object implementing the kart listener interface to remove.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |