Constructor
new LightSensorArray(numSensors, globalPos, relPositions, radiuses, analogOrDigital)
The constructor of the light sensor array class. This creates the
sensors and stores them internally as a composition.
Parameters:
Name | Type | Description |
---|---|---|
numSensors |
number | The number of light sensors |
globalPos |
p5.Vector | The global position of the light sensor array |
relPositions |
Array.<p5.Vector> | The relative positions of the sensors in the array. This ensures that they are transformed in the correct orientation. |
radiuses |
Array.<number> | An array of sensor radiuses |
analogOrDigital |
Array.<Robot.LightSensorType> | Array of LightSensorType showing if the given sensor is an Analog or digital light sensor. |
- Source:
Methods
calcPosMatrix()
calculate the position matrix from the global position and saves this in
this.posMatrix
- Source:
calcRefPosMatrix()
calculate the relative positions as a matrix. Saves the matrix in
this.refPosMatrix
- Source:
draw()
Draw the light sensor array. Colour each sensor independently.
- Source:
getLastSensorVals() → {Array.<number>}
gets the last sensor values from the light sensors
- Source:
Returns:
- the last sensor values
- Type
- Array.<number>
read(room) → {Array.<number>}
read the sensor values in the given room
Parameters:
Name | Type | Description |
---|---|---|
room |
World.Room | The room to probe with the sensors |
- Source:
Returns:
- the current sensor values
- Type
- Array.<number>
setBearing(newBearing)
Sets the bearing of the light sensor array. This also updates the
rotation matrix.
Parameters:
Name | Type | Description |
---|---|---|
newBearing |
number | New bearing in radians |
- Source:
setPos(newPos)
Sets the position of the light sensor array. This recalculates the
position matrix.
Parameters:
Name | Type | Description |
---|---|---|
newPos |
p5.Vector | New position |
- Source:
setRelativePositions(newPositions)
Set's new relative positions of the light sensors
Parameters:
Name | Type | Description |
---|---|---|
newPositions |
Array.<p5.Vector> | new relative positions array |
- Source:
Throws:
-
-
The length of the new positions array should be: numSensors
- Type
- Error
-
-
-
The position of sensor i is not a p5.Vector
- Type
- Error
-
updatePosAndBearing()
update the position and bearing of the light sensor array according to
the position matrix and the rotation matrix.
- Source: