Implementation of the fuzzy control algorithm for obstacle avoidance. This algorithm is for a two-wheel differential drive robot. It uses distance information from 3 analogue IR range sensors and controls DC motors using ESCON servo controllers. This C++ library is written for mbed LPC1768. For any questions and/or reporting bugs contact author: vans.edw@gmail.com

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers robot.h Source File

robot.h

00001 #ifndef ROBOT_H
00002 #define ROBOT_H
00003 
00004 #include "mbed.h"
00005 #include "sensor.h"
00006 #include "wheel.h"
00007 #include "fuzzylogic.h"
00008 
00009 class Robot
00010 {
00011     public:
00012 
00013         Robot(PinName StopPin, const float speed);
00014         ~Robot();
00015         void Run();
00016         
00017         // Behaviors of the robot
00018         void AvoidObstacles();
00019         void RandomWandering(); 
00020         
00021     private:
00022         Wheel *leftWheel;
00023         Wheel *rightWheel;
00024         Sensor *left;
00025         Sensor *left1;
00026         Sensor *middle;
00027         Sensor *right;
00028         Sensor *right1;
00029         fuzzylogic *controller;
00030         DigitalIn stop;
00031 
00032         const float m_speed;
00033         static const float wheelbase;
00034         static const float length;
00035         float R;
00036 
00037         void InitializeController();
00038         void InitializeWheels();
00039         
00040         float minimum(float a, float b);
00041 
00042         // Low level behaviors
00043         void Stop();
00044         void Start();
00045         void Reverse();
00046         void EnableWheels();
00047         void DisableWheels();
00048         void Steering(float steeringAngle); 
00049 };          
00050 
00051 #endif // ROBOT_H