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 main.cpp Source File

main.cpp

00001 #include "robot.h"
00002 #include "mbed.h"
00003 
00004 
00005 const int Sensor::N = 13;
00006 const float Wheel::period = 0.0005;
00007 const float Sensor::range = 0.2;
00008 
00009 // 20-150 cm sensor
00010 // float Sensor::voltage[15] = {2.75,2.55,2.00,1.55,1.25,1.15,0.90,0.80,0.75,0.65,0.60,0.55,0.50,0.455,0.45};
00011 // float Sensor::meters[15] = {0.15,0.20,0.30,0.40,0.50,0.60,0.70,0.80,0.90,1.00,1.10,1.20,1.30,1.40,1.50};
00012 
00013 // 10-80 cm sensor
00014 float Sensor::voltage[13] = {3.15, 2.98, 2.75, 2.3, 1.64, 1.3, 1.09, 0.92, 0.75, 0.61, 0.51, 0.45, 0.4};
00015 float Sensor::meters[13] = {0.06, 0.07, 0.08, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8};
00016 
00017 const float Robot::wheelbase = 0.4;
00018 const float Robot::length = 0.3;
00019 
00020 Robot *mobile = new Robot(p29, 0.2);
00021 
00022 Ticker wander;
00023 
00024 int main()
00025 {
00026     wander.attach(mobile,&Robot::RandomWandering, 2.0);      
00027     
00028     mobile->Run();
00029     
00030     wander.detach();
00031     delete mobile;
00032 }