sonar sensor is working in the version of code but the reading are not correct
Dependencies: C12832 Pulse RangeFinder Servo mbed rtos
Fork of Team_Sprint2 by
Revision 7:24d62ef1ed34, committed 2015-03-23
- Comitter:
- Soldier7
- Date:
- Mon Mar 23 18:07:16 2015 +0000
- Parent:
- 4:70090f3b1f07
- Child:
- 8:fe434a018d96
- Commit message:
- Started up-down servo control. Not working. Readme added.
Changed in this revision
README.txt | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.txt Mon Mar 23 18:07:16 2015 +0000 @@ -0,0 +1,27 @@ += Issues: = + +* There are mainly two options to handle the camera. Detached from the lamp or attached to the lamp head. + The algorithm for the two, are very different therefore we have to consider it as soon as possible. + The following evaluation is about the detached one if we go with it. + += The follwoing devices we should handle: = + +* Sonar sensor. We have to specify a working range where the detectable face can appear and should be followed. + This range approx. 70-250cm which have to be calibrated at the build time. + The working range data should be converted to between 0 and 1 value to easier manageable. + +* Camera. From the camera we are getting a horizontal and a vertical value of the tracked face from openCV to mbed, + which is the ratio value of the camera resolution between 0 and 1. + But because this is the position of the middle of the square around the face, it never 0 or 1, but around 0.1 - 0.9. + +* Pan servo. The pan servo should simply follow the face provided by the horizontal position. + +* Tilt servo. The tilt servo mainly similar with the pan, but it should be modified according to the neccessary + up-down movement. See the description below. + +* Up-down servo. The up-down servo should work together with the tilt one. There are many solution could be develop. + The following one is one of them. + If the distance of the face is close to the minimum, then the vertical movement should be mostly followed + by the up-down servo. If the face goes below or above the minimum-maximum position of the up-down servo, + then the out of range movement should be followed by the tilt servo. + As long as the face goes far, it should be more followed by the tilt servo and less with the up-down.
--- a/main.cpp Thu Mar 12 19:57:41 2015 +0000 +++ b/main.cpp Mon Mar 23 18:07:16 2015 +0000 @@ -2,9 +2,10 @@ #include "rtos.h" #include "Servo.h" #include "C12832.h" -Servo s1(p21); -Servo s2(p22); +//Servo sPan(p21); +Servo sTilt(p22); Serial pc(USBTX, USBRX); +Servo sVert(p21); // temporary assigned 21 for testing Mutex mutexIn; Mutex mutexOut; @@ -57,10 +58,13 @@ while (true) { mutexIn.lock(); // The control code will come here - if (corHoriz[1]=='1') - s1 = s1 + 0.25; - if (corHoriz[1]=='2') - s1 = s1 - 0.25; +// if (corHoriz[1]=='1') +// s1 = s1 + 0.25; +// if (corHoriz[1]=='2') +// s1 = s1 - 0.25; + if (corVert > .5) { // check if face is below the half of the camera view + if (outVert > .5) { // check if lamp head is facing down + sVert = ; // moves lamp down by the fraction of the difference from the middle mutexIn.unlock(); Thread::wait(25); }