This program is for an autonomous robot for the competition at the Hochschule Luzern. http://cruisingcrepe.wordpress.com/ We are one of the 32 teams. http://cruisingcrepe.wordpress.com/ The postition control is based on this Documentation: Control of Wheeled Mobile Robots: An Experimental Overview from Alessandro De Luca, Giuseppe Oriolo, Marilena Vendittelli. For more information see here: http://www.dis.uniroma1.it/~labrob/pub/papers/Ramsete01.pdf
Fork of autonomous Robot Android by
Diff: Android/Android.cpp
- Revision:
- 2:d8e1613dc38b
- Parent:
- 1:6cd533a712c6
- Child:
- 3:92ba0254af87
--- a/Android/Android.cpp Sat Mar 02 09:39:34 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,201 +0,0 @@ -#include "Android.h" - -using namespace std; - - -Android::Android(state_t* s, RobotControl* robotControl, MaxonESCON* motorControllerLeft, MaxonESCON* motorControllerRight, float period) - : - Task(period), - AndroidAccessory (OUTL, INBL, MANUFACTURER, MODEL, DESCRIPTION, VERSION, URI, SERIAL) -{ - /* get peripherals */ - this->s = s; - this->robotControl = robotControl; - this->motorControllerLeft = motorControllerLeft; - this->motorControllerRight = motorControllerRight; - this->period = period; - - setupDevice(); - USBInit(); - -} - - -Android::~Android() {} - - -void Android::run() -{ - - USBLoop(); - - - /* - - SENDEN SENDEN SENDEN SENDEN SENDEN SENDEN SENDEN SENDEN - - HIer die Sollwertvorgabe position und Winkel - robotContol->setxPosition(1.0f); - robotContol->setyPosition(1.0f); - robotContol->setTheta(1/2 * piiii); - - - SENDEN SENDEN SENDEN SENDEN SENDEN SENDEN SENDEN SENDEN - - - - - LESEN LESEN LESEN LESEN LESEN LESEN LESEN LESEN LESEN LESEN LESEN LESEN LESEN - - Hier die aktuelle Position und Winkel - s->xAxis oder robotControl->getxActualPosition(); - s->yAxis oder robotControl->getyActualPosition(); - s->angle = robotControl->getActualTheta() * 180 / PI; - - - Batterie - s->voltageBattery - - Status - s->state; - - LESEN LESEN LESEN LESEN LESEN LESEN LESEN LESEN LESEN LESEN LESEN LESEN LESEN - - - - - - BEim Start muss das Kommen nach dem Start Klicken muss alles auf null gesetzt werden. und los gehts - - compass.calibrate_compass_basis_rad(); - - robotControl.setAllToZero(START_X_OFFSET, START_Y_OFFSET); - leftMotor->setPulses(0); - rightMotor->setPulses(0); - robotControl->setEnable(false); - wait(0.2); - robotControl->setEnable(true); - wait(0.2); - state->startTimerFromZero(); - state->initPlotFile(); - state->start(); - - ENDE Start - - - - Beim ENDE Muss das kommen - state->savePlotFile(s); - ENDE - - */ -} - -int Android::callbackRead(u8 *buf, int len) -{ - // pc.printf("%i %s\n\r\n\n\n",len,buf); - for (int i = 0; i<INBL; i++) { - buf[i] = 0; - } -} - - -void Android::setupDevice() -{ - // pc.baud(460800); - // pc.printf("Welcome to Android\n\n\n\n\n\n\r"); - settick = false; - // pc.attach(this, &Android::serialIRQ, Serial::RxIrq); - for (int i = 0; i<OUTL; i++) { - buffer[i] = 0; - } - bcount = 0; - //n.attach(this,&Android::AttachTick,5); - //tick.attach(this,&Android::onTick,0.1); -} -void Android::resetDevice() -{ - //pc.printf("Android reset\n\r"); - for (int i = 0; i<OUTL; i++) { - buffer[i] = 0; - } - bcount = 0; -} - -int Android::callbackWrite() -{ - return 0; -} - - -void Android::AttachTick() -{ - if(!settick)tick.attach(this,&Android::onTick,0.04); - settick = true; -} - -void Android::onTick() -{ - bool update = false; - int templ, tempr; - - - - templ = int(left * 10000); - tempr = int(right * 10000); - - - - if (abs(templ-tl)>170) { - update = true; - } - if (abs(tempr-tr)>170) { - update = true; - } - if (update) { - u8* wbuf = _writebuff; - - wbuf[0] = 'P'; - wbuf[1] = templ&0xFF; - wbuf[2] = (templ>>8) & 0xFF; - wbuf[3] = tempr&0xFF; - wbuf[4] = (tempr>>8) & 0xFF; - wbuf[5] = 0; - - this->write(wbuf,5); - - } -} - - -void Android::serialIRQ() -{ - // buffer[bcount] = pc.getc(); - - // pc.putc(buffer[bcount]); - - if (buffer[bcount] == '\n' || buffer[bcount] == '\r') { - u8* wbuf = _writebuff; - for (int i = 0; i<OUTL; i++) { - wbuf[i] = buffer[i]; - buffer[i] = 0; - } - //pc.printf("Sending: %s\n\r",wbuf); - this->write(wbuf,bcount); - bcount = 0; - } else { - if (buffer[bcount] != 0x08 && buffer[bcount] != 0x7F ) { - bcount++; - if (bcount == OUTL) { - bcount = 0; - } - } else { - bcount--; - } - } - -} - - - -