Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Servo ros_lib_kinetic
Motor.h
00001 /*-------------------------------------------------------------------------------- 00002 Filename: TOF.h 00003 Description: Header file for adafruit VL_6180X TOF sensor 00004 --------------------------------------------------------------------------------*/ 00005 #ifndef MOTOR_H 00006 #define MOTOR_H 00007 00008 #include "mbed.h" 00009 #include "Buzzer.h" 00010 #include <ros.h> 00011 #include <Servo.h> 00012 #include <std_msgs/UInt8.h> 00013 00014 /*-------------------------------------------------------------------------------- 00015 ---------------------------------DEFINES------------------------------------------ 00016 --------------------------------------------------------------------------------*/ 00017 00018 //MOTOR 1 00019 #define M1_IN1 PC_6 00020 #define M1_IN2 PB_15 00021 #define M1_PWM PB_13 00022 #define M1_A PA_4 00023 #define M1_B PB_12 00024 00025 //MOTOR 2 00026 #define M2_IN1 PA_15 00027 #define M2_IN2 PC_7 00028 #define M2_PWM PB_4 00029 #define M2_A PB_5 00030 #define M2_B PB_3 00031 #define srvoPan PE_5 00032 #define srvoTilt PF_9 00033 00034 00035 static Servo servo1(srvoTilt); 00036 static Servo servo2(srvoPan); 00037 00038 /*-------------------------------------------------------------------------------- 00039 ---------------------------------CLASSES------------------------------------------ 00040 --------------------------------------------------------------------------------*/ 00041 00042 // Class for managing connection and state to a VL6180X sensor 00043 00044 class cMotor 00045 { 00046 public: 00047 cMotor(PwmOut pwm, DigitalOut fwd, DigitalOut rev); //Constructor, initialised motor pinouts 00048 void Forwards(float speed); //Drives motor forwards 00049 void Backwards(float speed);//Drives motor backwards 00050 void Stop(); //Stops both motors 00051 private: 00052 PwmOut _pwm; 00053 DigitalOut _fwd; 00054 DigitalOut _rev; 00055 00056 }; 00057 00058 /*-------------------------------------------------------------------------------- 00059 -----------------------------------Functions--------------------------------------- 00060 --------------------------------------------------------------------------------*/ 00061 void Check_for_obstacles(uint8_t TOFRange[4]); //Obstacle avoidance functionality 00062 void update_power_levels(float vBatt); //Sends power level to the LED class for further processing 00063 void MotorKeySub(const std_msgs::UInt8 &keyPress); 00064 void servoKeySub(const std_msgs::UInt8 &ServoKeyPress); 00065 00066 /*-------------------------------------------------------------------------------- 00067 --------------------------------External Variables-------------------------------- 00068 --------------------------------------------------------------------------------*/ 00069 //extern cMotor MotorL; //Left motor class and pin initialisation 00070 //extern cMotor MotorR; //Right motor class and pin initialisation 00071 00072 00073 static int IncSize; //Increment size for servo movment in increments of 1 - 20 degrees 00074 00075 00076 #endif
Generated on Wed Jul 13 2022 08:03:55 by
1.7.2