with the tof code

Dependencies:   mbed Servo ros_lib_kinetic

Committer:
Stumi
Date:
Tue Dec 10 11:52:53 2019 +0000
Revision:
8:262c6c40bff9
Parent:
7:8248af58df5a
Child:
9:326b8f261ef0
Communicates keyboard inputs to the robot using rosnodes;

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 8:262c6c40bff9 10 #include <ros.h>
Stumi 8:262c6c40bff9 11 #include <std_msgs/UInt8.h>
Stumi 2:6197e1cf2cd1 12
Stumi 2:6197e1cf2cd1 13 /*--------------------------------------------------------------------------------
Stumi 2:6197e1cf2cd1 14 ---------------------------------DEFINES------------------------------------------
Stumi 2:6197e1cf2cd1 15 --------------------------------------------------------------------------------*/
Stumi 2:6197e1cf2cd1 16
Stumi 2:6197e1cf2cd1 17 //MOTOR 1
Stumi 2:6197e1cf2cd1 18 #define M1_IN1 PC_6
Stumi 2:6197e1cf2cd1 19 #define M1_IN2 PB_15
Stumi 2:6197e1cf2cd1 20 #define M1_PWM PB_13
Stumi 2:6197e1cf2cd1 21 #define M1_A PA_4
Stumi 2:6197e1cf2cd1 22 #define M1_B PB_12
Stumi 2:6197e1cf2cd1 23
Stumi 2:6197e1cf2cd1 24 //MOTOR 2
Stumi 2:6197e1cf2cd1 25 #define M2_IN1 PA_15
Stumi 2:6197e1cf2cd1 26 #define M2_IN2 PC_7
Stumi 2:6197e1cf2cd1 27 #define M2_PWM PB_4
Stumi 2:6197e1cf2cd1 28 #define M2_A PB_5
Stumi 2:6197e1cf2cd1 29 #define M2_B PB_3
Stumi 2:6197e1cf2cd1 30
Stumi 2:6197e1cf2cd1 31 /*--------------------------------------------------------------------------------
Stumi 2:6197e1cf2cd1 32 ---------------------------------CLASSES------------------------------------------
Stumi 2:6197e1cf2cd1 33 --------------------------------------------------------------------------------*/
Stumi 2:6197e1cf2cd1 34
Stumi 2:6197e1cf2cd1 35 // Class for managing connection and state to a VL6180X sensor
Stumi 2:6197e1cf2cd1 36
Stumi 2:6197e1cf2cd1 37 class cMotor
Stumi 2:6197e1cf2cd1 38 {
Stumi 2:6197e1cf2cd1 39 public:
Stumi 2:6197e1cf2cd1 40 cMotor(PwmOut pwm, DigitalOut fwd, DigitalOut rev); //Constructor, initialised motor pinouts
Stumi 7:8248af58df5a 41 void Forwards(float speed); //Drives motor forwards
Stumi 7:8248af58df5a 42 void Backwards(float speed);//Drives motor backwards
Stumi 7:8248af58df5a 43 void Stop(); //Stops both motors
Stumi 2:6197e1cf2cd1 44 private:
Stumi 2:6197e1cf2cd1 45 PwmOut _pwm;
Stumi 2:6197e1cf2cd1 46 DigitalOut _fwd;
Stumi 2:6197e1cf2cd1 47 DigitalOut _rev;
Stumi 2:6197e1cf2cd1 48
Stumi 2:6197e1cf2cd1 49 };
Stumi 2:6197e1cf2cd1 50
Stumi 2:6197e1cf2cd1 51 /*--------------------------------------------------------------------------------
Stumi 2:6197e1cf2cd1 52 -----------------------------------Functions---------------------------------------
Stumi 2:6197e1cf2cd1 53 --------------------------------------------------------------------------------*/
Stumi 4:36a04230554d 54 void Check_for_obstacles(uint8_t TOFRange[4]); //Obstacle avoidance functionality
Stumi 7:8248af58df5a 55 void update_power_levels(float vBatt); //Sends power level to the LED class for further processing
Stumi 8:262c6c40bff9 56 void keySub(const std_msgs::UInt8 &keyPress);
Stumi 2:6197e1cf2cd1 57 /*--------------------------------------------------------------------------------
Stumi 2:6197e1cf2cd1 58 --------------------------------External Variables--------------------------------
Stumi 2:6197e1cf2cd1 59 --------------------------------------------------------------------------------*/
Stumi 4:36a04230554d 60 //extern cMotor MotorL; //Left motor class and pin initialisation
Stumi 4:36a04230554d 61 //extern cMotor MotorR; //Right motor class and pin initialisation
Stumi 2:6197e1cf2cd1 62
Stumi 2:6197e1cf2cd1 63 #endif