Practical Robotics Modular Robot Library
robot.h
- Committer:
- jah128
- Date:
- 2016-11-26
- Revision:
- 1:a6728adaf7e7
- Parent:
- 0:8a2dd255c508
- Child:
- 2:bf34b86aa0f3
File content as of revision 1:a6728adaf7e7:
#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 // SERIAL INTERFACES SETTINGS /* ENABLE_BLUETOOTH [1=on, 0=off]: Enable if the BlueSmirf module is being used */ /** @brief Enable if the BlueSmirf module is being used. 0=off 1=on*/ #define ENABLE_BLUETOOTH 1 /* ENABLE_PC_SERIAL [1=on, 0=off]: Enable if the PC(RPi) USB serial module is being used */ #define ENABLE_PC_SERIAL 1 /* BLUETOOTH_BAUD [recommended=115200]: Baud rate for the BlueSMIRF module */ #define BLUETOOTH_BAUD 115200 /* PC_BAUD [recommended=460800 for optimal performance, 115200 for compatability]: Baud rate for the PC USB serial module */ //#define PC_BAUD 460800 #define PC_BAUD 115200 /* DEBUG_MODE [1=on, 0=off]: Enable to allow debug messages to be sent of one of the serial interfaces */ #define DEBUG_MODE 1 /* DEBUG_OUTPUT_STREAM [1=PC\USB 2=BlueSmirf 4=Display]: Specify which output stream(s) should be used by default for debug messages, if enabled*/ #define DEBUG_OUTPUT_STREAM 1 // 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; /** * The Robot class contains the core functions for the robot */ 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); /** * Display a string message (printf) on the selected debug output stream [eg pc, bt or both] */ void debug(const char* format, ...); /** * Setup the serial interfaces (pc, bt) at the correct baud rate and attach listeners */ void setup_serial_interfaces(void); private: void _update_minutes(void); void _bt_rx_callback(void); void _pc_rx_callback(void); }; #endif