just a test

Dependencies:   mbed

Fork of scoreLight_Advanced by Alvaro Cassinelli

Committer:
mbedalvaro
Date:
Mon Oct 29 14:28:47 2012 +0000
Revision:
32:52273c3291fe
Parent:
31:5f039cbddee8
Child:
33:43e8bc451ef0
code for Tokyo design week (starting with two colored following spots, and NO standby mode)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedalvaro 1:a4050fee11f7 1 #ifndef RIGID_LOOP
mbedalvaro 1:a4050fee11f7 2 #define RIGID_LOOP
mbedalvaro 1:a4050fee11f7 3
mbedalvaro 1:a4050fee11f7 4 // Include the basic objects to create the loop
mbedalvaro 1:a4050fee11f7 5 #include "soundSpot.h"
mbedalvaro 1:a4050fee11f7 6 #include "classPointMass.h" // this may be used to move the center of the RIGID loop in dynamically "real" ways
mbedalvaro 1:a4050fee11f7 7 #include "classSpring.h" // same remark than above
mbedalvaro 1:a4050fee11f7 8
mbedalvaro 1:a4050fee11f7 9 using namespace std;
mbedalvaro 1:a4050fee11f7 10
mbedalvaro 32:52273c3291fe 11 enum RigidLoopMode {SPOT_FOLLOWING, SPOT_GHOST, SPOT_PACMAN, SPOT_AIR_HOCKEY, SPOT_LORENTZ_FORCE,
mbedalvaro 32:52273c3291fe 12 SPOT_BOUNCING, SPOT_BOUNCING_FACTOR,
mbedalvaro 31:5f039cbddee8 13 SPOT_TEST, SPOT_TRACK, SPOT_TRACK_DOT,
mbedalvaro 31:5f039cbddee8 14 EXPLOSION};
mbedalvaro 1:a4050fee11f7 15
mbedalvaro 1:a4050fee11f7 16 class rigidLoop : public soundSpot {
mbedalvaro 1:a4050fee11f7 17
mbedalvaro 1:a4050fee11f7 18 public:
mbedalvaro 1:a4050fee11f7 19
mbedalvaro 1:a4050fee11f7 20 // Constructor and destructor:
mbedalvaro 1:a4050fee11f7 21 rigidLoop();
mbedalvaro 1:a4050fee11f7 22 ~rigidLoop();
mbedalvaro 1:a4050fee11f7 23
mbedalvaro 1:a4050fee11f7 24 // instantiation of the virtual methods of the base class (we don't need to append "virtual", but for clarity I do):
mbedalvaro 12:0de9cd2bced5 25 void createBlob(int _id, RigidLoopMode _rigidBlobMode, vector2Df _initPos, vector2Df _initSpeed);
mbedalvaro 12:0de9cd2bced5 26 virtual void setRegionMotion(float mmix, float mmiy, float mmax, float mmay); // attention: initial position posX and posY should be inside this bounding box...
mbedalvaro 31:5f039cbddee8 27 virtual void update(vector2Df referencePos); // update dynamics of the mass loop
mbedalvaro 1:a4050fee11f7 28 virtual void draw(void); // draw the blob (renders on the laser trajectory object lsdTrajectory from the base class, using the openGL laser renderer - not yet done).
mbedalvaro 1:a4050fee11f7 29 virtual void computeBoundingBox();
mbedalvaro 1:a4050fee11f7 30 virtual void sendDataSpecific(void);
mbedalvaro 24:4e52031a495b 31 virtual void speedFactor(float speedfactor);
mbedalvaro 32:52273c3291fe 32 virtual void sizeFactor(float sizeFactor);
mbedalvaro 31:5f039cbddee8 33
mbedalvaro 31:5f039cbddee8 34 virtual void explosion(); // not very nice programming style, it should be a MODE instead or something like that.
mbedalvaro 31:5f039cbddee8 35 virtual vector2Df getCenter();
mbedalvaro 31:5f039cbddee8 36 virtual void resetPositionSpeed() {centerMass.setInitialCondition(startCenter, startSpeed);};
mbedalvaro 31:5f039cbddee8 37 virtual void setPositionSpeed(vector2Df _pos, vector2Df _spe) {centerMass.setInitialCondition(_pos, _spe);};
mbedalvaro 31:5f039cbddee8 38
mbedalvaro 31:5f039cbddee8 39
mbedalvaro 1:a4050fee11f7 40 // methods that are new to this class (not in base class):
mbedalvaro 1:a4050fee11f7 41 void initSizeBlob(int _numPoints);
mbedalvaro 1:a4050fee11f7 42 void createLoopFromScafold(void); // this is much simpler than the elastic blob (here, we only need to add a central mass)
mbedalvaro 1:a4050fee11f7 43 // void processLoopData(); // not needed, because the loop is rigid.
mbedalvaro 1:a4050fee11f7 44
mbedalvaro 1:a4050fee11f7 45 RigidLoopMode updateMode;
mbedalvaro 1:a4050fee11f7 46
mbedalvaro 1:a4050fee11f7 47 // The number of points in the loop (in this case, is just the number of points in the scaffold, as well as the number of points in the lsdTrajectory)
mbedalvaro 12:0de9cd2bced5 48 // int numPoints; // this belongs to soundSpot base class
mbedalvaro 1:a4050fee11f7 49 pointMass centerMass; // this is the center of the rigidLoop. Note that it can have mass or not, this will depend on the RigidLoopMode
mbedalvaro 1:a4050fee11f7 50
mbedalvaro 1:a4050fee11f7 51 // The following are common to all blobs:
mbedalvaro 1:a4050fee11f7 52 // float angleCorrectionForceLoop;
mbedalvaro 1:a4050fee11f7 53 // vector2D recenteringVectorLoop;
mbedalvaro 1:a4050fee11f7 54 // float angleRecenteringVector; // auxiliary variables for sending data (for the recenteringVectorLoop)
mbedalvaro 1:a4050fee11f7 55 // float normRecenteringVector;
mbedalvaro 1:a4050fee11f7 56
mbedalvaro 1:a4050fee11f7 57 // other modes:
mbedalvaro 1:a4050fee11f7 58 bool slidingDirection; // for contour following
mbedalvaro 1:a4050fee11f7 59
mbedalvaro 1:a4050fee11f7 60 // numeric parameters:
mbedalvaro 1:a4050fee11f7 61 float saccadeRadius;
mbedalvaro 1:a4050fee11f7 62
mbedalvaro 7:0df17f3078bc 63 // THINGS FOR CONTOUR FOLLOWING:
mbedalvaro 7:0df17f3078bc 64 float saccadeRadius_initial; // this is for SEARCH MODE (remember initial radius)
mbedalvaro 7:0df17f3078bc 65 bool justSearched;
mbedalvaro 7:0df17f3078bc 66
mbedalvaro 7:0df17f3078bc 67
mbedalvaro 4:f9d364f10335 68 float rotationAngle; // note: in the future, rotation would be done by the openGL-like renderer
mbedalvaro 4:f9d364f10335 69
mbedalvaro 1:a4050fee11f7 70 float massCenter;
mbedalvaro 1:a4050fee11f7 71 float dampMotionCenterMass;
mbedalvaro 25:74cb85b85fd2 72
mbedalvaro 21:bc9b9383f4b6 73
mbedalvaro 1:a4050fee11f7 74 float speedContourFollowing; // this is given as a percentage of the radius of the circle
mbedalvaro 32:52273c3291fe 75 float factorBouncingForce; // spring force when penetrating on dark zone (used by SPOT_BOUNCING)
mbedalvaro 32:52273c3291fe 76 float factorAbsorptionShock; // factor speed damping when bouncing on dark zone (used in SPOT_BOUNCING_FACTOR)
mbedalvaro 1:a4050fee11f7 77 };
mbedalvaro 1:a4050fee11f7 78
mbedalvaro 1:a4050fee11f7 79 #endif