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

Dependencies:   mbed

Fork of autonomous Robot Android by Christian Burri

AndroidADKTerm/android.h

Committer:
chrigelburri
Date:
2013-04-07
Revision:
12:235e318a414f
Parent:
Android/android.h@ 11:775ebb69d5e1
Child:
14:6a45a9f940a8

File content as of revision 12:235e318a414f:

#ifndef _ANDROID_H_
#define _ANDROID_H_

#include "mbed.h"
#include "AndroidAccessory.h"
#include "defines.h"
#include <string>
#include <sstream>
#include <vector>
#include <iostream>
#include <stdlib.h>

/**
 * @author Arno Galliker
 *
 * @subsection LICENSE
 *
 * Copyright &copy; 2013 HSLU Pren Team #1 Cruising Crêpe
 * All rights reserved.
 *
 * @subsection DESCRIPTION
 *
 * This class implements communication with the android smartphone
 * For more information see the Android ADK Cookbook:
 * <a href="http://mbed.org/cookbook/mbed-with-Android-ADK">http://mbed.org/cookbook/mbed-with-Android-ADK</a>
 *
 * Originally created by p07gbar from work by Makoto Abe
 */

#define OUTL 100
#define INBL 100

class AdkTerm : public AndroidAccessory
{

private:
    
    /** Attaches a tick to send messages over the USB buffer in a certain interval */
    void AttachTick();
    
    /** Method to call when a tick period is over */
    void onTick();
    
    /** Char buffer with a size of OUTL */
    char buffer[OUTL];
    
    /** Buffer count ??? */
    int bcount;
    
    /** Instance of ticker */
    Ticker tick;
    
    //float right,left,rl,ll;
    //int tl,tr;
    
    //Timeout n;
    
    /** States if tick is on */
    bool settick;
    
    /** States if something is written to the buffer?? */
    bool ind;
    
    /** Desired position in meters for x-coordinate, given by android */
    float x;
    
    /** Desired position in meters for y-coordinate, given by android */
    float y;
    
    /** Desired position in degrees for theta, given by android */
    float t;

public:

    /**
     * Creates a <code>AdkTerm</code> object and initializes all private
     * state variables. Constructor
     */
    AdkTerm();

    /**
     * Sets initial configurations and clears the buffer 
     * 
     */
    void setupDevice();

    /**
     * Returns the desired position in meters for x-coordinate, given by android
     * @return x-coordinate,given in [m]
     */
    float getx();

    /**
     * Returns the desired position in meters for y-coordinate, given by android
     * @return y-coordinate,given in [m]
     */
    float gety();

     /**
     * Returns the esired position in degrees for theta, given by android
     * @return y-coordinate,given in degrees [°]
     */
    float gett();

private:

    /**
     *
     *
     */
    //void AttachTick();

    /**
     *
     *
     */
    // void onTick();

    /**
     * Clears the buffer and bcount
     *
     */
    void resetDevice();

    /**
     * Takes an string, a vector of strings for the delimited tokens, and a with the 
     * @param str
     * @param tokens
     * @param delimiters
     */
    void Tokenize(const string& str, vector<string>& tokens, const string& delimiters = " ");

    /**
     *
     * @param buf
     * @param len
     */
    int callbackRead(u8 *buf, int len);

    /**
     *
     *
     */
    int callbackWrite();

    /**
     *
     *
     */
    void serialIRQ();

};

#endif