Isabella Gomez Torres
/
Version1-3
Integrated IMU6050 + ToF(side, down, front, back) + comments + main
Diff: main.cpp
- Revision:
- 18:94ae9ca5a709
- Parent:
- 17:770a161346ed
- Child:
- 19:7ead04523f89
diff -r 770a161346ed -r 94ae9ca5a709 main.cpp --- a/main.cpp Tue Jul 02 16:41:38 2019 +0000 +++ b/main.cpp Tue Jul 02 17:49:41 2019 +0000 @@ -4,19 +4,18 @@ DigitalIn pt3(D10, PullUp); // Pull up resistors to read analog signals into digital signals DigitalIn pt4(D9, PullUp); -/*added*/ -//DigitalIn e_button(D4); // Emergency button will start at HIGH +DigitalIn e_button(D6, PullDown); // Change to PullUp if testing without Emergency Button Connected QEI wheelS (D7, D8, NC, 1200); // Initializes Left encoder DigitalIn pt1(D7, PullUp); // Pull up resistors to read analog signals into digital signals DigitalIn pt2(D8, PullUp); int max_velocity; -//Timer testAccT; AnalogIn x(A0); // Initializes analog axis for the joystick AnalogIn y(A1); + //Watchdog limit should be 0.1; Set to 1 for Testing Only double watchdogLimit = 1; // Set timeout limit for watchdog timer in seconds int buttonCheck = 0; @@ -24,8 +23,10 @@ DigitalOut up(D12); // Turn up speed mode for joystick DigitalOut down(D13); // Turn down speed mode for joystick -DigitalOut on(D14); // Turn Wheelchair On -DigitalOut off(D15); // Turn Wheelchair Off + +PwmOut on(PE_6); // Turn Wheelchair On +PwmOut off(PE_5); // Turn Wheelchair Off + bool manual = false; // Turns chair joystic to automatic and viceverza Serial pc(USBTX, USBRX, 57600); // Serial Monitor @@ -53,6 +54,7 @@ Thread compass; // Thread for compass Thread velocity; // Thread for velosity Thread ToFSafe; // Thread for safety stuff +Thread emergencyButton; // Thread to check button state and reset device int main(void) @@ -61,18 +63,21 @@ nh.advertise(chatter); nh.advertise(chatter2); nh.subscribe(sub);*/ - //testAccT.start(); pc.printf("before starting\r\n"); - //queue.call_every(SAMPLEFREQ, &smart, &Wheelchair::compass_thread); // Sets up sampling frequency of the compass_thread - queue.call_every(SAMPLEFREQ, &smart, &Wheelchair::velocity_thread); // Sets up sampling frequency of the velosity_thread - queue.call_every(SAMPLEFREQ, &smart, &Wheelchair::ToFSafe_thread); // Sets up sampling frequency of the velosity_thread - //queue.call_every(200, rosCom_thread); // Sets up sampling frequency of the velosity_thread + //queue.call_every(SAMPLEFREQ, &smart, &Wheelchair::compass_thread); // Sets up sampling frequency of the compass thread + queue.call_every(SAMPLEFREQ, &smart, &Wheelchair::velocity_thread); // Sets up sampling frequency of the velocity thread + queue.call_every(SAMPLEFREQ, &smart, &Wheelchair::ToFSafe_thread); // Sets up sampling frequency of the ToF safety thread + //queue.call_every(200, rosCom_thread); // Sets up sampling frequency of the ROS com thread + queue.call_every(SAMPLEFREQ, &smart, &Wheelchair::emergencyButton_thread); // Sets up sampling frequency of the emergency button thread + t.reset(); - //compass.start(callback(&queue, &EventQueue::dispatch_forever)); // Starts running the compass thread - velocity.start(callback(&queue, &EventQueue::dispatch_forever)); // Starts running the velosity thread - ToFSafe.start(callback(&queue, &EventQueue::dispatch_forever)); // Starts running the velosity thread - //ros_com.start(callback(&queue, &EventQueue::dispatch_forever)); // Starts running the velosity thread + //compass.start(callback(&queue, &EventQueue::dispatch_forever)); // Starts running the compass thread + velocity.start(callback(&queue, &EventQueue::dispatch_forever)); // Starts running the velocity thread + ToFSafe.start(callback(&queue, &EventQueue::dispatch_forever)); // Starts running the ROS com thread + //ros_com.start(callback(&queue, &EventQueue::dispatch_forever)); // Starts running the ROS com thread + emergencyButton.start(callback(&queue, &EventQueue::dispatch_forever)); // Starts running the emergency button thread + pc.printf("After starting\r\n"); //added