180 likes | 344 Views
IN.1010, IN.0111, IN.0114, IN.1910, IN.0300 Robotics Project E-puck Camera Session 6 – 22 October 2013 Prof. B. Hirsbrunner (beat.hirsbrunner@unifr.ch) Thomas Rouvinez (thomas.rouvinez@unifr.ch). Today. Quick review Goals Refactoring E-puck camera Challenges Final Assignment
E N D
IN.1010, IN.0111, IN.0114, IN.1910, IN.0300 Robotics ProjectE-puck CameraSession 6 – 22 October 2013 Prof. B. Hirsbrunner (beat.hirsbrunner@unifr.ch)Thomas Rouvinez (thomas.rouvinez@unifr.ch)
Today • Quick review • Goals • Refactoring • E-puck camera • Challenges • Final Assignment • Requirements and Rules
Refactoring • Simplify the code • Remove duplications in the code • Remove code which is never called • Rename variables, constants, events, and procedure so their names make more sense
E-puck Camera (1) • A digital camera sees the world through a matrix of pixels • A linear camera only sees a horizontal or vertical line of pixels • In ASEBA, the e-puck camera sees a horizontal line of 60 pixels • Stored as an array 0 59
E-puck Camera (2) • Colors are composed of the primary colors from the RGB color model: • Red • Green • Blue • Generally colors are 8 bit encoded with values ranging from 0 to 255 • The colors in ASEBA are encoded in percentages (%) ranging from 0 to 100
E-puck Camera (3) • Colors of elements in the simulation (in RGB): • White wall: 90%, 90%, 90% • Red buttons: 77%, 20%, 15% • Green blocks: 0%, 50%, 17% • Blue door: 0%, 38%, 61% • Note: The colors of the elements in the physical arena are different (!)
E-Puck Camera (4) • The RGB values of the camera are found in the tables camR, camG and camB. • The value in the brackets corresponds to the color intensity of the pixel in the specified color channel: • camR: camR[0] ... camR[59] • camG: camG[0] ... camG[59] • camB: camB[0] ... camB[59]
Challenge: Loops • Don’t use long loops in the ir_sensors and camera event. Bad solution: var i var cumulateBlue = 0 var average = 0 var foundBlue onevent camera for i in 0:59 do cumulateBlue = cumulateBlue + camB[i] end average = cumulateBlue / 60 if average > 50 then foundBlue = TRUE end
Challenges: Sampling • To get started with camera values in the simulation, you can use sampling: • Only check the camera values in camR[30], camG[30], and camB[30]. • When using simplified sampling techniques, your results are less accurate • Once you have a solution that works, try to make the color detection more robust by using more values and/or using statistical approaches
Simple Color Detection (1) • Simulation example: var foundBlue = FALSE onevent ir_sensors if foundBlue == TRUE then # react to color being found end onevent camera if camR[30] == 0 and camG[30] == 38 and ... then foundBlue = TRUE end
Simple Color Detection (2) • The previous code will only work in the simulation • Color detection in the physical arena will require a more robust approach • One possibility: check if a color value lies within a certain bound: if camR[30] > targetColor - tolerance and camR[30] < targetColor + tolerance and ... then colorFound = TRUEend
Final Assignment • In exercise 6 we ask you to write the code for the final assignment in the simulation • You have 3 weeks to complete the challenge • It is important that you do the exercise carefully and try to anticipate which algorithms will work in the physical arena
Requirements and Rules • Each person has to write their own code for the final assignment in the simulated and physical environment (the code and game strategy can be discussed as a group) • Each person has to write a project report of 10-15 pages using Latex • Each person has to do a 5 minute presentation where he or she presents an interesting and/or tricky aspect of his or her implementation
Next Course • No course in the next two weeks • In the next course on Tuesday, 12 November, we will discuss what is expect from the technical report, the project presentation, and the demo video • We will also discuss the final assignment for the physical arena • On Tuesday 29 October and 5 November presence hours in class instead of lecture will take place