Updated with emergency button and watchdog code

Dependencies:   QEI2 chair_BNO055 PID VL53L1X_Filter

Dependents:   wheelchairControlSumer2019

Files at this revision

API Documentation at this revision

Comitter:
t1jain
Date:
Fri Jun 28 17:00:27 2019 +0000
Parent:
29:052247c0f0e0
Commit message:
Cleaned up code

Changed in this revision

wheelchair.cpp Show annotated file Show diff for this revision Revisions of this file
wheelchair.h Show annotated file Show diff for this revision Revisions of this file
--- a/wheelchair.cpp	Thu Jun 27 22:54:46 2019 +0000
+++ b/wheelchair.cpp	Fri Jun 28 17:00:27 2019 +0000
@@ -57,7 +57,7 @@
 void Wheelchair::assistSafe_thread()
 {
     int ToFV[12];
-    for(int i = 0; i < 6; i++)                                              // reads from the ToF Sensors
+    for(int i = 0; i < 6; i++)                                                          // Reads from the ToF Sensors
     {
         ToFV[i] = (*(ToF+i))->readFromOneSensor();
         //out->printf("%d ", ToFV[i]);
@@ -65,6 +65,7 @@
         //out->printf("\r\n");
     int sensor1 = ToFV[1];
     int sensor4 = ToFV[5];
+    
     //out->printf("%d, %d\r\n", sensor1, sensor4);
     /*if(curr_vel < 1 &&((2 * maxDecelerationSlow*sensor1 < curr_vel*curr_vel*1000*1000 || 
     2 * maxDecelerationSlow*sensor4 < curr_vel*curr_vel*1000*1000) && 
@@ -111,17 +112,17 @@
     out->printf("on\r\n");
     imu = new chair_BNO055(pc, time);
     Wheelchair::stop();                                                                 // Wheelchair is initially stationary
-    imu->setup();                                                                       // turns on the IMU
+    imu->setup();                                                                       // Turns on the IMU
     wheelS = qeiS;                                                                      // "wheel" is called for encoder
     wheel = qei;   
-    ToF = ToFT;                                                                         // passes pointer with addresses of ToF sensors
+    ToF = ToFT;                                                                         // Passes pointer with addresses of ToF sensors
     
-    for(int i = 0; i < 12; i++)                                               // initializes the ToF Sensors
+    for(int i = 0; i < 12; i++)                                                         // Initializes the ToF Sensors
     {
         (*(ToF+i))->initReading(0x31+((0x02)*i), 50000);
     }
          
-    out->printf("wheelchair setup done \r\n");                                          // Make sure it initialized; prints in serial monitor
+    out->printf("wheelchair setup done \r\n");                                          // Make sure its initialized; prints in serial monitor
     ti = time;
     
 
@@ -254,7 +255,7 @@
     }
  
     myPID.SetTunings(5,0, 0.004);                                                       // Sets the constants for P and D
-    myPID.SetOutputLimits(0,high-def-.12);                                              //Limit is set to the differnce between def and low
+    myPID.SetOutputLimits(0,high-def-.12);                                              // Limit is set to the differnce between def and low
     myPID.SetControllerDirection(REVERSE);                                              // PID mode: Reverse
  
     /* PID stops when approaching a litte more than desired angle */
--- a/wheelchair.h	Thu Jun 27 22:54:46 2019 +0000
+++ b/wheelchair.h	Fri Jun 28 17:00:27 2019 +0000
@@ -14,19 +14,20 @@
 
 /*
 * Joystick has analog out of 200-700, scale values between 1.3 and 3.3
-*/             
-#define def (2.5f/3.3f)                 //Default axis on joystick to stay neutral; used on x and y axis
-#define high 3.3f/3.3f                  //High power on joystick; used on x and y axis
-#define low (1.7f/3.3f)                 //Low power on joystick; used on x and y axis
-#define offset .03f                    //Joystick adjustment to be able to go straight. Chair dependent on manufactoring precision
-#define process .1                      //Defines default time delay in seconds
+*/       
+      
+#define def (2.5f/3.3f)                 // Default axis on joystick to stay neutral; used on x and y axis
+#define high 3.3f/3.3f                  // High power on joystick; used on x and y axis
+#define low (1.7f/3.3f)                 // Low power on joystick; used on x and y axis
+#define offset .03f                     // Joystick adjustment to be able to go straight. Chair dependent on manufactoring precision
+#define process .1                      // Defines default time delay in seconds
 
 /* Pin plug in for Nucleo-L432KC */
-#define xDir PA_6                         //* PWM Pins */
+#define xDir PA_6                       // PWM Pins 
 #define yDir PA_5
-#define Encoder1 D7                     //*Digital In Pull Up Pin */
+#define Encoder1 D7                     // Digital In Pull Up Pin 
 #define Encoder2 D8
-#define Diameter 31.75                  //Diameter of encoder wheel
+#define Diameter 31.75                  // Diameter of encoder wheel
 #define maxDecelerationSlow 120
 #define maxDecelerationFast 30
 #define ToFSensorNum 12
@@ -115,7 +116,7 @@
     double vel;
     double test1, test2;  
     bool forwardSafety;
-    double curr_yaw, curr_velS;                                                            // Variable that contains current relative angle
+    double curr_yaw, curr_velS;         // Variable that contains current relative angle
 
     
 private: