Implement new controller

Dependencies:   mbed-rtos mbed QEI BNO055 MPU6050_DMP_Nucleo-I2Cdev virgo3_imuHandler_Orion_PCB MAX17048 Servo

Fork of Orion_newPCB_test by Team Virgo v3

Committer:
ahmed_lv
Date:
Tue Mar 20 05:56:22 2018 +0000
Revision:
30:44676e1b38f8
Parent:
28:39d694b0e998
Editted Input Variables to PID

Who changed what in which revision?

UserRevisionLine numberNew contents of line
akashvibhute 2:761e3c932ce0 1 /*
akashvibhute 2:761e3c932ce0 2 *
akashvibhute 2:761e3c932ce0 3 * config.h Virgo v3 PCB AV22032015
akashvibhute 2:761e3c932ce0 4 *
akashvibhute 2:761e3c932ce0 5 */
akashvibhute 2:761e3c932ce0 6
akashvibhute 2:761e3c932ce0 7 #ifndef VirgoConfig_H
akashvibhute 2:761e3c932ce0 8 #define VirgoConfig_H
akashvibhute 2:761e3c932ce0 9
akashvibhute 2:761e3c932ce0 10 //** General Functions ****************************************************************************
akashvibhute 2:761e3c932ce0 11 #define PC_BAUDRATE 921600
akashvibhute 2:761e3c932ce0 12
akashvibhute 2:761e3c932ce0 13 //-------------------------------------------------------------------------------------------------
akashvibhute 2:761e3c932ce0 14
akashvibhute 2:761e3c932ce0 15 //** Function exectution rates ********************************************************************
akashvibhute 6:690db8b5030b 16 #define Hearbeat_RateHz 1 //hearbeat loop run rate in Hz
akashvibhute 4:315716ef8178 17 #define Hearbeat_RateMS (1000/Hearbeat_RateHz) //hearbeat loop run rate in ms
akashvibhute 4:315716ef8178 18
akashvibhute 15:23d79bb4eaf2 19 #define imu_UpdateRateHz 110 // imu update rate in Hz
akashvibhute 4:315716ef8178 20 #define imu_UpdatePeriodMS (1000/imu_UpdateRateHz) // imu update rate in ms
akashvibhute 4:315716ef8178 21
ahmed_lv 28:39d694b0e998 22 #define motorControl_UpdateRateHz 50// 200 // motorControl update rate in Hz
akashvibhute 4:315716ef8178 23 #define motorControl_UpdatePeriodMS (1000/motorControl_UpdateRateHz) // motorControl update rate in ms
akashvibhute 4:315716ef8178 24
akashvibhute 2:761e3c932ce0 25 #define odometry_UpdateRateHz 125 //odometry update rate in Hz
akashvibhute 4:315716ef8178 26 #define odometry_UpdatePeriodMS (1000/odometry_UpdateRateHz) //odometry update rate in ms
akashvibhute 4:315716ef8178 27
akashvibhute 15:23d79bb4eaf2 28 #define PrintLoop_RateHz 10 //print loop run rate in Hz
akashvibhute 4:315716ef8178 29 #define PrintLoop_PeriodMS (1000/PrintLoop_RateHz) //print loop run rate in ms
akashvibhute 4:315716ef8178 30
akashvibhute 2:761e3c932ce0 31 #define PurePursuit_UpdateRateHz 20//Pure pursuit update run rate in Hz
akashvibhute 4:315716ef8178 32 #define PurePursuit_UpdatePeriodMS (1000/PurePursuit_UpdateRateHz)//Pure pursuit update run rate in ms
akashvibhute 4:315716ef8178 33
akashvibhute 2:761e3c932ce0 34 #define WaypointCmd_UpdateRateHz 10 //waypoint commander run rate in Hz
akashvibhute 4:315716ef8178 35 #define WaypointCmd_UpdatePeriodMS (1000/WaypointCmd_UpdateRateHz) //waypoint commander run rate in ms
akashvibhute 4:315716ef8178 36
akashvibhute 15:23d79bb4eaf2 37 #define CommLoop_UpdateRateHz 100 //Communications loop run rate in Hz
akashvibhute 4:315716ef8178 38 #define CommLoop_UpdatePeriodMS (1000/CommLoop_UpdateRateHz) //Communications loop run rate in ms
akashvibhute 4:315716ef8178 39
akashvibhute 15:23d79bb4eaf2 40 #define CommPump_UpdateRateHz 500 //nRF network communications pump run rate in Hz
akashvibhute 5:099cb2e76c7d 41 #define CommPump_UpdatePeriodMS (1000/CommPump_UpdateRateHz) //nRF network communications pump run rate in ms
akashvibhute 5:099cb2e76c7d 42
akashvibhute 15:23d79bb4eaf2 43 //#define nRfDefault_uploadRateMS 200 //default upload rate in ms for nRF wireless comm
akashvibhute 5:099cb2e76c7d 44
akashvibhute 5:099cb2e76c7d 45 #define camera_cycleMinutes 15 //default camera switch on frequency in minutes
akashvibhute 2:761e3c932ce0 46 #define camera_CaptureTimeS 30 //default camera capture time in seconds
akashvibhute 10:ea4b90be68dc 47
akashvibhute 10:ea4b90be68dc 48 #define DataRecorder_RateHz 100 //data recorder loop run rate in Hz
akashvibhute 10:ea4b90be68dc 49 #define DataRecorder_PeriodMS (1000/DataRecorder_RateHz) //data recorder loop run rate in ms
akashvibhute 2:761e3c932ce0 50 //-------------------------------------------------------------------------------------------------
akashvibhute 2:761e3c932ce0 51
akashvibhute 4:315716ef8178 52
akashvibhute 4:315716ef8178 53 //** Drivetrain ********************************************************************************
akashvibhute 4:315716ef8178 54 //** Motor **
akashvibhute 4:315716ef8178 55 #define PWMfreq_khz 20
akashvibhute 2:761e3c932ce0 56
akashvibhute 10:ea4b90be68dc 57 #define PIDFf_kP 0.50
akashvibhute 10:ea4b90be68dc 58 #define PIDFf_kI 1.50
akashvibhute 10:ea4b90be68dc 59 #define PIDFf_kD 0.20
akashvibhute 10:ea4b90be68dc 60 #define PIDFf_kFf 2.50
akashvibhute 2:761e3c932ce0 61
akashvibhute 10:ea4b90be68dc 62 #define PIDFf_lim_P 0.05
akashvibhute 10:ea4b90be68dc 63 #define PIDFf_lim_I 0.30
akashvibhute 10:ea4b90be68dc 64 #define PIDFf_lim_D 0.05
akashvibhute 10:ea4b90be68dc 65 #define PIDFf_lim_Ff 0.60
akashvibhute 2:761e3c932ce0 66
akashvibhute 6:690db8b5030b 67 #define PIDFf_range_min -1.0
akashvibhute 6:690db8b5030b 68 #define PIDFf_range_max 1.0
akashvibhute 2:761e3c932ce0 69
akashvibhute 2:761e3c932ce0 70 #define pid_MWindowSize 10
akashvibhute 6:690db8b5030b 71
akashvibhute 6:690db8b5030b 72 //#define motor_LimitRPM_min -100.0
akashvibhute 6:690db8b5030b 73 //#define motor_LimitRPM_max 300.0
akashvibhute 6:690db8b5030b 74
akashvibhute 6:690db8b5030b 75 //#define motor_Acc_limit 200.0
akashvibhute 4:315716ef8178 76 //-------------
akashvibhute 2:761e3c932ce0 77
akashvibhute 4:315716ef8178 78 //** Encoder **
ahmed_lv 28:39d694b0e998 79 #define encoder_resolution 408.168 // Number of counts per revolution
ahmed_lv 28:39d694b0e998 80 #define encoder_MWindowSize 10
akashvibhute 4:315716ef8178 81 //-------------
akashvibhute 2:761e3c932ce0 82 //-------------------------------------------------------------------------------------------------
akashvibhute 2:761e3c932ce0 83
akashvibhute 2:761e3c932ce0 84
akashvibhute 4:315716ef8178 85
akashvibhute 2:761e3c932ce0 86 //** Localization *********************************************************************************
akashvibhute 4:315716ef8178 87 //** IMU **
akashvibhute 4:315716ef8178 88 #define Pose_MWindowSize 10
akashvibhute 15:23d79bb4eaf2 89 #define GyroAcc_MWindowSize 10
akashvibhute 4:315716ef8178 90
ahmed_lv 28:39d694b0e998 91 //* MPU6050 *
akashvibhute 4:315716ef8178 92 #define MPU6050_StabilizationReadings 10 //number of non deviating data points to determine if imu has stabilized
akashvibhute 4:315716ef8178 93 #define IMU_FIFO_RATE_DIVIDER 0x01 // FIFO rate = 200Hz / (1 + this value), range 0x00 to 0x09. Here, 0x01 implies 100Hz.
akashvibhute 4:315716ef8178 94 #define IMU_SAMPLE_RATE_DIVIDER 1 // Sample rate = 1kHz / (1 + this value), Here, 1 implies 500Hz.
akashvibhute 4:315716ef8178 95 #define MPU6050_GYRO_FS MPU6050_GYRO_FS_2000 // measuring range of gyroscope (±n deg/s)
akashvibhute 4:315716ef8178 96 #define MPU6050_ACCEL_FS MPU6050_ACCEL_FS_2 // measuring range of acceleration sensor (±n g)
akashvibhute 4:315716ef8178 97 //* ** *
akashvibhute 4:315716ef8178 98
akashvibhute 4:315716ef8178 99 //* BNO055 *
akashvibhute 11:49344285c82a 100 #define BNO055_StabilizationReadings 200 //number of non deviating data points to determine if imu has stabilized
akashvibhute 4:315716ef8178 101
akashvibhute 4:315716ef8178 102 //* ** *
akashvibhute 4:315716ef8178 103
akashvibhute 5:099cb2e76c7d 104 //* Localization *
ahmed_lv 28:39d694b0e998 105 #define wheel_dia 60 //wheel dia in mm * effective hypocyclic gear ratio
ahmed_lv 28:39d694b0e998 106 #define track_width 165 // in mm
akashvibhute 5:099cb2e76c7d 107
akashvibhute 2:761e3c932ce0 108
akashvibhute 2:761e3c932ce0 109 //-------------------------------------------------------------------------------------------------
akashvibhute 2:761e3c932ce0 110
akashvibhute 2:761e3c932ce0 111
akashvibhute 10:ea4b90be68dc 112 //** PurePursuit controller *************************************************************************
ahmed_lv 28:39d694b0e998 113 #define track_width 165 //track width in mm
ahmed_lv 28:39d694b0e998 114 #define driveTrain_minV 10//175 //min velocity of individual drive in mm/s
ahmed_lv 28:39d694b0e998 115 #define driveTrain_maxV 700//235 //max velocity of individual drive in mm/s
akashvibhute 2:761e3c932ce0 116
akashvibhute 2:761e3c932ce0 117 //-------------------------------------------------------------------------------------------------
akashvibhute 2:761e3c932ce0 118
akashvibhute 2:761e3c932ce0 119 //** Communications *******************************************************************************
akashvibhute 2:761e3c932ce0 120 #define virgo3_robot_address 01 //address of this robot node
akashvibhute 20:2720a283d1c5 121 #define virgo3_network_channel 68 //communications channel number
akashvibhute 2:761e3c932ce0 122
akashvibhute 2:761e3c932ce0 123 //-------------------------------------------------------------------------------------------------
akashvibhute 2:761e3c932ce0 124
akashvibhute 2:761e3c932ce0 125
akashvibhute 10:ea4b90be68dc 126 //** Attitude Controller **************************************************************************
akashvibhute 2:761e3c932ce0 127 #define wheelV_MWindowSize 25 //wheel velocity moving window filter size, customized for Pitch controller
akashvibhute 2:761e3c932ce0 128
akashvibhute 10:ea4b90be68dc 129 //** HansonController **
akashvibhute 10:ea4b90be68dc 130
akashvibhute 10:ea4b90be68dc 131
akashvibhute 10:ea4b90be68dc 132 //** PID pitch controller **
akashvibhute 10:ea4b90be68dc 133 // This PID controller adds/subtracts a percentage of command velocity based on the variations of
akashvibhute 10:ea4b90be68dc 134 // the pitch angle while controlling the pitch angle to a setpoint angle.
akashvibhute 10:ea4b90be68dc 135
akashvibhute 13:d971833e28ea 136 #define AttPIDFf_kP 9.00
akashvibhute 13:d971833e28ea 137 #define AttPIDFf_kI 1.00
akashvibhute 13:d971833e28ea 138 #define AttPIDFf_kD 0.10
akashvibhute 10:ea4b90be68dc 139 #define AttPIDFf_kFf 0.00
akashvibhute 10:ea4b90be68dc 140
akashvibhute 13:d971833e28ea 141 #define AttPIDFf_lim_P 0.6
akashvibhute 13:d971833e28ea 142 #define AttPIDFf_lim_I 0.1
akashvibhute 10:ea4b90be68dc 143 #define AttPIDFf_lim_D 0.3
akashvibhute 10:ea4b90be68dc 144 #define AttPIDFf_lim_Ff 0.0
akashvibhute 10:ea4b90be68dc 145
akashvibhute 10:ea4b90be68dc 146 #define AttPIDFf_range_min -1.0
akashvibhute 10:ea4b90be68dc 147 #define AttPIDFf_range_max 1.0
akashvibhute 10:ea4b90be68dc 148
akashvibhute 10:ea4b90be68dc 149
akashvibhute 2:761e3c932ce0 150 //-------------------------------------------------------------------------------------------------
akashvibhute 10:ea4b90be68dc 151
akashvibhute 10:ea4b90be68dc 152 //** Data Recorder ********************************************************************************
akashvibhute 10:ea4b90be68dc 153 #define max_coloumns 16
akashvibhute 11:49344285c82a 154 //#define max_rows 1200
akashvibhute 11:49344285c82a 155 #define max_rows 120
akashvibhute 15:23d79bb4eaf2 156 #define max_RAM 16*1024 //max permissible ram usage in kB
akashvibhute 10:ea4b90be68dc 157
akashvibhute 10:ea4b90be68dc 158 //-------------------------------------------------------------------------------------------------
akashvibhute 10:ea4b90be68dc 159
akashvibhute 10:ea4b90be68dc 160
akashvibhute 2:761e3c932ce0 161 #endif /* VirgoConfig_H */