This program is for an autonomous robot for the competition at the Hochschule Luzern. We are one of the 32 teams. <a href="http://cruisingcrepe.wordpress.com/">http://cruisingcrepe.wordpress.com/</a> 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: <a href="http://www.dis.uniroma1.it/~labrob/pub/papers/Ramsete01.pdf">http://www.dis.uniroma1.it/~labrob/pub/papers/Ramsete01.pdf</a>

Dependencies:   mbed

Fork of autonomousRobotAndroid by Christian Burri

Committer:
chrigelburri
Date:
Sun Mar 03 16:26:47 2013 +0000
Revision:
2:d8e1613dc38b
Parent:
1:6cd533a712c6
Child:
3:92ba0254af87
Viereck Fahren; Code aufger?umt und eine setter methode progammiert f?r sollwert

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chrigelburri 0:31f7be68e52d 1 #ifndef _DEFINES_H_
chrigelburri 0:31f7be68e52d 2 #define _DEFINES_H_
chrigelburri 0:31f7be68e52d 3
chrigelburri 0:31f7be68e52d 4 #include "mbed.h"
chrigelburri 0:31f7be68e52d 5
chrigelburri 0:31f7be68e52d 6 //Physical dimensions.
chrigelburri 0:31f7be68e52d 7 #define PI 3.141592654f
chrigelburri 0:31f7be68e52d 8
chrigelburri 0:31f7be68e52d 9 // Motor #339282 EC 45 flat 30W and GEAR
chrigelburri 0:31f7be68e52d 10 #define POLE_PAIRS 8u // 8
chrigelburri 0:31f7be68e52d 11 #define GEAR 1.0f // Gear on the motor
chrigelburri 0:31f7be68e52d 12 #define PULSES_PER_STEP 6u // 6 step for Hallsensor
chrigelburri 0:31f7be68e52d 13
chrigelburri 0:31f7be68e52d 14 // Physical Dimension of the car
chrigelburri 0:31f7be68e52d 15 #define WHEEL_RADIUS 0.042f // radius of the wheel, given in [m]
chrigelburri 1:6cd533a712c6 16 #define WHEEL_DISTANCE 0.18f // Distance of the wheel, given in [m]
chrigelburri 0:31f7be68e52d 17
chrigelburri 0:31f7be68e52d 18 // State Bits of the car
chrigelburri 0:31f7be68e52d 19 #define STATE_STOP 1u // Bit0 = stop pressed
chrigelburri 0:31f7be68e52d 20 #define STATE_UNDER 2u // Bit1 = Undervoltage battery
chrigelburri 0:31f7be68e52d 21 #define STATE_LEFT 4u // Bit2 = left ESCON in error state
chrigelburri 0:31f7be68e52d 22 #define STATE_RIGHT 8u // Bit3 = right ESCON in error state
chrigelburri 0:31f7be68e52d 23
chrigelburri 0:31f7be68e52d 24 // ESCON Dimenstion
chrigelburri 0:31f7be68e52d 25 #define ESCON_SET_FACTOR 100.0f // Speed Factor how set in the ESCON
chrigelburri 0:31f7be68e52d 26 #define ESCON_GET_FACTOR 100.0f // Speed Factor how get in the ESCON
chrigelburri 0:31f7be68e52d 27
chrigelburri 0:31f7be68e52d 28 // Start Defintition
chrigelburri 2:d8e1613dc38b 29 #define START_X_OFFSET -0.8f // Sets the start X-point [m]
chrigelburri 0:31f7be68e52d 30 #define START_Y_OFFSET 0.8f // Sets the start Y-point [m]
chrigelburri 0:31f7be68e52d 31
chrigelburri 0:31f7be68e52d 32 // Maximum Aceeleration
chrigelburri 0:31f7be68e52d 33 #define ACCELERATION 0.25f // maximum translational acceleration, given in [m/s2]
chrigelburri 1:6cd533a712c6 34 #define THETA_ACCELERATION 1.0f // maximum rotational acceleration, given in [rad/s2]
chrigelburri 1:6cd533a712c6 35
chrigelburri 1:6cd533a712c6 36 // Gains of the position controller
chrigelburri 2:d8e1613dc38b 37 #define GAIN 0.30f // Main Gain
chrigelburri 2:d8e1613dc38b 38 #define K1 1.0f * GAIN
chrigelburri 2:d8e1613dc38b 39 #define K2 3.0f * GAIN
chrigelburri 2:d8e1613dc38b 40 #define K3 2.0f * GAIN
chrigelburri 1:6cd533a712c6 41
chrigelburri 2:d8e1613dc38b 42 #define MIN_DISTANCE_ERROR 0.03 // min. Distance to switch the position controller off. Because when Distance Error goes to zero the ATAN2 is not define, given in [m]
chrigelburri 0:31f7be68e52d 43
chrigelburri 0:31f7be68e52d 44 // LiPo Batterie
chrigelburri 2:d8e1613dc38b 45 #define BAT_MULTIPLICATOR 21.633333333f // R2 / (R1 + R2) = 0.153 R2= 10k , R1 = 1.8k 1/0.153 = 6.555 ---> 3.3 * 6.555 = 21.6333333f
chrigelburri 2:d8e1613dc38b 46 #define BAT_MIN 17.5f // minium operate voltage [V] Battery Type: 1SP1P LG-18650 --> nominal voltage 3.6V --> 5 batterys ==> 5 * 3.5V = 17.5V
chrigelburri 2:d8e1613dc38b 47
chrigelburri 0:31f7be68e52d 48 // Frequenz for the Task
chrigelburri 0:31f7be68e52d 49 #define PERIOD_COMPASS 0.050f // 20Hz Rate for Compass HMC6352
chrigelburri 0:31f7be68e52d 50 #define PERIOD_ROBOTCONTROL 0.001f // 1kHz Rate for Robot Control
chrigelburri 0:31f7be68e52d 51 #define PERIOD_STATE 0.001f // 1kHz Rate for State Objekt
chrigelburri 0:31f7be68e52d 52 #define PERIOD_ANDROID 0.1f // 10Hz Rate for State Objekt
chrigelburri 0:31f7be68e52d 53
chrigelburri 0:31f7be68e52d 54 // Compass Maxima und Minima for the Filter
chrigelburri 0:31f7be68e52d 55 #define SET_MAXIMAS_MINIMAS true // For Set the maximas und minimas when false the object search the maximas minimas by your own
chrigelburri 0:31f7be68e52d 56 /*#define COMP_X_MAX 344.464996f // Maximum X-Range
chrigelburri 0:31f7be68e52d 57 #define COMP_Y_MAX 238.751282f // Maximum Y-Range
chrigelburri 0:31f7be68e52d 58 #define COMP_Z_MAX -266.899994f // Maximum Z-Range not used in this side
chrigelburri 0:31f7be68e52d 59 #define COMP_X_MIN -90.412109f // Minimum X-Range
chrigelburri 0:31f7be68e52d 60 #define COMP_Y_MIN -220.834808f // Minimum Y-Range
chrigelburri 0:31f7be68e52d 61 #define COMP_Z_MIN -356.000000f // Minimun Z-Range not used in this side
chrigelburri 0:31f7be68e52d 62 */
chrigelburri 0:31f7be68e52d 63 #define COMP_X_MAX 391.219910f // Maximum X-Range
chrigelburri 0:31f7be68e52d 64 #define COMP_Y_MAX 382.915161f // Maximum Y-Range
chrigelburri 0:31f7be68e52d 65 #define COMP_Z_MAX -237.855042f // Maximum Z-Range not used in this side
chrigelburri 0:31f7be68e52d 66 #define COMP_X_MIN -169.952530f // Minimum X-Range
chrigelburri 0:31f7be68e52d 67 #define COMP_Y_MIN -247.647675f // Minimum Y-Range
chrigelburri 0:31f7be68e52d 68 #define COMP_Z_MIN -385.915009f // Minimun Z-Range not used in this side
chrigelburri 0:31f7be68e52d 69
chrigelburri 2:d8e1613dc38b 70 /**
chrigelburri 2:d8e1613dc38b 71 * struct state
chrigelburri 2:d8e1613dc38b 72 * structure containing system sensor data
chrigelburri 2:d8e1613dc38b 73 **/
chrigelburri 0:31f7be68e52d 74 typedef struct state {
chrigelburri 0:31f7be68e52d 75 /** millis Time [ms]*/
chrigelburri 0:31f7be68e52d 76 int millis;
chrigelburri 0:31f7be68e52d 77 /** Battery voltage [V] */
chrigelburri 0:31f7be68e52d 78 float voltageBattery;
chrigelburri 0:31f7be68e52d 79 /** Number of pulses left */
chrigelburri 0:31f7be68e52d 80 int leftPulses;
chrigelburri 0:31f7be68e52d 81 /** Number of pulses right */
chrigelburri 0:31f7be68e52d 82 int rightPulses;
chrigelburri 0:31f7be68e52d 83 /** Velocity left [m/s] */
chrigelburri 0:31f7be68e52d 84 float leftVelocity;
chrigelburri 0:31f7be68e52d 85 /** Velocity right [m/s] */
chrigelburri 0:31f7be68e52d 86 float rightVelocity;
chrigelburri 0:31f7be68e52d 87 /** Velocity of the car [m/s] */
chrigelburri 0:31f7be68e52d 88 float velocity;
chrigelburri 0:31f7be68e52d 89 /** Velocity rotation [°/s] */
chrigelburri 0:31f7be68e52d 90 float omega;
chrigelburri 0:31f7be68e52d 91 /** X-Axis from co-ordinate [m] */
chrigelburri 0:31f7be68e52d 92 float xAxis;
chrigelburri 0:31f7be68e52d 93 /** Y-Axis from co-ordinate [m] */
chrigelburri 0:31f7be68e52d 94 float yAxis;
chrigelburri 0:31f7be68e52d 95 /** X-Axis Error [m] */
chrigelburri 0:31f7be68e52d 96 float xAxisError;
chrigelburri 0:31f7be68e52d 97 /** X-Axis Error [m] */
chrigelburri 0:31f7be68e52d 98 float yAxisError;
chrigelburri 0:31f7be68e52d 99 /** Angle Error [°] */
chrigelburri 0:31f7be68e52d 100 float angleError;
chrigelburri 0:31f7be68e52d 101 /** Angle from Car [°] */
chrigelburri 0:31f7be68e52d 102 float angle;
chrigelburri 0:31f7be68e52d 103 /** Setpoint X-Axis [m] */
chrigelburri 0:31f7be68e52d 104 float setxAxis;
chrigelburri 0:31f7be68e52d 105 /** Setpoint Y-Axis [m] */
chrigelburri 0:31f7be68e52d 106 float setyAxis;
chrigelburri 0:31f7be68e52d 107 /** Setpoint Angel [°] */
chrigelburri 0:31f7be68e52d 108 float setAngle;
chrigelburri 0:31f7be68e52d 109 /** Right Distance Sensor [m] */
chrigelburri 0:31f7be68e52d 110 float rightDist;
chrigelburri 0:31f7be68e52d 111 /** Compass Angle [°] */
chrigelburri 0:31f7be68e52d 112 float compassAngle;
chrigelburri 0:31f7be68e52d 113 /** Compass X-Axis */
chrigelburri 0:31f7be68e52d 114 float compassxAxis;
chrigelburri 0:31f7be68e52d 115 /** Compass Y-Axis */
chrigelburri 0:31f7be68e52d 116 float compassyAxis;
chrigelburri 0:31f7be68e52d 117 /** State of the Car **/
chrigelburri 0:31f7be68e52d 118 int state;
chrigelburri 2:d8e1613dc38b 119 /** distance to Goal */
chrigelburri 2:d8e1613dc38b 120 float rho;
chrigelburri 2:d8e1613dc38b 121 /** theta to goal */
chrigelburri 2:d8e1613dc38b 122 float lamda;
chrigelburri 2:d8e1613dc38b 123 /** theta from the goal */
chrigelburri 2:d8e1613dc38b 124 float delta;
chrigelburri 0:31f7be68e52d 125 } state_t;
chrigelburri 0:31f7be68e52d 126
chrigelburri 0:31f7be68e52d 127
chrigelburri 0:31f7be68e52d 128 #endif