save loops

Dependencies:   mbed

Committer:
mbedalvaro
Date:
Tue Dec 02 08:29:59 2014 +0000
Revision:
1:3be7b7d050f4
Parent:
0:df6fdd9b99f0
updated

Who changed what in which revision?

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