SessionOnTheVirtualWorld

Page Actions

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
  • how to import its code

  • how to create an instance of the TCS3200 class

  • how to switch the LEDs on and off

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
  • spheres

  • cylinders

  • boxes

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.

-- %USERSIG{UliRaich - 2018-04-25}%

Comments

 
I Attachment Action Size Date Who Comment
TCS3200.py.txttxt TCS3200.py.txt manage 10 K 25 Apr 2018 - 11:56 UnknownUser  
TCS3200.pycpyc TCS3200.pyc manage 11 K 25 Apr 2018 - 11:56 UnknownUser  
cylinder1.py.txttxt cylinder1.py.txt manage 210 bytes 25 Apr 2018 - 11:55 UnknownUser  
cylinder2.py.txttxt cylinder2.py.txt manage 198 bytes 25 Apr 2018 - 11:55 UnknownUser  
cylinder3.py.txttxt cylinder3.py.txt manage 198 bytes 25 Apr 2018 - 11:55 UnknownUser  
cylinder4.py.txttxt cylinder4.py.txt manage 317 bytes 25 Apr 2018 - 11:55 UnknownUser  
cylinder5.py.txttxt cylinder5.py.txt manage 598 bytes 25 Apr 2018 - 11:55 UnknownUser  
cylinder6.py.txttxt cylinder6.py.txt manage 947 bytes 25 Apr 2018 - 11:55 UnknownUser  
cylinder7.py.txttxt cylinder7.py.txt manage 711 bytes 25 Apr 2018 - 11:55 UnknownUser  
cylinder8.py.txttxt cylinder8.py.txt manage 712 bytes 25 Apr 2018 - 11:55 UnknownUser  
scene-1.py.txttxt scene-1.py.txt manage 4 K 25 Apr 2018 - 11:56 UnknownUser  
scene.py.txttxt scene.py.txt manage 4 K 25 Apr 2018 - 11:55 UnknownUser  
sceneBak.py.txttxt sceneBak.py.txt manage 3 K 25 Apr 2018 - 11:56 UnknownUser  
scenePC.py.txttxt scenePC.py.txt manage 4 K 25 Apr 2018 - 11:56 UnknownUser  
virtualWorld.py.txttxt virtualWorld.py.txt manage 3 K 25 Apr 2018 - 11:56 UnknownUser  
Topic revision: r1 - 25 Apr 2018, UliRaich