For coursework of group 3 in SOFT564Z

Dependencies:   Motordriver ros_lib_kinetic

Committer:
Jonathan738
Date:
Sun Jan 05 15:42:22 2020 +0000
Revision:
12:82b8fe254222
Parent:
11:0b9098ec11c7
Added working version of TOF code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jonathan738 0:3dfee562823a 1 /*------------------------------------------------------------------------------
Jonathan738 0:3dfee562823a 2 Created by: Sami Sequeira & Jonathan Wheadon
Jonathan738 0:3dfee562823a 3 @ The University of Plymouth
Jonathan738 0:3dfee562823a 4 November 2019
Jonathan738 0:3dfee562823a 5 For the SOFT564Z module on distributed systems
Jonathan738 0:3dfee562823a 6 ------------------------------------------------------------------------------*/
Jonathan738 0:3dfee562823a 7
Jonathan738 4:8afc50a3e4ac 8 #include "mbed.h"
Jonathan738 10:c752a8d76ee2 9 //#include "Debug.hpp"
Jonathan738 7:2796f0b5228d 10 //#include "dateTime.hpp"
Jonathan738 0:3dfee562823a 11 #include "General.hpp"
Jonathan738 11:0b9098ec11c7 12 #include "Battery_Monitor.hpp"
Jonathan738 4:8afc50a3e4ac 13 #include "Pins.h"
Jonathan738 11:0b9098ec11c7 14 #include "ros.h"
Jonathan738 11:0b9098ec11c7 15 #include "rtos.h"
Jonathan738 11:0b9098ec11c7 16 #include "ROS_Handler.hpp"
Jonathan738 11:0b9098ec11c7 17 #include <motordriver.h>
Jonathan738 11:0b9098ec11c7 18 #include "math.h"
Jonathan738 11:0b9098ec11c7 19 #include "Motors.hpp"
Jonathan738 12:82b8fe254222 20 #include "VL6180.hpp"
Jonathan738 0:3dfee562823a 21
Jonathan738 8:e406c6f728bd 22 DigitalOut debug_LED(LED1);
Jonathan738 8:e406c6f728bd 23
Jonathan738 0:3dfee562823a 24 // Threads
Jonathan738 11:0b9098ec11c7 25 Thread ROS_Thread(osPriorityRealtime); // Create THREAD with highest priority for ROS
Jonathan738 12:82b8fe254222 26 Thread TOF_Thread(osPriorityNormal);
Jonathan738 10:c752a8d76ee2 27 //Thread Debug_Thread(osPriorityNormal);
Jonathan738 12:82b8fe254222 28 //Thread Motor_Thread(osPriorityNormal);
Jonathan738 0:3dfee562823a 29
Jonathan738 0:3dfee562823a 30 // Thread ID for the Main function (CMSIS API)
Jonathan738 11:0b9098ec11c7 31 osThreadId tidMain;
Jonathan738 0:3dfee562823a 32
Jonathan738 7:2796f0b5228d 33 // main starts all threads
Jonathan738 0:3dfee562823a 34 int main(void)
Jonathan738 0:3dfee562823a 35 {
Jonathan738 0:3dfee562823a 36 // Main thread ID
Jonathan738 11:0b9098ec11c7 37 tidMain = Thread::gettid();
Jonathan738 0:3dfee562823a 38
Jonathan738 0:3dfee562823a 39 // Start each thread
Jonathan738 11:0b9098ec11c7 40 ROS_Thread.start(ROS_Handler);
Jonathan738 12:82b8fe254222 41 TOF_Thread.start(TOF_Handler);
Jonathan738 12:82b8fe254222 42 //Motor_Thread.start(Motor_Handler);
Jonathan738 7:2796f0b5228d 43 //Debug_Thread.start(TerminalThread);
firnenenrif 1:6a10e58b3d43 44
Jonathan738 4:8afc50a3e4ac 45 // Creates an object to monitor and handle changes in battery level using an RGB LED as an OutPut
Jonathan738 12:82b8fe254222 46 Battery_Monitor VBatt_Monitor(ADC_VBAT, 1.0f);
Jonathan738 8:e406c6f728bd 47
firnenenrif 1:6a10e58b3d43 48 /**************************************************************************/
Jonathan738 12:82b8fe254222 49 //initialize(); //initialize(); only needs to be called once, at the start of the program.
firnenenrif 1:6a10e58b3d43 50 //the encoder interrupts should be able to handle themselves from there, and do not require
firnenenrif 1:6a10e58b3d43 51 //resetting.
firnenenrif 1:6a10e58b3d43 52 /**************************************************************************/
Jonathan738 8:e406c6f728bd 53
Jonathan738 8:e406c6f728bd 54 while(1)
Jonathan738 8:e406c6f728bd 55 {
Jonathan738 10:c752a8d76ee2 56 //Flag_Error(warning, "Flashing LED\n\r");
Jonathan738 11:0b9098ec11c7 57 debug_LED = 1;
Jonathan738 12:82b8fe254222 58 wait_ms(500);
Jonathan738 11:0b9098ec11c7 59 debug_LED = 0;
Jonathan738 12:82b8fe254222 60 wait_ms(500);
Jonathan738 0:3dfee562823a 61 }
Jonathan738 0:3dfee562823a 62 }