6
Finch Robot Arrays Pepper

Finch Robot Arrays Pepper. Light Sensor getLightSensors() It will return an array of 2 integers with: – Left sensor in 0 – Right sensor in 1 Possible

Embed Size (px)

Citation preview

Page 1: Finch Robot Arrays Pepper. Light Sensor getLightSensors() It will return an array of 2 integers with: – Left sensor in 0 – Right sensor in 1 Possible

Finch Robot Arrays

Pepper

Page 2: Finch Robot Arrays Pepper. Light Sensor getLightSensors() It will return an array of 2 integers with: – Left sensor in 0 – Right sensor in 1 Possible

Light Sensor

• getLightSensors()• It will return an array of 2 integers with:– Left sensor in 0 – Right sensor in 1

• Possible array; Left Right Meaning

80 40 Right eye is getting less light

20 80 Left eye is getting less light

40 40 Both get the same light

Page 3: Finch Robot Arrays Pepper. Light Sensor getLightSensors() It will return an array of 2 integers with: – Left sensor in 0 – Right sensor in 1 Possible

Access Light Sensor array

• Make a variable of integer array type to hold the response:

int[ ] lights ;• Call the getLightSensors() method to retrieve

the array: lights = myFinch.getLightSensors();

• Access the value:–lights[0]; //gets left value–lights[1]; // gets right value

0 1

80 40

Page 4: Finch Robot Arrays Pepper. Light Sensor getLightSensors() It will return an array of 2 integers with: – Left sensor in 0 – Right sensor in 1 Possible

Obstacle Sensor

• getObstacleSensors()• It will return an array of 2 booleans with:– Left sensor in 0 – Right sensor in 1

• Possible array; Left Right Meaning

False true Left side only sees obstacle

True False Right side only sees obstacle

False False No obstacles

True True Both sides see an obstacle

Page 5: Finch Robot Arrays Pepper. Light Sensor getLightSensors() It will return an array of 2 integers with: – Left sensor in 0 – Right sensor in 1 Possible

Access Obstacle Sensor array

• Make a variable of boolean array type to hold the response:

boolean[ ] obs;• Call the getObstacleSensors() method to

retrieve the array: obs= myFinch.getObstacleSensors();

• Access the value:–obs[0]; //gets left value–obs[1]; // gets right value

0 1

80 40

Page 6: Finch Robot Arrays Pepper. Light Sensor getLightSensors() It will return an array of 2 integers with: – Left sensor in 0 – Right sensor in 1 Possible

Summary• Two commands for retrieving sensor array from

the Finch: – getObstacleSensors()– getLightSensors()– Both put left in 0 index and right in 1 index– Obstacle returns boolean and light returns int– Create an array to hold the response

• Int[ ] or boolean[ ] arrayname– Call the method to fill the array setting your array

variable = the method call– Read the result as arrayname[index]