Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of scoreLight_Advanced by
rigidLoop.h@21:bc9b9383f4b6, 2012-05-06 (annotated)
- Committer:
- mbedalvaro
- Date:
- Sun May 06 14:40:19 2012 +0000
- Revision:
- 21:bc9b9383f4b6
- Parent:
- 12:0de9cd2bced5
- Child:
- 24:4e52031a495b
Version working but not optimal for CHI. This is the first day of the setup.
Who changed what in which revision?
User | Revision | Line number | New 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 | 4:f9d364f10335 | 11 | enum RigidLoopMode {SPOT_FOLLOWING, SPOT_BOUNCING, SPOT_TEST}; |
mbedalvaro | 1:a4050fee11f7 | 12 | |
mbedalvaro | 1:a4050fee11f7 | 13 | class rigidLoop : public soundSpot { |
mbedalvaro | 1:a4050fee11f7 | 14 | |
mbedalvaro | 1:a4050fee11f7 | 15 | public: |
mbedalvaro | 1:a4050fee11f7 | 16 | |
mbedalvaro | 1:a4050fee11f7 | 17 | // Constructor and destructor: |
mbedalvaro | 1:a4050fee11f7 | 18 | rigidLoop(); |
mbedalvaro | 1:a4050fee11f7 | 19 | ~rigidLoop(); |
mbedalvaro | 1:a4050fee11f7 | 20 | |
mbedalvaro | 1:a4050fee11f7 | 21 | // instantiation of the virtual methods of the base class (we don't need to append "virtual", but for clarity I do): |
mbedalvaro | 12:0de9cd2bced5 | 22 | void createBlob(int _id, RigidLoopMode _rigidBlobMode, vector2Df _initPos, vector2Df _initSpeed); |
mbedalvaro | 12:0de9cd2bced5 | 23 | virtual void setRegionMotion(float mmix, float mmiy, float mmax, float mmay); // attention: initial position posX and posY should be inside this bounding box... |
mbedalvaro | 1:a4050fee11f7 | 24 | virtual void update(); // update dynamics of the mass loop |
mbedalvaro | 1:a4050fee11f7 | 25 | 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 | 26 | virtual void computeBoundingBox(); |
mbedalvaro | 1:a4050fee11f7 | 27 | virtual void sendDataSpecific(void); |
mbedalvaro | 1:a4050fee11f7 | 28 | |
mbedalvaro | 1:a4050fee11f7 | 29 | // methods that are new to this class (not in base class): |
mbedalvaro | 1:a4050fee11f7 | 30 | void initSizeBlob(int _numPoints); |
mbedalvaro | 1:a4050fee11f7 | 31 | void createLoopFromScafold(void); // this is much simpler than the elastic blob (here, we only need to add a central mass) |
mbedalvaro | 1:a4050fee11f7 | 32 | // void processLoopData(); // not needed, because the loop is rigid. |
mbedalvaro | 1:a4050fee11f7 | 33 | |
mbedalvaro | 1:a4050fee11f7 | 34 | RigidLoopMode updateMode; |
mbedalvaro | 1:a4050fee11f7 | 35 | |
mbedalvaro | 1:a4050fee11f7 | 36 | // 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 | 37 | // int numPoints; // this belongs to soundSpot base class |
mbedalvaro | 1:a4050fee11f7 | 38 | 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 | 39 | |
mbedalvaro | 1:a4050fee11f7 | 40 | // The following are common to all blobs: |
mbedalvaro | 1:a4050fee11f7 | 41 | // float angleCorrectionForceLoop; |
mbedalvaro | 1:a4050fee11f7 | 42 | // vector2D recenteringVectorLoop; |
mbedalvaro | 1:a4050fee11f7 | 43 | // float angleRecenteringVector; // auxiliary variables for sending data (for the recenteringVectorLoop) |
mbedalvaro | 1:a4050fee11f7 | 44 | // float normRecenteringVector; |
mbedalvaro | 1:a4050fee11f7 | 45 | |
mbedalvaro | 1:a4050fee11f7 | 46 | // other modes: |
mbedalvaro | 1:a4050fee11f7 | 47 | bool slidingDirection; // for contour following |
mbedalvaro | 1:a4050fee11f7 | 48 | |
mbedalvaro | 1:a4050fee11f7 | 49 | // numeric parameters: |
mbedalvaro | 1:a4050fee11f7 | 50 | float saccadeRadius; |
mbedalvaro | 1:a4050fee11f7 | 51 | |
mbedalvaro | 7:0df17f3078bc | 52 | // THINGS FOR CONTOUR FOLLOWING: |
mbedalvaro | 7:0df17f3078bc | 53 | float saccadeRadius_initial; // this is for SEARCH MODE (remember initial radius) |
mbedalvaro | 7:0df17f3078bc | 54 | bool justSearched; |
mbedalvaro | 7:0df17f3078bc | 55 | |
mbedalvaro | 7:0df17f3078bc | 56 | |
mbedalvaro | 4:f9d364f10335 | 57 | float rotationAngle; // note: in the future, rotation would be done by the openGL-like renderer |
mbedalvaro | 4:f9d364f10335 | 58 | |
mbedalvaro | 1:a4050fee11f7 | 59 | float massCenter; |
mbedalvaro | 1:a4050fee11f7 | 60 | float dampMotionCenterMass; |
mbedalvaro | 1:a4050fee11f7 | 61 | |
mbedalvaro | 21:bc9b9383f4b6 | 62 | vector2Df gravity; |
mbedalvaro | 21:bc9b9383f4b6 | 63 | |
mbedalvaro | 1:a4050fee11f7 | 64 | float speedContourFollowing; // this is given as a percentage of the radius of the circle |
mbedalvaro | 1:a4050fee11f7 | 65 | float factorBouncingForce; |
mbedalvaro | 1:a4050fee11f7 | 66 | }; |
mbedalvaro | 1:a4050fee11f7 | 67 | |
mbedalvaro | 1:a4050fee11f7 | 68 | #endif |