00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <math.h>
00032
00033 #define OBOT_DEFAULT_PORT "/dev/usb/ttyUSB1"
00034
00035
00036 #define OBOT_DELAY_US 10000
00037
00038
00039
00040 #define OBOT_AXLE_LENGTH 0.317
00041 #define OBOT_WHEEL_DIAM 0.10795
00042 #define OBOT_WHEEL_CIRCUM (OBOT_WHEEL_DIAM * M_PI)
00043 #define OBOT_TICKS_PER_REV 11600.0
00044 #define OBOT_M_PER_TICK (OBOT_WHEEL_CIRCUM / OBOT_TICKS_PER_REV)
00045
00046 #define OBOT_PID_FREQUENCY (1/1.9375e-3)
00047 #define OBOT_MAGIC_TIMING_CONSTANT 1.0
00048 #define OBOT_MPS_PER_TICK (OBOT_M_PER_TICK * OBOT_PID_FREQUENCY / \
00049 OBOT_MAGIC_TIMING_CONSTANT)
00050
00051
00052 #define OBOT_MAX_TICS 2147483648U
00053
00054
00055
00056 #define OBOT_MAX_WHEELSPEED 5.0
00057
00058
00059 #define OBOT_MIN_WHEELSPEED_TICKS 5
00060
00061
00062
00063 #define OBOT_ACK 6 // if command acknowledged
00064 #define OBOT_NACK 21 // if garbled message
00065
00066 #define OBOT_INIT1 253 // The init commands are used in sequence(1,2,3)
00067 #define OBOT_INIT2 252 // to initialize a link to a cerebellum.
00068 #define OBOT_INIT3 251 // It will then blink green and start accepting other
00069
00070
00071 #define OBOT_DEINIT 250
00072
00073 #define OBOT_SET_VELOCITIES 118 // 'v'(left_vel, right_vel) as 16-bit signed ints
00074 #define OBOT_SET_ACCELERATIONS 97 // 'a'(left_accel, right_accel) as 16-bit unsigned ints
00075 #define OBOT_ENABLE_VEL_CONTROL 101 // 'e'()
00076 #define OBOT_DISABLE_VEL_CONTROL 100 // 'd'()
00077 #define OBOT_GET_ODOM 111 // 'o'()->(left_count, right_count, left_vel, right_vel)
00078 #define OBOT_GET_VOLTAGE 98 // 'b'()->(batt_voltage)
00079 #define OBOT_STOP 115 // 's'() [shortcut for set_velocities(0,0)]
00080 #define OBOT_KILL 107 // 'k'() [shortcut for disable_velocity_control]
00081 #define OBOT_HEARTBEAT 104 // 'h'() sends keepalive
00082
00083
00084