Class Robi2
- java.lang.Object
-
- org.deepjava.runtime.ppc32.Task
-
- org.deepjava.runtime.mpc555.driver.Robi2
-
- All Implemented Interfaces:
Ippc32
,Actionable
public class Robi2 extends Task
This driver is used for the Robi2. Robi2 is controlled by a MPC555 processor.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static HLC1395Pulsed
distSense
(package private) static Robi2
robi2BackgroundTask
static float
v_max
static float
wheelDiameter
static float
wheelDistance
-
Fields inherited from class org.deepjava.runtime.ppc32.Task
done, firstErr, maxNofTasks, nofActivations, period, safe
-
Fields inherited from interface org.deepjava.runtime.ppc32.Ippc32
CR, CTR, DAR, DEC, DSISR, FPR0, FPR1, FPR10, FPR11, FPR12, FPR13, FPR14, FPR15, FPR16, FPR17, FPR18, FPR19, FPR2, FPR20, FPR21, FPR22, FPR23, FPR24, FPR25, FPR26, FPR27, FPR28, FPR29, FPR3, FPR30, FPR31, FPR4, FPR5, FPR6, FPR7, FPR8, FPR9, FPSCR, LR, MSR, R0, R1, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19, R2, R20, R21, R22, R23, R24, R25, R26, R27, R28, R29, R3, R30, R31, R4, R5, R6, R7, R8, R9, SPR1, SPR18, SPR19, SPR22, SPR26, SPR268, SPR269, SPR27, SPR272, SPR273, SPR274, SPR275, SPR287, SPR8, SPR9, SPRG0, SPRG1, SPRG2, SPRG3, SRR0, SRR1, TBLread, TBUread, XER
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
action()
Background Task.static void
activatePosLEDs()
Enable all three position LEDs (white)static void
deactivatePosLEDs()
Disable all three position LEDs (white)static void
disableAllLEDs()
Turn all LEDs off.static void
drive(int speed)
Set the speed and direction of both drives so that they rotates in the same direction.
The sign define the direction.static void
enableAllLEDs()
static float
getBatteryVoltage()
Returns the voltage of the batterystatic boolean
getCenterLED()
Get the state of the center LED (the blue one).static int
getDistSensorValue(int sensor)
Read the converted value of a chosen distance sensor.static boolean
getHeadPosLED()
Get the state of head position LED (LED16).static boolean
getLeftPosLED()
Get the state of the rear left position LED (LED17).static float
getOrientation()
Returns the orientation of the Robi2 referenced to the orientation of the point of origin.
The point of origin is set, where the Robi2 stood at the start time of the program or resetPos has been called.static boolean
getPatternLED(int r, int c)
Set the state of the chosen pattern LED.static float
getPosX()
Returns the x position of the Robi2 referenced to the point of origin.
The point of origin is set, where the Robi2 stood at the start time of the program or resetPos has been called.static float
getPosY()
Returns the x position of the Robi2 referenced to the point of origin.
The point of origin is set, where the Robi2 stood at the start time of the program or resetPos has been called.static boolean
getRightPosLED()
Get the state of the rear right position LED (LED18).static float
getRobiSpeed()
Returns the current speed of the Robi in his drive direction.static float
getSpeedX()
Returns the current speed of the Robi2 in X-direction.static float
getSpeedY()
Returns the current speed of the Robi2 in Y-direction.static int
getSwitchValue()
Reads the position of the HEX-switch.static void
resetPos()
Reset the position.
The current position is the new point of origin.static void
setCenterLED(boolean state)
Set the state of the center LED (the blue one).static void
setDriveSpeedEqual(int speed)
Deprecated.static void
setDrivesSpeedAntidormic(int speed)
Deprecated.static void
setHeadPosLED(boolean state)
Set the state of head position LED (LED16).static void
setLeftDriveSpeed(float speed)
Sets the speed of the left drive in meter per second [m/s].
The sign define the direction.static void
setLeftDriveSpeed(int speed)
Sets the speed of the left drive in percent.
The sign define the direction.static void
setLeftPosLED(boolean state)
Set the state of the rear left position LED (LED17).static void
setPatternLED(int r, int c, boolean state)
Set the state of the chosen pattern LED.static void
setPosLEDs(boolean state)
Set the state for all three position LEDs (the white ones).static void
setRightDriveSpeed(float speed)
Sets the speed of the right drive in meter per second [m/s].
The sign define the direction.static void
setRightDriveSpeed(int speed)
Sets the speed of the right drive in percent.
The sign define the direction.static void
setRightPosLED(boolean state)
Set the state of the rear right position LED (LED18).static void
stop()
Stop both drivesstatic void
turn(int speed)
Set the speed and direction of both drives so that they rotates antidormic.
The sign define the direction of the rotation of the Robi2.
A positive value turns clockwise, a negative value turns counterclockwise.
-
-
-
Field Detail
-
robi2BackgroundTask
static Robi2 robi2BackgroundTask
-
wheelDiameter
public static final float wheelDiameter
- See Also:
- Constant Field Values
-
wheelDistance
public static final float wheelDistance
- See Also:
- Constant Field Values
-
v_max
public static final float v_max
- See Also:
- Constant Field Values
-
distSense
static HLC1395Pulsed distSense
-
-
Method Detail
-
action
public void action()
Background Task.Do not call this method!
- Specified by:
action
in interfaceActionable
- Overrides:
action
in classTask
-
activatePosLEDs
public static void activatePosLEDs()
Enable all three position LEDs (white)
-
deactivatePosLEDs
public static void deactivatePosLEDs()
Disable all three position LEDs (white)
-
setPosLEDs
public static void setPosLEDs(boolean state)
Set the state for all three position LEDs (the white ones). This method is useful for toggling the positions LEDs.- Parameters:
state
- the state of the LED (true = on, false = off)
-
setHeadPosLED
public static void setHeadPosLED(boolean state)
Set the state of head position LED (LED16).- Parameters:
state
- the state of LED16 (true = on, false = off)
-
getHeadPosLED
public static boolean getHeadPosLED()
Get the state of head position LED (LED16).- Returns:
- the state of LED16 (true = on, false = off)
-
setLeftPosLED
public static void setLeftPosLED(boolean state)
Set the state of the rear left position LED (LED17).- Parameters:
state
- the state of LED17 (true = on, false = off)
-
getLeftPosLED
public static boolean getLeftPosLED()
Get the state of the rear left position LED (LED17).- Returns:
- the state of LED17. (true = on, false = off)
-
setRightPosLED
public static void setRightPosLED(boolean state)
Set the state of the rear right position LED (LED18).- Parameters:
state
- the state of LED18 (true = on, false = off)
-
getRightPosLED
public static boolean getRightPosLED()
Get the state of the rear right position LED (LED18).- Returns:
- the state of LED18 (true = off, false = on)
-
setPatternLED
public static void setPatternLED(int r, int c, boolean state)
Set the state of the chosen pattern LED. Pattern LEDs are the red ones. Examples:setPatternLED(0,0,true)
turns LED11 onsetPatternLED(3,2,false)
turns LED13 off
- Parameters:
r
- row of the LED(range 0..3);c
- column of the LED (range 0..2)state
- the state of the LED (true = on, false = off)
-
getPatternLED
public static boolean getPatternLED(int r, int c)
Set the state of the chosen pattern LED. Pattern LEDs are the red ones. Examples:getPatternLED(0,0)
gets the state of LED11getPatternLED(3,2)
gets the state of LED13
- Parameters:
r
- row of the LED (range 0..3);c
- column of the LED (range 0..2)- Returns:
- the state of the LED (true = on, false = off)
-
setCenterLED
public static void setCenterLED(boolean state)
Set the state of the center LED (the blue one).- Parameters:
state
- the state of the blue center LED (true = on, false = off)
-
getCenterLED
public static boolean getCenterLED()
Get the state of the center LED (the blue one).- Returns:
- the state of the blue center LED (true = on, false = off)
-
enableAllLEDs
public static void enableAllLEDs()
-
disableAllLEDs
public static void disableAllLEDs()
Turn all LEDs off.
-
getSwitchValue
public static int getSwitchValue()
Reads the position of the HEX-switch.- Returns:
- the position/value of the HEX-switch
-
getDistSensorValue
public static int getDistSensorValue(int sensor)
Read the converted value of a chosen distance sensor.- Parameters:
sensor
- the sensor which should be read (range 0..15)- Returns:
- converted value (range 0..1023), -1 = failed.
-
getPosX
public static float getPosX()
Returns the x position of the Robi2 referenced to the point of origin.
The point of origin is set, where the Robi2 stood at the start time of the program or resetPos has been called.- Returns:
- the difference of the x-coordinate to the point of origin
-
getPosY
public static float getPosY()
Returns the x position of the Robi2 referenced to the point of origin.
The point of origin is set, where the Robi2 stood at the start time of the program or resetPos has been called.- Returns:
- the difference of the y-coordinate to the point of origin
-
getOrientation
public static float getOrientation()
Returns the orientation of the Robi2 referenced to the orientation of the point of origin.
The point of origin is set, where the Robi2 stood at the start time of the program or resetPos has been called.- Returns:
- the difference of the orientation to the point of origin
-
getSpeedX
public static float getSpeedX()
Returns the current speed of the Robi2 in X-direction.- Returns:
- speed
-
getSpeedY
public static float getSpeedY()
Returns the current speed of the Robi2 in Y-direction.- Returns:
- speed
-
getRobiSpeed
public static float getRobiSpeed()
Returns the current speed of the Robi in his drive direction. The given value is in meter per second [m/s].- Returns:
- speed in meter per second [m/s]
-
resetPos
public static void resetPos()
Reset the position.
The current position is the new point of origin.
-
setLeftDriveSpeed
public static void setLeftDriveSpeed(int speed)
Sets the speed of the left drive in percent.
The sign define the direction. A negative value for backwards and a positive value for forward.- Parameters:
speed
- range: -100..100
-
setLeftDriveSpeed
public static void setLeftDriveSpeed(float speed)
Sets the speed of the left drive in meter per second [m/s].
The sign define the direction. A negative value for backwards and a positive value for forward.- Parameters:
speed
- range: -v_max...v_max
-
setRightDriveSpeed
public static void setRightDriveSpeed(int speed)
Sets the speed of the right drive in percent.
The sign define the direction. A negative value for backwards and a positive value for forward.- Parameters:
speed
- range -100..100
-
setRightDriveSpeed
public static void setRightDriveSpeed(float speed)
Sets the speed of the right drive in meter per second [m/s].
The sign define the direction. A negative value for backwards and a positive value for forward.- Parameters:
speed
- range: -v_max...v_max
-
drive
public static void drive(int speed)
Set the speed and direction of both drives so that they rotates in the same direction.
The sign define the direction. A negative value for backwards and a positive value for forward.- Parameters:
speed
- range: -100..100
-
setDriveSpeedEqual
public static void setDriveSpeedEqual(int speed)
Deprecated.Set the speed and direction of both drives so that they rotates in the same direction. The sign define the direction. A negative value for backwards and a positive value for forward.- Parameters:
speed
- range: -100..100
-
turn
public static void turn(int speed)
Set the speed and direction of both drives so that they rotates antidormic.
The sign define the direction of the rotation of the Robi2.
A positive value turns clockwise, a negative value turns counterclockwise.- Parameters:
speed
- range: -100..100
-
setDrivesSpeedAntidormic
public static void setDrivesSpeedAntidormic(int speed)
Deprecated.Set the speed and direction of both drives so that they rotates antidormic. The sign define the direction of the rotation of the Robi2. A positive value turns clockwise, a negative value turns counterclockwise.- Parameters:
speed
- range: -100..100
-
stop
public static void stop()
Stop both drives
-
getBatteryVoltage
public static float getBatteryVoltage()
Returns the voltage of the battery- Returns:
- voltage
-
-