Practical Robotics Modular Robot Library

Dependents:   ModularRobot

robot.h

Committer:
jah128
Date:
2016-11-26
Revision:
0:8a2dd255c508
Child:
1:a6728adaf7e7

File content as of revision 0:8a2dd255c508:



#ifndef ROBOT_H
#define ROBOT_H

#include "mbed.h"
#include "led.h"
#include "sensors.h"
#include "motors.h"
#include "calibration.h"

#define LED_ADDRESS 0xC0
#define ADC_ADDRESS 0x90

// To update sensors 10 times a second (8 x 0.0125 = 0.1)
#define SENSOR_TICKER_PERIOD 0.0125

// H-Bridge should work at upto 100kHz (10uS) but note it seems to behave unusually at frequencies close to but above this
// Slower speeds work a bit faster but noisier
#define MOTOR_PWM_PERIOD_US 400

#define USE_STALL_OFFSET 1
#define STALL_OFFSET 0.22

extern I2C primary_i2c;
extern AnalogIn vin_battery;
extern Serial pc;
extern Led led;
extern Sensors sensors;
extern Motors motors;
extern volatile char i2c_lock;

class Robot
{
public:

    /**
     * Main initialisation routine: setup the robot, the I2C interfaces, start system timers etc.
     *
     */
    void init(void);
    
    /**
     * Get the uptime for the MBED
     *
     * @return The amount of time in seconds that the MBED has been active since last reset
     */
    float get_uptime(void);
    
    /**
     * Get the battery voltage
     * 
     * The battery voltage is passed through a 7.5V Zener diode, then into a 1:1 potential divider.   This
     * allows a voltage in the approximate range 7.5 to 13.8V to be measured.
     *
     * @return The current voltage reading for the battery
     */
    float get_battery_voltage(void);
    
    private:
    void _update_minutes(void);
};


#endif