just a test

Dependencies:   mbed

Fork of scoreLight_Advanced by Alvaro Cassinelli

Committer:
mbedalvaro
Date:
Mon Nov 05 06:08:35 2012 +0000
Revision:
33:43e8bc451ef0
Parent:
32:52273c3291fe
Child:
39:7c54b6bca0e2
added resizing functions, as well as better control on the thresholding modes

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 33:43e8bc451ef0 31 virtual void setSpeed(float speed);
mbedalvaro 33:43e8bc451ef0 32 virtual void setSize(float size);
mbedalvaro 24:4e52031a495b 33 virtual void speedFactor(float speedfactor);
mbedalvaro 32:52273c3291fe 34 virtual void sizeFactor(float sizeFactor);
mbedalvaro 31:5f039cbddee8 35
mbedalvaro 31:5f039cbddee8 36 virtual void explosion(); // not very nice programming style, it should be a MODE instead or something like that.
mbedalvaro 31:5f039cbddee8 37 virtual vector2Df getCenter();
mbedalvaro 31:5f039cbddee8 38 virtual void resetPositionSpeed() {centerMass.setInitialCondition(startCenter, startSpeed);};
mbedalvaro 31:5f039cbddee8 39 virtual void setPositionSpeed(vector2Df _pos, vector2Df _spe) {centerMass.setInitialCondition(_pos, _spe);};
mbedalvaro 31:5f039cbddee8 40
mbedalvaro 31:5f039cbddee8 41
mbedalvaro 1:a4050fee11f7 42 // methods that are new to this class (not in base class):
mbedalvaro 1:a4050fee11f7 43 void initSizeBlob(int _numPoints);
mbedalvaro 1:a4050fee11f7 44 void createLoopFromScafold(void); // this is much simpler than the elastic blob (here, we only need to add a central mass)
mbedalvaro 1:a4050fee11f7 45 // void processLoopData(); // not needed, because the loop is rigid.
mbedalvaro 1:a4050fee11f7 46
mbedalvaro 1:a4050fee11f7 47 RigidLoopMode updateMode;
mbedalvaro 1:a4050fee11f7 48
mbedalvaro 1:a4050fee11f7 49 // 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 50 // int numPoints; // this belongs to soundSpot base class
mbedalvaro 1:a4050fee11f7 51 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 52
mbedalvaro 1:a4050fee11f7 53 // The following are common to all blobs:
mbedalvaro 1:a4050fee11f7 54 // float angleCorrectionForceLoop;
mbedalvaro 1:a4050fee11f7 55 // vector2D recenteringVectorLoop;
mbedalvaro 1:a4050fee11f7 56 // float angleRecenteringVector; // auxiliary variables for sending data (for the recenteringVectorLoop)
mbedalvaro 1:a4050fee11f7 57 // float normRecenteringVector;
mbedalvaro 1:a4050fee11f7 58
mbedalvaro 1:a4050fee11f7 59 // other modes:
mbedalvaro 1:a4050fee11f7 60 bool slidingDirection; // for contour following
mbedalvaro 1:a4050fee11f7 61
mbedalvaro 1:a4050fee11f7 62 // numeric parameters:
mbedalvaro 1:a4050fee11f7 63 float saccadeRadius;
mbedalvaro 1:a4050fee11f7 64
mbedalvaro 7:0df17f3078bc 65 // THINGS FOR CONTOUR FOLLOWING:
mbedalvaro 7:0df17f3078bc 66 float saccadeRadius_initial; // this is for SEARCH MODE (remember initial radius)
mbedalvaro 7:0df17f3078bc 67 bool justSearched;
mbedalvaro 7:0df17f3078bc 68
mbedalvaro 7:0df17f3078bc 69
mbedalvaro 4:f9d364f10335 70 float rotationAngle; // note: in the future, rotation would be done by the openGL-like renderer
mbedalvaro 4:f9d364f10335 71
mbedalvaro 1:a4050fee11f7 72 float massCenter;
mbedalvaro 1:a4050fee11f7 73 float dampMotionCenterMass;
mbedalvaro 25:74cb85b85fd2 74
mbedalvaro 21:bc9b9383f4b6 75
mbedalvaro 1:a4050fee11f7 76 float speedContourFollowing; // this is given as a percentage of the radius of the circle
mbedalvaro 32:52273c3291fe 77 float factorBouncingForce; // spring force when penetrating on dark zone (used by SPOT_BOUNCING)
mbedalvaro 32:52273c3291fe 78 float factorAbsorptionShock; // factor speed damping when bouncing on dark zone (used in SPOT_BOUNCING_FACTOR)
mbedalvaro 1:a4050fee11f7 79 };
mbedalvaro 1:a4050fee11f7 80
mbedalvaro 1:a4050fee11f7 81 #endif