how to program ir sensors in order to detect grayscale and

16
How to program IR sensors in order to detect grayscale and distance © 2021, R2T2 Collaboration

Upload: others

Post on 11-Feb-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

How to program IR sensors in order to detect

grayscale and distance

© 2021, R2T2 Collaboration

1. Create the program shown in the picture2. 1st test: Place your robot on a table with a not dark surface. Send

the program to the robot. Will the robot fall down from the edge of the table?

3. 2nd test: Place your robot on a table with a not dark surface. Send the program to the robot. Will the robot continue to move forward on the black rectangle?

Observation of the Thymio behaviour

?

?

You can find the challenge sheet on the next page

© 2021, R2T2 Collaboration 2

! For the 1st experiment, place your robot on a table with a surface that is not dark. If your tables are dark-coloured, then try this experiment using a piece of white paper taped down along the edge of the table.

We observe the same behaviour of the robot during the tests from the previous page. Thymio moves forward on a «white» surface, but stops on the edge of the

table or on the black rectangle.

STOP

STOP

Observation of the Thymio behaviour

© 2021, R2T2 Collaboration 3

Thymio has infra-red (IR) proximity sensors.

Look carefully at a Thymio sensor. It has two parts!

One part emits IR light and the other detects it.

If the receiver detects IR light, then there is an obstacle in front of the sensor.

Emitter Receiver

The light reaches an obstacle and then reflects back (returns) to the receiver.

How do the Thymio’s distance sensors work?

If the IR light does not reach an obstacle, then no light comes back to the receiver.

© 2021, R2T2 Collaboration 4

Infrared light reflects differently from different surfaces. A white surface reflects much more IR light than a black surface, as with visible light.

Light-coloured surface far from the sensor (less light coming

back)

White surface(a lot of light coming back)

Grey surface(less light coming back)

Black surface(no light coming back)

Black and “no obstacle detection” is the same for the an IR sensor.

Reflection of IR light from different surfaces

A surface closer to the sensor (more light coming back) 5

You can see the effect of how the colour of a surface

changes the data of the ground sensors in the

Aseba Studio. We invite you to connect your robot to a computer and open

Aseba Studio

Thymio ground sensor data

© 2021, R2T2 Collaboration 6

We are using this window in the Aseba Studio

Click on the arrow next to the «prox.ground.delta» to see the

ground sensor data

Place Thymio so that the ground sensors are above the white :

ObserveClick on the «refresh» button to

check the latest data coming from the ground sensors

Sensor data in Aseba Studio

© 2021, R2T2 Collaboration 7

Observe and compare how data of the ground sensors changes in Aseba Studio according to

the colour of a surface

Challenge 1

You can find the challenge sheet on the next page

© 2021, R2T2 Collaboration 8

Place an obstacle in front of a Thymio’s horizontal proximity sensors. Change the distance

between Thymio and an obstacle and observe the data in Aseba

Studio.

(check the variable « prox.horizontal »)

Challenge 2

You can find answers to the challenges 1 and 2 on the next page

© 2021, R2T2 Collaboration 9

Sensor data values decrease when the surface is darker (less light IR is reflected).

The same effect is observed when approaching an obstacle or moving it away from the sensors: the sensors receive less IR light reflected back from an obstacle that is far away.

Answer to Challenges 1 and 2

© 2021, R2T2 Collaboration 10

Adjust the threshold for detecting an event using the slider below the sensors.

If you move the slider to the right, then more light is needed to trigger the action(s).

If you move the slider to the left, then less light is needed to trigger the action(s).

How to set the detection range of the sensors

Apply the same for the proximity horizontal sensors

© 2021, R2T2 Collaboration 11

You can find the Aseba code corresponding to the slider position on the right side of the interface.

How to set the sensitivity of the sensors

Apply the same for the proximity horizontal sensors

© 2021, R2T2 Collaboration 12

Program the robot to move forward until the black-

coloured strip and change the intensity of the yellow-

coloured top LEDs according to the colour of the surface: more intense when it is on white, less intense on grey

and no light on black.

STOP

Challenge 3

You can find the correct answer on the next page

© 2021, R2T2 Collaboration 13

Answer to Challenge 3

© 2021, R2T2 Collaboration 14