META TOPICPARENT |
name="Exercises" |
Reading the Color Sensor and creating the virtual world
Introduction
Reading the color sensor is rather tricky but we are lucky to find a ready made module that contains the access code.
Exercise Session 3
The TCS3200 Color sensor
1. Connecting the color sensor and switching the LEDs
Connect the color sensor according to the following table:
Read the code of the TCS3200 class and try to figure out
2. Calibration and and color readout
Write a program to calibrate the sensor (find black and white color) and read the rgb color of a paper. Print the rgb value
3. Color sensor and rgb LED
Extend exercise 2 to display the paper color on the rgb LED
The virtual world
1. Creating a few 3D objects
Before creating 3D objects you must import the visual module:
from visual import *
Now you you can create 3D objects like
Try this and play with parameters like position, size and colors. Try what happens if press the second or third mouse button and you move the mouse.
2. Create a scene with just a cylinder and a sphere
-
Create a scene with just a cylinder with default options.
-
Move the cylinder left and change its radius and length
-
Add a sphere with default options
-
Change the sphere size and color
3. Create a scene that corresponds to our setup
Create a scene that represents our hardware setup:
-
The distance sensor
-
the color sensor
-
the paper
4. Connect the virtual world to the real world
Read the paper color from the color sensor and modify the color of the thin box representing the paper sheet.
Read the distance between the paper and the distance sensor and make sure this distance is reflected in your virtual world model.
-- Uli Raich - 2018-04-25
Comments
META FILEATTACHMENT |
attachment="TCS3200.py.txt" attr="" comment="" date="1524657367" name="TCS3200.py.txt" path="TCS3200.py.txt" size="11104" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="cylinder1.py.txt" attr="" comment="" date="1524657323" name="cylinder1.py.txt" path="cylinder1.py.txt" size="210" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="cylinder2.py.txt" attr="" comment="" date="1524657323" name="cylinder2.py.txt" path="cylinder2.py.txt" size="198" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="cylinder3.py.txt" attr="" comment="" date="1524657323" name="cylinder3.py.txt" path="cylinder3.py.txt" size="198" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="cylinder4.py.txt" attr="" comment="" date="1524657323" name="cylinder4.py.txt" path="cylinder4.py.txt" size="317" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="cylinder5.py.txt" attr="" comment="" date="1524657323" name="cylinder5.py.txt" path="cylinder5.py.txt" size="598" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="cylinder6.py.txt" attr="" comment="" date="1524657323" name="cylinder6.py.txt" path="cylinder6.py.txt" size="947" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="cylinder7.py.txt" attr="" comment="" date="1524657323" name="cylinder7.py.txt" path="cylinder7.py.txt" size="711" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="cylinder8.py.txt" attr="" comment="" date="1524657323" name="cylinder8.py.txt" path="cylinder8.py.txt" size="712" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="scene.py.txt" attr="" comment="" date="1524657323" name="scene.py.txt" path="scene.py.txt" size="4286" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="scene-1.py.txt" attr="" comment="" date="1524657366" name="scene-1.py.txt" path="scene-1.py.txt" size="4713" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="sceneBak.py.txt" attr="" comment="" date="1524657366" name="sceneBak.py.txt" path="sceneBak.py.txt" size="3559" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="scenePC.py.txt" attr="" comment="" date="1524657367" name="scenePC.py.txt" path="scenePC.py.txt" size="4403" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="TCS3200.pyc" attr="" comment="" date="1524657367" name="TCS3200.pyc" path="TCS3200.pyc" size="11305" user="UliRaich" version="1" |
META FILEATTACHMENT |
attachment="virtualWorld.py.txt" attr="" comment="" date="1524657367" name="virtualWorld.py.txt" path="virtualWorld.py.txt" size="4069" user="UliRaich" version="1" |
|