DOC PREVIEW
GT LCC 6310 - Lecture Notes

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1LCC 6310The Computer as an Expressive MediumLecture 21OverviewProgramming conceptsBraitenberg vehicle conceptLook at some vehiclesLook through major code sectionsImplement a sensory fieldAssignment 6Braitenberg VehiclesValentino Braitenberg (http://www.kyb.mpg.de/~braitenb)Professor and former director of the Max Planck Institute for Biological Cybernetics in Tübingen, Germany Book: "Vehicles: Experiments in Synthetic Psychology"Neuro-psychologist interested in how primitive neural structures can give rise to complex behaviorHe developed a simple model of robots with sensors and motors toshow how complex behavior can arise from simple mechanismsWe're interested in his vehicles as a simple autonomous agent framework to play withBuild ecosystems of interacting agents and sensory sourcesVehicleSensory sourceSensorsWheel and motorWires2Vehicle 1One sensor (light sensor) connected directly to one motorWhat will happen in light areas?What will happen in dark areas?Vehicle 1 : simple movementStraight movementWhen in light areas it speeds up, in dark areas it slows down - could be described as being "restless" in light places, but "liking" dark places. Vehicle 2aSensors (light sensors) connected directly to motor on same sideWhat will happen when light is to one side?What will happen when light is directly in front?Vehicle 2a: cowardSensors (light sensors) connected directly to motor on same sideSteers away from sourceCharges source directly in frontRests in darkness3Vehicle 2bSensors connected directly to motor on opposite sideWhat will happen when light is to one side?What will happen when light is directly in front?Vehicle 2b: aggressiveTurns towards sourceand chargesCharges source directly in frontRests in darknessSensors connected directly to motor on opposite sideVehicle 3aSensors connected through an inverter to motor on same sideWhat will happen when light is to one side?What will happen when light is directly in front?----Vehicle 3a: love----Turns towards sourceand restsMoves toward source and restsMoves in darknessSensors connected through an inverter to motor on same side--4Vehicle 3bSensors connected through an inverter to motor on opposite sideWhat will happen when light is to one side?What will happen when light is directly in front?----Vehicle 3b: explorer------Turns away from sourceMoves in darknessRotates away (unless exactly on target)Sensors connected through an inverter to motor on opposite sideClasses in codeVehicle (1)Abstract class, provides template for movement logicSubclassed by vehicles with specific behavior logicsDraws itself and the wheels and the sensorsWheel (2)The flapping things on the vehicleSensor (3)The "eyes" on the vehicle – glow indicates activationCan act as sensors with inverters as wellSource (4)A light source - has a range of influenceSensoryField (5)A collection of light sources whose influence adds upDraws itself and all the light sources in the fieldLet's see this run in Processing…(1)(2)(5)(4)(3)How do we implement all this?This week:We'll begin by creating our sensory field of light sourcesWrite code to implement:Source.javaSensoryField.javaNext week:We'll create the vehicles to move around the sensory fieldWrite code to implement:Vehicle.java (and VehicleCoward.java, VehicleAggressive.java, etc.)Sensor.javaWheel.java5SensoryFieldsThe sensory field is a 2D array of pixels that corresponds to the size of the display. Different light sources change the pixels of the field.Provides a mechanism for summing all the different sources togetherThis is the mechanism for summing different sources togetherupdate() sums the light sources to fill the 2D array of background pixelsupdateGround() turns the 2D array into a PImage that can be displayed, which is faster than drawing out each pixel individuallySensing in the vehicles can thus take place by asking the ground for the summed sense value (rather than by directly asking the sources)SourcesWe'll implement a light sourceThe influence falls off non-linearly farther from the sourcemaxrange determines how far out influence extendsSources only draw the little circle in the middle The light gradient around them is actually in the sensory fielddrawrange toggles drawing of the maxrange circle around sourcesgetValue() is used by the sensory field to sample a light source (to determine how much a light source affects a given pixel)Let's build a class to represent a Source…Source classWhat do we need to store for a Source?What should a Source be able to do?Let's build this class…Source variablesWhat do we need to store for a Source?float x, y; // the positionfloat maxrange; // the radius of influence of this sourceboolean grabbed; // so we can tell if it's being draggedboolean drawrange; // so we know whether to draw the range circle6Source methodsWhat should a Source be able to do?drawMe() // should know how to draw itselfsetLocation() // so that we can move it around after initializationhitTest() // check if this source has been clickedgetValue() // get a sensory reading at a specific pointgetInfluence() // find influence of source at given a distanceLet's fill in some of these methods…hitTestCheck if the source has been clicked at (xhit,yhit)The source is located at coordinates (x,y)boolean hitTest(float xhit, float yhit) {if ((xhit < x+RAD) && (xhit > x-RAD) && (yhit < y+RAD) && (yhit > y-RAD)) {grabbed = true;} else {grabbed = false; }return grabbed;}getValueGet the sensory value of this source at location (tx,ty)The inverse influence is returned when positiveInfluence flag is falsefloat getValue(float tx, float ty, boolean positiveInfluence) {float d = distance(tx,ty,x,y);if (d >= maxrange) {// point is outside the radius of influencereturn ((positiveInfluence) ? 0 : 1);}// non-linear influence based on proximity to sourcefloat f = getInfluence(d, maxrange); // non-linear return ((positiveInfluence) ? f : 1-f);}getInfluenceGet the influence of this source at a radius of r from the sourcermax is the maximum radius of influencefloat getInfluence(float r, float rmax) {// get the ratio between 0-1 of how close r is to the source// (0 when r at range perimeter, 1 when r is at source center)float ratio = (rmax - (float)Math.min(r, rmax)) / rmax;// compute the (non-linear) strength (0-1) based on how close we are. // -- Note: cos(t) ranges from 1 to -1 as t goes from 0 to PI.// -- Want: number from 0-1, so need to scale by 0.5 and shift by 0.5// -- Want: increasing strength closer to source, so


View Full Document

GT LCC 6310 - Lecture Notes

Documents in this Course
Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?