with the tof code

Dependencies:   mbed Servo ros_lib_kinetic

Committer:
Stumi
Date:
Tue Nov 12 12:56:02 2019 +0000
Revision:
6:2cc2aac35868
Parent:
4:36a04230554d
Child:
7:8248af58df5a
Added buzzer functionality; Added buzzer and LED into obstacle avoidance routine; Made class declaration for led and buzzer in motor.cpp NOT MAIN

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Stumi 2:6197e1cf2cd1 1 /*--------------------------------------------------------------------------------
Stumi 2:6197e1cf2cd1 2 Filename: TOF.h
Stumi 2:6197e1cf2cd1 3 Description: Header file for adafruit VL_6180X TOF sensor
Stumi 2:6197e1cf2cd1 4 --------------------------------------------------------------------------------*/
Stumi 2:6197e1cf2cd1 5 #ifndef MOTOR_H
Stumi 2:6197e1cf2cd1 6 #define MOTOR_H
Stumi 2:6197e1cf2cd1 7
Stumi 2:6197e1cf2cd1 8 #include "mbed.h"
Stumi 6:2cc2aac35868 9 #include "Buzzer.h"
Stumi 6:2cc2aac35868 10 #include "LED.h"
Stumi 2:6197e1cf2cd1 11
Stumi 2:6197e1cf2cd1 12 /*--------------------------------------------------------------------------------
Stumi 2:6197e1cf2cd1 13 ---------------------------------DEFINES------------------------------------------
Stumi 2:6197e1cf2cd1 14 --------------------------------------------------------------------------------*/
Stumi 2:6197e1cf2cd1 15
Stumi 2:6197e1cf2cd1 16 //MOTOR 1
Stumi 2:6197e1cf2cd1 17 #define M1_IN1 PC_6
Stumi 2:6197e1cf2cd1 18 #define M1_IN2 PB_15
Stumi 2:6197e1cf2cd1 19 #define M1_PWM PB_13
Stumi 2:6197e1cf2cd1 20 #define M1_A PA_4
Stumi 2:6197e1cf2cd1 21 #define M1_B PB_12
Stumi 2:6197e1cf2cd1 22
Stumi 2:6197e1cf2cd1 23 //MOTOR 2
Stumi 2:6197e1cf2cd1 24 #define M2_IN1 PA_15
Stumi 2:6197e1cf2cd1 25 #define M2_IN2 PC_7
Stumi 2:6197e1cf2cd1 26 #define M2_PWM PB_4
Stumi 2:6197e1cf2cd1 27 #define M2_A PB_5
Stumi 2:6197e1cf2cd1 28 #define M2_B PB_3
Stumi 2:6197e1cf2cd1 29
Stumi 2:6197e1cf2cd1 30 /*--------------------------------------------------------------------------------
Stumi 2:6197e1cf2cd1 31 ---------------------------------CLASSES------------------------------------------
Stumi 2:6197e1cf2cd1 32 --------------------------------------------------------------------------------*/
Stumi 2:6197e1cf2cd1 33
Stumi 2:6197e1cf2cd1 34 // Class for managing connection and state to a VL6180X sensor
Stumi 2:6197e1cf2cd1 35
Stumi 2:6197e1cf2cd1 36 class cMotor
Stumi 2:6197e1cf2cd1 37 {
Stumi 2:6197e1cf2cd1 38 public:
Stumi 2:6197e1cf2cd1 39 cMotor(PwmOut pwm, DigitalOut fwd, DigitalOut rev); //Constructor, initialised motor pinouts
Stumi 2:6197e1cf2cd1 40 void Forwards(float speed);
Stumi 2:6197e1cf2cd1 41 void Backwards(float speed);
Stumi 3:df6160e2f6d9 42 void Stop();
Stumi 2:6197e1cf2cd1 43 private:
Stumi 2:6197e1cf2cd1 44 PwmOut _pwm;
Stumi 2:6197e1cf2cd1 45 DigitalOut _fwd;
Stumi 2:6197e1cf2cd1 46 DigitalOut _rev;
Stumi 2:6197e1cf2cd1 47
Stumi 2:6197e1cf2cd1 48 };
Stumi 2:6197e1cf2cd1 49
Stumi 2:6197e1cf2cd1 50 /*--------------------------------------------------------------------------------
Stumi 2:6197e1cf2cd1 51 -----------------------------------Functions---------------------------------------
Stumi 2:6197e1cf2cd1 52 --------------------------------------------------------------------------------*/
Stumi 4:36a04230554d 53 void Check_for_obstacles(uint8_t TOFRange[4]); //Obstacle avoidance functionality
Stumi 2:6197e1cf2cd1 54
Stumi 2:6197e1cf2cd1 55 /*--------------------------------------------------------------------------------
Stumi 2:6197e1cf2cd1 56 --------------------------------External Variables--------------------------------
Stumi 2:6197e1cf2cd1 57 --------------------------------------------------------------------------------*/
Stumi 4:36a04230554d 58 //extern cMotor MotorL; //Left motor class and pin initialisation
Stumi 4:36a04230554d 59 //extern cMotor MotorR; //Right motor class and pin initialisation
Stumi 2:6197e1cf2cd1 60
Stumi 2:6197e1cf2cd1 61 #endif