Hormone for optimizing COT

Dependents:   TurtleBot_v01 TurtleBot_with_AHS

Committer:
worasuchad
Date:
Sun Aug 19 06:28:06 2018 +0000
Revision:
1:43249c4dae57
Parent:
0:df6e371d8665
Child:
2:6da425fac1f7
hormone experiment version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
worasuchad 0:df6e371d8665 1 #include "hormone.h"
worasuchad 0:df6e371d8665 2 #include "mbed.h"
worasuchad 0:df6e371d8665 3
worasuchad 0:df6e371d8665 4 /*------------------------< Function comment >------------------------*/
worasuchad 0:df6e371d8665 5 /* NAME : constructor */
worasuchad 0:df6e371d8665 6 /* PARAMETERS : - */
worasuchad 0:df6e371d8665 7 /* RETURN VALUE : - */
worasuchad 0:df6e371d8665 8 /* DESCRIPTION : - */
worasuchad 0:df6e371d8665 9 /*--------------------------------------------------------------------*/
worasuchad 0:df6e371d8665 10 hormone::hormone()
worasuchad 0:df6e371d8665 11 {
worasuchad 0:df6e371d8665 12 upDegree = 45.00; downDegree = 95.00;
worasuchad 0:df6e371d8665 13 cgUp = 45.00; cgDown = 95;
worasuchad 1:43249c4dae57 14 cgUpPrev = 0.6; // hr = 45
worasuchad 1:43249c4dae57 15 cgDownPrev = 0.5; // hr = 95
worasuchad 0:df6e371d8665 16 upPreProc = 0.0; downPreProc = 0.0;
worasuchad 0:df6e371d8665 17 }
worasuchad 0:df6e371d8665 18
worasuchad 0:df6e371d8665 19 /*------------------------< Function comment >------------------------*/
worasuchad 0:df6e371d8665 20 /* NAME : hormone concentration */
worasuchad 0:df6e371d8665 21 /* PARAMETERS : - */
worasuchad 0:df6e371d8665 22 /* RETURN VALUE : - */
worasuchad 0:df6e371d8665 23 /* DESCRIPTION : - */
worasuchad 0:df6e371d8665 24 /*--------------------------------------------------------------------*/
worasuchad 0:df6e371d8665 25 float hormone::upHG(const float G2,const float G4 )
worasuchad 0:df6e371d8665 26 {
worasuchad 0:df6e371d8665 27
worasuchad 0:df6e371d8665 28 upPreProc = (G2 + G4) / 2;
worasuchad 0:df6e371d8665 29
worasuchad 0:df6e371d8665 30 // hormone gland //
worasuchad 0:df6e371d8665 31 cgUp = tanh( (0.7f * upPreProc) + (0.3f * cgUpPrev) );
worasuchad 0:df6e371d8665 32 cgUpPrev = cgUp;
worasuchad 0:df6e371d8665 33
worasuchad 0:df6e371d8665 34 return 75.00f * cgUp;
worasuchad 1:43249c4dae57 35
worasuchad 1:43249c4dae57 36 //return 75.00f;
worasuchad 0:df6e371d8665 37 }
worasuchad 0:df6e371d8665 38
worasuchad 0:df6e371d8665 39
worasuchad 0:df6e371d8665 40 /*------------------------< Function comment >------------------------*/
worasuchad 0:df6e371d8665 41 /* NAME : hormone concentration for servo down */
worasuchad 0:df6e371d8665 42 /* PARAMETERS : - */
worasuchad 0:df6e371d8665 43 /* RETURN VALUE : - */
worasuchad 0:df6e371d8665 44 /* DESCRIPTION : - */
worasuchad 0:df6e371d8665 45 /*--------------------------------------------------------------------*/
worasuchad 0:df6e371d8665 46 float hormone::downHG(const float G2,const float G3 )
worasuchad 0:df6e371d8665 47 {
worasuchad 0:df6e371d8665 48
worasuchad 0:df6e371d8665 49 downPreProc = (G2 + G3) / 2;
worasuchad 0:df6e371d8665 50
worasuchad 0:df6e371d8665 51 // hormone gland //
worasuchad 0:df6e371d8665 52 cgDown = tanh( (0.3f * downPreProc) + (0.5f * cgDownPrev) );
worasuchad 0:df6e371d8665 53 cgDownPrev = cgDown;
worasuchad 0:df6e371d8665 54
worasuchad 1:43249c4dae57 55 return (-25.00f * cgDown) + 107.50f;
worasuchad 1:43249c4dae57 56
worasuchad 1:43249c4dae57 57 //return 90.00f;
worasuchad 0:df6e371d8665 58 }
worasuchad 0:df6e371d8665 59
worasuchad 0:df6e371d8665 60 /*------------------------< Function comment >------------------------*/
worasuchad 0:df6e371d8665 61 /* NAME : hormone receiver for servo up */
worasuchad 0:df6e371d8665 62 /* PARAMETERS : - */
worasuchad 0:df6e371d8665 63 /* RETURN VALUE : - */
worasuchad 0:df6e371d8665 64 /* DESCRIPTION : - */
worasuchad 0:df6e371d8665 65 /*--------------------------------------------------------------------*/
worasuchad 0:df6e371d8665 66 float hormone::hormoneRecUp(const float upDeg)
worasuchad 0:df6e371d8665 67 {
worasuchad 0:df6e371d8665 68 upDegree = upDeg;
worasuchad 0:df6e371d8665 69
worasuchad 0:df6e371d8665 70 if(upDegree < 45.00f )
worasuchad 0:df6e371d8665 71 {
worasuchad 0:df6e371d8665 72 upDegree = 45.00f;
worasuchad 0:df6e371d8665 73 }
worasuchad 0:df6e371d8665 74 else if(upDegree > 75.00f)
worasuchad 0:df6e371d8665 75 {
worasuchad 0:df6e371d8665 76 upDegree = 75.00f;
worasuchad 0:df6e371d8665 77 }
worasuchad 0:df6e371d8665 78
worasuchad 0:df6e371d8665 79 return upDegree;
worasuchad 0:df6e371d8665 80 }
worasuchad 0:df6e371d8665 81
worasuchad 0:df6e371d8665 82 /*------------------------< Function comment >------------------------*/
worasuchad 0:df6e371d8665 83 /* NAME : hormone receiver for servo down */
worasuchad 0:df6e371d8665 84 /* PARAMETERS : - */
worasuchad 0:df6e371d8665 85 /* RETURN VALUE : - */
worasuchad 0:df6e371d8665 86 /* DESCRIPTION : - */
worasuchad 0:df6e371d8665 87 /*--------------------------------------------------------------------*/
worasuchad 0:df6e371d8665 88 float hormone::hormoneRecDown(const float downDeg)
worasuchad 0:df6e371d8665 89 {
worasuchad 0:df6e371d8665 90 //downDegree = 90.00f*(1.00f-(0.06f*cgDown));
worasuchad 0:df6e371d8665 91 downDegree = downDeg;
worasuchad 0:df6e371d8665 92
worasuchad 0:df6e371d8665 93 if(downDegree < 90.00f)
worasuchad 0:df6e371d8665 94 {
worasuchad 0:df6e371d8665 95 downDegree = 90.00f;
worasuchad 0:df6e371d8665 96 }
worasuchad 0:df6e371d8665 97 else if(downDegree > 100.00f)
worasuchad 0:df6e371d8665 98 {
worasuchad 0:df6e371d8665 99 downDegree = 100.00f;
worasuchad 0:df6e371d8665 100 }
worasuchad 0:df6e371d8665 101
worasuchad 0:df6e371d8665 102 return downDegree;
worasuchad 0:df6e371d8665 103 }
worasuchad 0:df6e371d8665 104 /*--------------------------------------------------------------------*/