Guest User

Untitled

a guest
Aug 24th, 2024
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 50.19 KB | None | 0 0
  1. // Ardumower Sunray
  2. // Copyright (c) 2013-2020 by Alexander Grau, Grau GmbH
  3. // Licensed GPLv3 for open source use
  4. // or Grau GmbH Commercial License for commercial use (http://grauonline.de/cms2/?page_id=153)
  5.  
  6. /*
  7. WARNING: all software, hardware and motor components are designed and optimized as a whole, if you
  8. try to replace or exclude some component not as designed, you risk to damage your hardware with
  9. the software.
  10.  
  11. see Wiki for installation details:
  12. http://wiki.ardumower.de/index.php?title=Ardumower_Sunray
  13.  
  14. requirements:
  15. + Ardumower chassis and Ardumower kit mowing and gear motors
  16. + Ardumower PCB 1.3/1.4
  17. + Adafruit Grand Central M4 (highly recommended) or Arduino Due
  18. + Ardumower BLE UART module (HM-10/CC2540/CC2541)
  19. + optional: Ardumower IMU (MPU6050/MPU9150/MPU9250/MPU9255) - choose your IMU below
  20. + optional: Ardumower WIFI (ESP8266 ESP-01 with stock firmware)
  21. + optional: HTU21D temperature/humidity sensor
  22. + optional: sonar, bumperduino, freewheel sensor
  23. + Ardumower RTK (ublox F9P)
  24.  
  25.  
  26. 1. Rename file 'config_example.h' into 'config.h'
  27.  
  28. 2. Configure the options below and finally compile and upload this project.
  29.  
  30.  
  31. Adafruit Grand Central M4 NOTE: You have to add SDA, SCL pull-up resistors to the board
  32. and deactivate Due clone reset cicuit (JP13):
  33. https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#Adafruit_Grand_Central_M4
  34. NOTE: If you get compilation errors with Adafruit Grand Central M4, you may have to downgrade 'Adafruit SAMD Boards' to version to 1.7.5.
  35.  
  36. Arduino Due UPLOAD NOTE:
  37.  
  38. If using Arduino Due 'native' USB port for uploading, choose board 'Arduino Due native' in the
  39. Arduino IDE and COM port 'Arduino Due native port'.
  40.  
  41. If using Arduino Due 'programming' USB port for uploading, choose board 'Arduino Due programming' in the
  42. Arduino IDE and COM port 'Arduino Due programming port'.
  43.  
  44. Also, you may choose the serial port below for serial monitor output (CONSOLE).
  45.  
  46. */
  47.  
  48.  
  49. #define DRV_SERIAL_ROBOT 1 // Linux (Alfred)
  50. //#define DRV_CAN_ROBOT 1 // Linux (owlRobotics platform)
  51. //#define DRV_ARDUMOWER 1 // keep this for Ardumower
  52.  
  53. //#define DRV_SIM_ROBOT 1 // simulation
  54.  
  55. // ------- Bluetooth4.0/BLE module -----------------------------------
  56. // see Wiki on how to install the BLE module and configure the jumpers:
  57. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#Bluetooth_BLE_UART_module
  58. #define ENABLE_PASS 1 // comment out to disable password authentication
  59. #define PASS 123456 // choose password for WiFi/BLE communication (NOTE: has to match the connection password in the App!)
  60.  
  61. // -------- IMU sensor ----------------------------------------------
  62. // choose one MPU IMU (make sure to connect AD0 on the MPU board to 3.3v)
  63. // verify in CONSOLE that your IMU was found (you will hear 8 buzzer beeps for automatic calibration at start)
  64. // see Wiki for wiring, how to position the module, and to configure the I2C pullup jumpers:
  65. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#IMU.2C_sensor_fusion
  66.  
  67. #define MPU6050
  68. //#define MPU9150
  69. //#define MPU9250 // also choose this for MPU9255
  70. //#define BNO055
  71. //#define ICM20948
  72. #define MPU_ADDR 0x69 // I2C address (0x68 if AD0=LOW, 0x69 if AD0=HIGH)
  73.  
  74. // imu fifo rate (Hz)
  75. #define IMU_FIFO_RATE 5
  76.  
  77. // should the mower turn off if IMU is tilt over? (yes: uncomment line, no: comment line)
  78. #define ENABLE_TILT_DETECTION 1
  79.  
  80. // --------- lift sensor (only Alfred mower) ---------------------------------------------
  81. // should the lift sensor be enabled? (yes: uncomment line, no: comment line)
  82. #define ENABLE_LIFT_DETECTION 1
  83. // should the lift sensor be used for obstacle avoidance (if not, mower will simply go into error if lifted)
  84. #define LIFT_OBSTACLE_AVOIDANCE 1
  85.  
  86. ////////////////////////////////////////////////////////////////////////////////////////////////////
  87. //Modsection START
  88. //please keep in mind that there are bugs, but if you encounter bugs that stop the operation of mower on an area completely please tell me about it...
  89.  
  90. //Experimental Modfunctions/Options/Speeds/Time etc. for different stuff and movement operations. Please read the descriptions. Cheers.
  91. //Mower general times and speeds with their condition parameters
  92. #define MOWSPINUPTIME 10000 // (ms) Adds time to rotate mowingdisc before starting moving, use high value if you enable ESCAPE_LAWN for good reading of idle mow motor RPM
  93. #define OVERLOADSPEED 0.15 // (m/s) if there is a overloadcurrent of a motordriver, mower will use OVERLOADSPEED
  94. #define ROTATETOTARGETSPEED1 65.0 // (deg/s) if angle difference to point is more than ANGLEDIFF1 then this value will be used... warning, a high value will result in extreme gearmotor stress (test at own risk, 65deg/s is still safe and fast)
  95. #define ROTATETOTARGETSPEED2 40.0 // (deg/s) if angle difference to point is between ANGLEDIFF1 and ANGLEDIFF2 then this value will be used...
  96. #define ROTATETOTARGETSPEED3 25.0 // (deg/s) if angle difference to point is less than ANGLEDIFF2 then this value will be used...
  97. #define ANGLEDIFF1 30.0 // (deg) if angle to point is more than ANGLEDIFF1 --> ROTATETOTARGETSPEED1 will be used
  98. #define ANGLEDIFF2 15.0 // (deg) if angle to point is between ANGLEDIFF1 and ANGLEDIFF2 --> ROTATETOTARGETSPEED2 will be used, if it is less ROTATETOTARGETSPEED3 will be used...
  99. #define ANGLEPRECISE 5.0 // (deg) if Angle to point ist within 5deg, mower will continue with Linetracker.cpp Stanleycode and NEARWAYPOINT setup
  100. #define TRACKSLOWSPEED 0.20 // (m/s) e.g the docking speed or functions of the future
  101. #define NEARWAYPOINTSPEED 0.25 // (m/s) defines the speed of mower when reaching/leaving a waypoint
  102. #define NEARWAYPOINTDISTANCE 0.45 // (m) defines the distance of mower if approaching and leaving a waypoint and thus triggers NEARWAYPOINTSPEED of mower
  103. #define FLOATSPEED 0.25 // (m/s) on GPS FLOAT SOLUTION, mower will use FLOATSPEED
  104. #define SONARSPEED 0.15 // (m/s) if sonar enabled and used, on sonar trigger mower will use SONARSPEED
  105. #define DOCKANGULARSPEED 25.0 // (deg/s) the turning rate of mower when docking (no change needed, keep low; tune at your needs if you must)
  106. #define OBSTACLEAVOIDANCESPEED 0.35 // (m/s) on obstacle evade operations, mower will use OBSTACLEAVOIDANCESPEED
  107. #define ESCAPE_REVERSE_WAY 0.45 // (m) distance in meters the mover will drive reverse in escapeReverseOp if obstacle triggered eg. by bumper org gps no speed
  108. #define ESCAPE_FORWARD_WAY 0.25 // (m) distance in meters the mover will drive forward in escapeForwardOp if obstacle triggered by OBSTACLE_ROTATION (no rotation)
  109. #define GLOBALSPEEDLIMIT true // if true, MOTOR_MAX_SPEED and MOTOR_MIN_SPEED will limit possible code bugs or inputs directly in motor.cpp
  110. #define MOTOR_MAX_SPEED 0.60 // (m/s) maximum mower speed
  111. #define MOTOR_MIN_SPEED 0.05 // (m/s) minimal mower speed
  112. //use a PID controller for mowmotor to set an RPM instead of PWM? If you use this (there will be a console output with data after 10sec when you activate the mowmotor and this is enabled)
  113. #define USE_MOW_RPM_SET true // uses RPM instead of PWM to set mowmotor (RPM_FAULT_DETECTION of orig Sunray needs to be TRUE for all RPM based functions!!)
  114. #define MOWMOTOR_RPM_OFFSET 110 // compensate small RPM offsets (positive if RPM reading is less then RPM setpoint)
  115. #define MOWMOTOR_PID_KP 0.0024// (0.0024 Mowmotordriver DRV8308) (0.0018 JYQD) this is enough to compensate battery drainage over time and have a slow spinup, there may be a controlleroffset to rpm which has to be thought of... RPM_OFFSET
  116. #define MOWMOTOR_PID_KI 0.002 // (0.04 (Mowmotordriver DRV8308/JYQD))
  117. #define MOWMOTOR_PID_KD 0.00 // (0.0000 (Mowmotordriver DRV8308/JYQD))
  118. //adaptive_speed settings on RPM or LOAD of mowmotor (consider if you have mowmotor odometrie)
  119. #define ADAPTIVE_SPEED true // if true, mowing speed will adjust to RPM or MOWMOTORPOWER of mow motor on all forward speed mow operations, only available if ENABLE_RPM_FAULT_DETECTION true
  120. #define MOWMOTORPOWER true // uses Power (Watts) for adaptive speed instead of mowRPM (best)
  121. #define MOWPOWERMIN 10.0 // (Watt) idle Power of Mowmotor or minimum load power of mowmotor, if under this load mower will have maximum speed
  122. #define MOWPOWERMAX 50.0 // (Watt) max load power of mowmotor, when hitting this load mower will be at minspeed
  123. #define MOW_RPM_NORMAL 3000 // (3200)(rpm) mow motor rpm for mowing (WARNING, you should check if your rpm output works as espected! if it does work, but the reading is wrong, you need to calculate the mowmotorticks per second according to realistic rpm!)
  124. #define MOW_RPM_SLOW 3300 // (3400)(rpm) mow motor rpm when MOW_RPMtr_SLOW (%) of MOW_RPM_NORMAL (rpm) is met. Should be higher or the same as MOW_RPM_NORMAL
  125. #define MOW_RPM_RETRY 3600 // (3600)(rpm) mow motor rpm when MOW_RPMtr_RETRY (%) of MOW_RPM_NORMAL (rpm) is met. Should be higher or the same as MOW_RPM_SLOW4 (is only used by ESCAPE_LAWN)
  126. //escapeLawn operation, mower will backup on a mowmotor stall and retry with given values... after the first try and still stalling, it backs up and waits for mowmotor to recover
  127. #define ESCAPE_LAWN true // mower drives reverse if true and RPM stall of mow motor is detected by more than MOW_RPMtr_STALL(percentage), only available if ENABLE_RPM_FAULT_DETECTION true
  128. //#define ESCAPE_LAWN_MOWMOTORPOWER true //not yet implemented... will get rid of RPM triggers and use power of mowmotor instead of rpm readings to trigger this function (testing)
  129. #define MOW_RPMtr_STALL 60 // (70)(%) if RPM of mowmotor stalls under % of MOW_RPM_NORMAL mower will back up with ESCAPELAWNDISTANCE and ESCAPELAWNSPEED and try again
  130. #define MOW_RPMtr_SLOW 75 // (85)(%) if RPM of mowmotor stalls under % of MOW_RPM_NORMAL mower will trigger a keepSlow state with KEEPSLOWSPEED
  131. #define ESCAPELAWNSPEED 0.35 // (m/s) speed of mower reverse due to MOW_RPM_STALL trigger
  132. #define ESCAPELAWNDISTANCE 0.5 // (m) distance mower reverses with ESCAPELAWNSPEED due to MOW_RPM_STALL triggered
  133. #define ESCAPELAWNWAITTIME 5000 // (ms)after reversing the second time within ESCAPELAWNTIMER, mower will wait for this time before continue (recover rpm)
  134. #define ESCAPELAWNTIMER 20000 // (ms)timer to reset retries of ESCAPELAWN, if time is met and retries stay under MAXRETRY triggercounter will reset, otherwise there will be an obstacle error
  135. #define ESCAPELAWN_DEADTIME 3000 // (ms)deadtime between allowed ESCAPELAWN triggers (deadtime should be the reverse time of action and be calculated in code :| )
  136. #define MAXRETRY 5 // number of possible retries of ESCAPELAWN within ESCAPELAWNTIMER until there will be an obstacle error or obstacle avoidance
  137. #define MAXRETRYOBSTACLE false // if true, ESCAPELAWN will trigger Obstacle avoidance when to many MAXRETRY´s and will not trigger an error
  138. #define RETRYSLOWSPEED 0.15 // (ms) if ESCAPELAWN true, mower will back up with ESCAPELAWNSPEED if RPM stall is detected and retry mowing forward with RETRYSPEED until RETRYSLOWTIME is met, then it will continue with normal Speed
  139. #define KEEPSLOWSPEED 0.25 // mower will use this speed if there is a rpm stall (%) of mowingblades defined by MOW_RPMtr_SLOW
  140. #define RETRYSLOWTIME 15000 // (ms) mower will continue slow with RETRY_SLOW_SPEED after ESCAPELAWN operation (reversing triggered by MOW_RPMtr_RETRY (%)) for RETRYSLOWTIME, if a MOW_RPMtr_SLOW will happen again in this retryslowstate, mower resets this timer until no rpm stall occurs in set time
  141. #define KEEPSLOWTIME 15000 // (ms) mower will continue slow with KEEP_SLOW_SPEED for given Time if MOW_RPMtr_SLOW (%) was met... if a MOW_RPMtr_SLOW will happen again during keepslowstate, mower resets this timer until no rpm stall occurs in set time.
  142. //stanley options for experiments
  143. #define MAP_STANLEY_CONTROL true // if true, stanley values will be mapped linear from MOTOR_MIN_SPEED-->MOTOR_MAX_SPEED with SC_P_*|SC_K_* to actual speedset of mower (recommended if you use high operation speeds)
  144. #define STANLEYNORMALMUL false // if true, StanleyNormal parameters in Sunray-App will be multiplied by 10! (0,1 = 1) (for testing)
  145. //svol0s GPS reboot option after undocking-->mowing
  146. #define GPS_REBOOT true // if false and DOCK_POINT_GPS_REBOOT is not 0, mower will wait at the DOCK_POINT_GPS_REBOOT point for fix without rebooting GPS, if false and DOCK_POINT_GPS_REBOOT = 0 this function is off (hopefully)
  147. #define GPSWAITREBOOT 15000 // (ms) time to wait after rebooting gps for response from ublox?
  148. #define GPS_STABLETIME 30000 // (ms) GPS Time with fix solution, before continueing from DOCK_POINT_GPS_REBOOT after undock
  149. #define DOCK_POINT_GPS_REBOOT 3 // (pt)(MrTree: Warning, you need 3 more dockpoints than this number, or there will be bugs! so, if there is 4 defined, you need 7 on the Map!) Svol0: dockingpoint number (counted from last dockingpoint) where the gps will be rebooted and waited for gps-fix by undocking. 0 = no gps reboot by undocking. MrTree: if not "0" and GPS_REBOOT = false, mower will wait at the point for fix without rebooting GPS
  150. #define DOCK_SLOW_ONLY_LAST_POINTS 4 // (pt) Svol0: dockingpoint number (counted from last dockingpoint) where slow speed will be used to reach the dockingstation (0 = all points will be reached with slow speed)
  151. //keep mower from rotating in dock by all means, needs situation dependent tuning, so be aware!
  152. #define DOCK_NO_ROTATION true // if true, rotation for the mower when reaching or leaving the last dockpoint is not allowed! Make sure mower comes just before the dock in a straight line from the point before, then the last point is the dockposition, on that path angular steering is not allowed!
  153. #define DOCK_NO_ROTATION_DISTANCE 1.0 // (m) distance to dockpoint to stop angular motion of mower, make sure mower comes straight to dock!
  154. #define DOCK_NO_ROTATION_TIMER 12000 // (ms) if mower doesnt hit the charger in given time after passing dockpoint before last dockpoint(charger), an obstacle will be triggered and mower will reverse to gps reboot point and try again.
  155. //#define DOCK_NO_ROTATION_DELAY 2000 // (ms) gives the mower time to surpass the point before dockpoint by given time, after this timer angular will be clamped to zero!
  156. #define DOCK_NO_ROTATION_SPEED 0.15 // (m/s) (original it was 0.10, made it changeable...) when angular is not allowed while going to dockposition, this speed is used
  157. //GPS
  158. #define GPS_RESET_WAIT_FIX true // reset GPS if mower is in a float timeout?
  159. #define GPS_RESET_WAIT_FIX_TIME 15 // (min) time in minutes to reset gps if mower is in a float timeout without getting fix within GPS_RESET_WAIT_FIX_TIME
  160. //other tests
  161. #define SUPER_SPIKE_ELIMINATOR 0 // advanced spike elimination (experimental, comment out to disable)
  162. //obstacle behaviour when OBSTACLE_ROTATION is enabled and escapeForward is triggered due to IMUYaw difference (wheel at backside, popo situation)
  163. #define CHANGE_OBSTACLE_ROTATION true // if true, after 2 times moving forward due to an IMUyaw difference or OVERLOAD_ROTATION with escapeForward because of FREEWHEEL_IS_AT_BACKSIDE, escapeReverse with obstacle is triggered (prevent mower going forward if it can´t rotate and already tried to evade with escapeForward op)
  164. #define OVERLOAD_ROTATION true // this function is dependent of FREEWHEEL_IS_AT_BACKSIDE and is usefull if there is alot of grip of wheels which lead to a high current and can result in a motor error overcurrent, before that happens... we want an evasion of the situation. If FREEWHEEL_IS_AT_BACKSIDE is true mower will drive forward on MOTOROVERLOAD if mower state is shouldrotate... otherwise it will trigger an Obstacle and escapeReverse (front snout of mower is hitting something during rotation)
  165. //try to fix 8308 driver with pwm (keep FALSE if you have no issues or no DRV8308, this is for experiments only)
  166. #define DRV8308_FIX false // only for testing, if true and charger is connected, drivers pwm will be 1 for DRVFIXITERATIONS iteration of code everytime DRVFIXTIMER is met
  167. #define DRVFIXITERATIONS 5 // iterations of code for pwm of drivers to be PWM_GEAR and PWM_MOW (below)
  168. #define DRVFIXTIMER 60000 // (ms) timer for DRV8308_FIX, everytime timer is met, function will run once for DRVFIXITERATIONS and set pwm of drivers to 1
  169. #define PWM_GEAR 1 // PWM for DRVFIX efforts..
  170. #define PWM_MOW 1 // PWM for DRVFIX efforts..
  171. //try to fix 8308 driver with moving, only works reliable with "DOCK_RETRY_TOUCH = true"! tested and seems to be a valid workaround for the DRV8308 related dock stuck issue (keep FALSE if you have no issues or no DRV8308)
  172. #define MOVE_REGULARLY true // if true, mower will move in dock in given MOVE_AGAIN_AFTER time, kk: move mower to keep 8308 alive
  173. #define MOVE_AGAIN_AFTER 10.0 // kk: move the mower every xx minutes
  174. #define MOVING_TIME 500 // kk: time (ms) for moving back
  175. #define SWITCH_OFF_TRACTION_MOTORS true // should tractionmotors be disabled in dock?
  176. //LOG
  177. #define OUTPUT_ENABLED false // output standard Sunray_FW LOG in serial monitor and SDlog
  178. #define CALC_LOOPTIME false // calc and output the sunray loop time in serial monitor and SDlog
  179. #define TUNING_LOG false // outputs valuable var-states of sunray for debugging tuning functions or just for observation and insights
  180. #define TUNING_LOG_TIME 5000 // (ms) periodic output time of TUNING_LOG
  181. #define DEBUG_LOG true // adds output informations on changed mower states, functions and operations
  182. //Modsection END
  183. ////////////////////////////////////////////////////////////////////////////////////////////////////
  184.  
  185. // ------- SD card map load/resume and logging ---------------------------------
  186. // all serial console output can be logged to a (FAT32 formatted) SD card
  187. // NOTE: for full log file inspections, we will need your sunray.ino.elf binary
  188. // (you can find out the location of the compiled .elf file while compiling with verbose compilation switched on
  189. // via 'File->Preferences->Full output during compile') - detailed steps here:
  190. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#SD_card_module
  191. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#SD_card_logging
  192. #define ENABLE_SD 1 // enable SD card services (resuming, logging)? (uncomment to activate)
  193. //#define ENABLE_SD_LOG 1 // enable SD card logging? uncomment to activate (not recommended - WARNING: may slow down system!)
  194. #define ENABLE_SD_RESUME 1 // enable SD card map load/resume on reset? (uncomment to activate)
  195.  
  196.  
  197. // ------ odometry -----------------------------------
  198. // values below are for Ardumower chassis and Ardumower motors
  199. // see Wiki on how to configure the odometry divider:
  200. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#PCB1.3_odometry_divider
  201. // NOTE: It is important to verify your odometry is working accurate.
  202. // Follow the steps described in the Wiki to verify your odometry returns approx. 1 meter distance for
  203. // driving the same distance on the ground (without connected GPS):
  204. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#Odometry_test
  205. // https://forum.ardumower.de/threads/andere-r%C3%A4der-wie-config-h-%C3%A4ndern.23865/post-41732
  206.  
  207. // NOTE: if using non-default Ardumower chassis and your freewheel is at frontside (gear motors at backside), have may have to swap motor cables,
  208. // more info here: https://wiki.ardumower.de/index.php?title=Ardumower_Chassis_%27mountain_mod%27)
  209. #define FREEWHEEL_IS_AT_BACKSIDE false // default Ardumower: true (change to false, if your freewheel is at frontside) - this is used for obstacle avoidance
  210. #define WHEEL_BASE_CM 39 // wheel-to-wheel distance (cm)
  211. #define WHEEL_DIAMETER 205 // wheel diameter (mm)
  212. #define MOWER_SIZE 60 // mower / chassis size / length in cm
  213.  
  214. //#define ENABLE_ODOMETRY_ERROR_DETECTION true // use this to detect odometry erros
  215. #define ENABLE_ODOMETRY_ERROR_DETECTION false
  216.  
  217. // choose ticks per wheel revolution :
  218. // ...for the 36mm diameter motor (blue cap) https://www.marotronics.de/2-x-36er-DC-Planeten-Getriebemotor-24-Volt-mit-HallIC-30-33-RPM-8mm-Welle
  219. //#define TICKS_PER_REVOLUTION 1310 / 2 // odometry ticks per wheel revolution
  220.  
  221. // ...for the 36mm diameter motor (black cap) https://www.marotronics.de/MA36-DC-Planeten-Getriebemotor-24-Volt-mit-HallIC-30-33-RPM-8mm-Welle-ab-2-Stueck-Staffelpreis
  222. // #define TICKS_PER_REVOLUTION 975 / 2
  223.  
  224. // ...for the newer 42mm diameter motor (green connector) https://www.marotronics.de/MA42-DC-Planeten-Getriebemotor-24-Volt-mit-HallIC-30-33-RPM-8mm-Welle-ab-2-Stueck-Staffelpreis
  225. // #define TICKS_PER_REVOLUTION 696 / 2 // odometry ticks per wheel revolution
  226.  
  227. // ...for the older 42mm diameter motor (white connector) https://wiki.ardumower.de/images/d/d6/Ardumower_chassis_inside_ready.jpg
  228. //#define TICKS_PER_REVOLUTION 1050 / 2 // odometry ticks per wheel revolution
  229.  
  230. // ...for the brushless motor april 2021 https://wiki.ardumower.de/index.php?title=Datei:BLUnit.JPG
  231. //#define TICKS_PER_REVOLUTION 1300 / 2 // 1194/2 odometry ticks per wheel revolution
  232.  
  233.  
  234.  
  235.  
  236. //... Mowmotor ticks per revolution:
  237. #define MOTOR_MOW_TICKS_PER_REVOLUTION 12 /2 //ACT BLDC MOTOR from Shop = 6! (DRV8308/JYQD)
  238.  
  239.  
  240. #define TICKS_PER_REVOLUTION 320 // odometry ticks per wheel revolution (RM24)
  241. //#define TICKS_PER_REVOLUTION 975 // odometry ticks per wheel revolution (owlRobotics platform)
  242. //#define TICKS_PER_REVOLUTION 90 // odometry ticks per wheel revolution (hoverboard motor)
  243.  
  244. // ----- gear motors --------------------------------------------------
  245. // for brushless motors, study the sections (drivers, adapter, protection etc.) in the Wiki (https://wiki.ardumower.de/index.php?title=DIY_Brushless_Driver_Board)
  246. //#define MOTOR_DRIVER_BRUSHLESS 1 // uncomment this for new brushless motor drivers
  247. //#define MOTOR_DRIVER_BRUSHLESS_MOW_DRV8308 1 // uncomment for brushless DRV8308 driver and mowing motor
  248. //#define MOTOR_DRIVER_BRUSHLESS_MOW_A4931 1 // uncomment for brushless A3931 driver and mowing motor
  249. //#define MOTOR_DRIVER_BRUSHLESS_MOW_BLDC8015A 1 // uncomment for brushless BLDC8015A driver and mowing motor
  250. //#define MOTOR_DRIVER_BRUSHLESS_MOW_JYQD 1 // uncomment for brushless JYQD driver and mowing motor (https://forum.ardumower.de/threads/jyqd-treiber-und-sunray.24811/)
  251. //#define MOTOR_DRIVER_BRUSHLESS_MOW_OWL 1 // uncomment for brushless owlDrive mowing motor
  252. //#define MOTOR_DRIVER_BRUSHLESS_GEARS_DRV8308 1 // uncomment for brushless DRV8308 driver and gear/traction motors
  253. //#define MOTOR_DRIVER_BRUSHLESS_GEARS_A4931 1 // uncomment for brushless A4931 driver and gear/traction motors
  254. //#define MOTOR_DRIVER_BRUSHLESS_GEARS_BLDC8015A 1 // uncomment for brushless BLDC8015A driver and gear/traction motors
  255. //#define MOTOR_DRIVER_BRUSHLESS_GEARS_JYQD 1 // uncomment for brushless JYQD driver and gears/traction motor
  256. //#define MOTOR_DRIVER_BRUSHLESS_GEARS_OWL 1 // uncomment for brushless owlDrive gears/traction motor
  257.  
  258. #define MOTOR_FAULT_CURRENT 3.0 // gear motors fault current (amps)
  259. #define MOTOR_TOO_LOW_CURRENT 0.005 // gear motor too low current (amps), set to zero (0) to disable
  260. #define MOTOR_OVERLOAD_CURRENT 1.2 // gear motors overload current (amps)
  261.  
  262. #define USE_LINEAR_SPEED_RAMP true // use a speed ramp for the linear speed //MrTree overshooting is reduced, deceleration is more agressive: keep enabled! (recommended)
  263. //#define USE_LINEAR_SPEED_RAMP false // do not use a speed ramp
  264.  
  265. // motor speed control (PID coefficients) - these values are tuned for Ardumower motors
  266. // general information about PID controllers: https://wiki.ardumower.de/index.php?title=PID_control
  267. #define MOTOR_PID_LP 0.0 // encoder low-pass filter (use for low encoder tickcount - use zero to disable)
  268. #define MOTOR_PID_KP 0.5 // 0.5 do not change 2.0 (for non-Ardumower motors or if the motor speed control is too fast you may try: KP=1.0, KI=0, KD=0)
  269. #define MOTOR_PID_KI 0.01 // 0.01 do not change 0.03
  270. #define MOTOR_PID_KD 0.01 // 0.01 do not change 0.03
  271. #define MOTOR_PID_LIMIT 255 // output limit - do not change 255
  272. #define MOTOR_PID_RAMP 0 // output derivative limit - do not change 0
  273.  
  274. #define MOTOR_LEFT_SWAP_DIRECTION 1 // uncomment to swap left motor direction
  275. #define MOTOR_RIGHT_SWAP_DIRECTION 1 // uncomment to swap right motor direction
  276.  
  277.  
  278. // ----- mowing motor -------------------------------------------------
  279. // NOTE: motor drivers will indicate 'fault' signal if motor current (e.g. due to a stall on a molehole) or temperature is too high for a
  280. // certain time (normally a few seconds) and the mower will try again and set a virtual obstacle after too many tries
  281. // On the other hand, the overload detection will detect situations the fault signal cannot detect: slightly higher current for a longer time
  282.  
  283. // shall the mow motor be activated for normal operation? Deactivate this option for GPS tests and path tracking running tests
  284. #define ENABLE_MOW_MOTOR true // Default is true, set false for testing purpose to switch off mow motor permanently
  285.  
  286. //#define MAX_MOW_PWM 200 // use this to permanently reduce mowing motor power (255=max)
  287.  
  288. #define MOW_FAULT_CURRENT 8.0 // mowing motor fault current (amps)
  289. #define MOW_TOO_LOW_CURRENT 0.005 // mowing motor too low current (amps) , set to zero (0) to disable
  290. #define MOW_OVERLOAD_CURRENT 2.0 // mowing motor overload current (amps)
  291.  
  292. // should the direction of mowing motor toggle each start? (yes: true, no: false)
  293. #define MOW_TOGGLE_DIR true
  294. //#define MOW_TOGGLE_DIR false
  295.  
  296. // should the error on motor overload detection be enabled?
  297. #define ENABLE_OVERLOAD_DETECTION true // robot will stop on overload
  298. //#define ENABLE_OVERLOAD_DETECTION false // robot will slow down on overload
  299.  
  300. // should the motor fault (error) detection be enabled?
  301. #define ENABLE_FAULT_DETECTION true
  302. //#define ENABLE_FAULT_DETECTION false // use this if you keep getting 'motor error'
  303.  
  304. #define ENABLE_RPM_FAULT_DETECTION true // use mow rpm signal to detect a motor fault (requires mowing motor with rpm output!)
  305. //#define ENABLE_RPM_FAULT_DETECTION false // do not use mow rpm signal to detect a motor fault
  306.  
  307. // should the robot trigger obstacle avoidance on motor errors if motor recovery failed?
  308. #define ENABLE_FAULT_OBSTACLE_AVOIDANCE true
  309.  
  310.  
  311. // ------ WIFI module (ESP8266 ESP-01 with ESP firmware 2.2.1) --------------------------------
  312. // NOTE: all settings (maps, absolute position source etc.) are stored in your phone - when using another
  313. // device for the WIFI connection (PC etc.), you will have to transfer those settings (share maps via app,
  314. // re-enter absolute position source etc) !
  315. // see Wiki on how to install the WIFI module and configure the WIFI jumpers:
  316. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#Bluetooth_BLE_UART_module
  317.  
  318. #define START_AP false // should WIFI module start its own access point?
  319. //#define WIFI_IP 192,168,2,16 // choose IP e.g. 192,168,4,1 (comment out for dynamic IP/DHCP) - NOTE: use commans instead of points
  320. #define WIFI_SSID "ssid" // choose WiFi network ID
  321. #define WIFI_PASS "pass" // choose WiFi network password
  322.  
  323. // client (app) ---> server (robot)
  324. #define ENABLE_SERVER true // must be enabled if robot should act as server (recommended)
  325. //#define ENABLE_SERVER false // must be disabled if robot should act as client (requires external relay server)
  326.  
  327. // a relay server allows to access the robot via the Internet by transferring data from app to robot and vice versa (not available yet, highly experimental)
  328. // client (app) ---> relay server <--- client (robot)
  329. #define ENABLE_RELAY false // must be enabled to use relay server
  330. #define RELAY_USER "username" // choose a unique user name/number!
  331. #define RELAY_MACHINE "robot1" // choose a unique robot id
  332. #define RELAY_HOST "grauonline.net" // relay server name
  333. #define RELAY_PORT 5000 // relay server port
  334.  
  335. //#define ENABLE_UDP 1 // enable console for UDP? (for developers only)
  336. #define UDP_SERVER_IP 192,168,2,56 // remote UDP IP and port to connect to
  337. #define UDP_SERVER_PORT 4210
  338.  
  339. // --------- NTRIP client (linux only, highly experimental) ---------------------------------
  340. //#define ENABLE_NTRIP 1 // must be activated to use Linux NTRIP
  341. #define NTRIP_HOST "195.227.70.119" // sapos nrw
  342. #define NTRIP_PORT 2101
  343. #define NTRIP_MOUNT "VRS_3_4G_NW"
  344. #define NTRIP_USER "user"
  345. #define NTRIP_PASS "pass"
  346.  
  347. // ------ MQTT (for ESP8266 only, highly experimental - ENABLE_SERVER must be set to false for this to work :-/ ) -----------------------------
  348. // you can access your robot using a MQTT broker - choose a topic prefix for your robot below - available MQTT topics:
  349. // robot1/cmd (cmd can be: start, stop, dock)
  350. // robot1/op (current robot operation as text)
  351. // robot1/gps/sol (current gps solution as text)
  352. // robot1/gps/pos (current gps position as text)
  353. // ... lot of other information -> see comm.cpp or check with your MQTT Explorer
  354. //#define ENABLE_MQTT true // start MQTT client? (true for yes, false for no)
  355. #define ENABLE_MQTT false
  356. #define MQTT_TOPIC_PREFIX "robot1" // the MQTT topic prefix for your robot
  357. #define MQTT_SERVER "192.168.2.27" // your MQTT broker IP or hostname (e.g. "broker.mqtt-dashboard.com")
  358. #define MQTT_PORT 1883
  359. #define MQTT_USER "user"
  360. #define MQTT_PASS "pass"
  361.  
  362. // ------ ultrasonic sensor -----------------------------
  363. // see Wiki on how to install the ultrasonic sensors:
  364. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#Ultrasonic_sensor
  365.  
  366. //#define SONAR_INSTALLED 1 // uncomment if ultrasonic sensors are installed
  367. //#define SONAR_ENABLE true // should ultrasonic sensor be used?
  368. #define SONAR_ENABLE false
  369. #define SONAR_TRIGGER_OBSTACLES true // should sonar be used to trigger obstacles? if not, mower will only slow down
  370. #define SONAR_LEFT_OBSTACLE_CM 10 // stop mowing operation below this distance (cm)
  371. #define SONAR_CENTER_OBSTACLE_CM 10 // stop mowing operation below this distance (cm)
  372. #define SONAR_RIGHT_OBSTACLE_CM 10 // stop mowing operation below this distance (cm)
  373.  
  374. // ------ rain sensor ----------------------------------------------------------
  375. #define RAIN_ENABLE true // if activated, mower will dock when rain sensor triggers
  376. //#define RAIN_ENABLE false
  377.  
  378. // ------ time-of-flight distance sensor (VL53L0X) -----------------------------
  379. // do not use this sensor (not recommended)
  380. //#define TOF_ENABLE true
  381. #define TOF_ENABLE false
  382. #define TOF_OBSTACLE_CM 100 // stop mowing operation below this distance (cm)
  383.  
  384.  
  385. // ------ bumper sensor (bumperduino, freewheel etc.) ----------------
  386. // see Wiki on how to install bumperduino or freewheel sensor:
  387. // https://wiki.ardumower.de/index.php?title=Bumper_sensor
  388. // https://wiki.ardumower.de/index.php?title=Free_wheel_sensor
  389. #define BUMPER_ENABLE true
  390. //#define BUMPER_ENABLE false
  391. #define BUMPER_DEADTIME 1000 // linear motion dead-time (ms) after bumper is allowed to trigger
  392. #define BUMPER_TRIGGER_DELAY 0 // bumper must be active for (ms) to trigger
  393. #define BUMPER_MAX_TRIGGER_TIME 30 // if bumpersensor stays permanent triggered mower will stop with bumper error (time in seconds; 0 = disabled)
  394.  
  395.  
  396. // ----- battery charging current measurement (INA169) --------------
  397. // the Marotronics charger outputs max 1.5A
  398. // ( https://www.marotronics.de/Ladegeraete-fuer-den-Ardumower-Akkus-24V-mit-Status-LED-auch-fuer-Li-Ion-Akkus )
  399. // so we are using the INA169 in non-bridged mode (max. 2.5A)
  400. // ( https://www.marotronics.de/INA169-Analog-DC-Current-Sensor-Breakout-60V-25A-5A-Marotronics )
  401.  
  402. #define CURRENT_FACTOR 0.5 // PCB1.3 (non-bridged INA169, max. 2.5A)
  403. //#define CURRENT_FACTOR 1.0 // PCB1.3 (bridged INA169, max. 5A)
  404. //#define CURRENT_FACTOR 1.98 // PCB1.4 (non-bridged INA169, max. 2.5A)
  405. //#define CURRENT_FACTOR 2.941 // PCB1.4 (bridged INA169, max. 5A)
  406.  
  407. #define GO_HOME_VOLTAGE 25.5 // start going to dock below this voltage
  408. // The battery will charge if both battery voltage is below that value and charging current is above that value.
  409. #define BAT_FULL_VOLTAGE 30.0 // start mowing again at this voltage
  410. #define BAT_FULL_CURRENT -0.1 // start mowing again below this charging current (amps)
  411. #define BAT_FULL_SLOPE 0.002 // start mowing again below this voltage slope
  412.  
  413. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#Automatic_battery_switch_off
  414. #define BAT_SWITCH_OFF_IDLE false // switch off if idle (JP8 must be set to autom.)
  415. #define BAT_SWITCH_OFF_IDLE_TIME 500 // MrTree seconds when switching of in idle state
  416. #define BAT_SWITCH_OFF_UNDERVOLTAGE true // switch off if undervoltage (JP8 must be set to autom.)
  417. #define BAT_SWITCH_OFF_VOLTAGE 20.0 //switch off mower if under this voltage
  418.  
  419. // ------ GPS ------------------------------------------
  420. // ------- RTK GPS module -----------------------------------
  421. // see Wiki on how to install the GPS module and configure the jumpers:
  422. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#Bluetooth_BLE_UART_module
  423. //
  424. // NOTE: if you experience GPS checksum errors, try to increase UART FIFO size:
  425. // 1. Arduino IDE->File->Preferences->Click on 'preferences.txt' at the bottom
  426. // 2. Locate file 'packages/arduino/hardware/sam/xxxxx/cores/arduino/RingBuffer.h'
  427. // (for Adafruit Grand Central M4: 'packages\adafruit\hardware\samd\xxxxx\cores\arduino\RingBuffer.h')
  428. // change: #define SERIAL_BUFFER_SIZE 128 into into: #define SERIAL_BUFFER_SIZE 1024
  429.  
  430. //#define GPS_USE_TCP 1 // comment out for serial gps, activate for TCP client-based GPS
  431. //#define GPS_SKYTRAQ 1 // comment out for ublox gps, uncomment for skytraq gps/NMEA
  432. // #define GPS_LIDAR 1 // decomment for LiDAR
  433.  
  434. #define REQUIRE_VALID_GPS true // mower will pause if no float and no fix GPS solution during mowing (recommended)
  435. //#define REQUIRE_VALID_GPS false // mower will continue to mow if no float or no fix solution (not recommended)
  436.  
  437. #define GPS_SPEED_DETECTION true // will detect obstacles via GPS feedback (no speed) - recommended
  438. //#define GPS_SPEED_DETECTION false
  439.  
  440. // detect if robot is actually moving (obstacle detection via GPS feedback)
  441. #define GPS_MOTION_DETECTION true // if robot is not moving trigger obstacle avoidance
  442. //#define GPS_MOTION_DETECTION false // ignore if robot is not moving
  443. #define GPS_MOTION_DETECTION_TIMEOUT 5 // timeout for motion (secs)
  444. #define GPS_MOTION_DETECTION_DELTA 0.10 // (0.20) distance mower must be moving in timeouttime until gps no motion is triggered
  445.  
  446. // configure ublox f9p with optimal settings (will be stored in f9p RAM only)
  447. // NOTE: due to a PCB1.3 bug GPS_RX pin is not working and you have to fix this by a wire:
  448. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#PCB1.3_GPS_pin_fix_and_wire_fix (see 'GPS wire fix')
  449. #define GPS_REBOOT_RECOVERY true // allow GPS receiver rebooting (recommended - requires GPS wire fix above! otherwise firmware will stuck at boot!)
  450. //#define GPS_REBOOT_RECOVERY false // do not allow rebooting GPS receiver (no GPS wire fix required)
  451.  
  452. #define GPS_CONFIG true // configure GPS receiver (recommended - requires GPS wire fix above! otherwise firmware will stuck at boot!)
  453. //#define GPS_CONFIG false // do not configure GPS receiver (no GPS wire fix required)
  454.  
  455. #define GPS_CONFIG_FILTER true // use signal strength filter? (recommended to get rid of 'FIX jumps') - adjust filter settings below
  456. //#define GPS_CONFIG_FILTER false // use this if you have difficulties to get a FIX solution (uses ublox default filter settings)
  457. #define CPG_CONFIG_FILTER_MINELEV 3 // (10) Min SV elevation degree: 14 (high elevation, less robust), 10 (low elevation, robust)
  458. #define CPG_CONFIG_FILTER_NCNOTHRS 8 // (0) C/N0 Threshold #SVs: 10 (robust), 6 (less robust)
  459. #define CPG_CONFIG_FILTER_CNOTHRS 17 // (0) 30 dbHz (robust), 13 dbHz (less robust)
  460.  
  461.  
  462. // ------ obstacle detection and avoidance -------------------------
  463.  
  464. #define ENABLE_PATH_FINDER true // path finder calculates routes around exclusions and obstacles
  465. //#define ENABLE_PATH_FINDER false
  466. #define ALLOW_ROUTE_OUTSIDE_PERI_METER 1.0 // max. distance (m) to allow routing from outside perimeter
  467. // (increase if you get 'no map route' errors near perimeter)
  468.  
  469. #define OBSTACLE_DETECTION_ROTATION true // detect robot rotation stuck (requires IMU)
  470. //#define OBSTACLE_DETECTION_ROTATION false // NOTE: recommended to turn this off for slope environment
  471. #define ROTATION_TIMEOUT 5000 //15000 Timeout of rotation movement that triggers an obstacle with escapeReverse
  472. #define ROTATION_TIME 1000 //3000 Time the code expects to rotate without a IMU yaw difference
  473.  
  474. #define OBSTACLE_AVOIDANCE true // try to find a way around obstacle
  475. //#define OBSTACLE_AVOIDANCE false // stop robot on obstacle
  476. #define OBSTACLE_DIAMETER 1.2 // choose diameter of obstacles placed in front of robot (m) for obstacle avoidance
  477.  
  478. #define DISABLE_MOW_MOTOR_AT_OBSTACLE true // switch off mow motor while escape at detected obstacle; set false if mow motor shall not be stopped at detected obstacles
  479.  
  480. // detect robot being kidnapped? robot will try GPS recovery if distance to tracked path is greater than a certain value
  481. // (false GPS fix recovery), and if that fails go into error
  482. #define KIDNAP_DETECT true // recommended
  483. //#define KIDNAP_DETECT false
  484. #define KIDNAP_DETECT_ALLOWED_PATH_TOLERANCE 2.0 // allowed path tolerance (m)
  485. #define KIDNAP_DETECT_ALLOWED_PATH_TOLERANCE_DOCK_UNDOCK 20.2 // allowed path tolerance (m)
  486. #define KIDNAP_DETECT_DISTANCE_DOCK_UNDOCK 5 // distance from dock in (m) to use KIDNAP_DETECT_ALLOWED_PATH_TOLERANCE_DOCK_UNDOCK
  487.  
  488. // ------ docking --------------------------------------
  489. // is a docking station available?
  490. #define DOCKING_STATION true // use this if docking station available and mower should dock automatically
  491. //#define DOCKING_STATION false // mower will just stop after mowing instead of docking automatically
  492.  
  493. #define DOCK_IGNORE_GPS false // use GPS fix in docking station and IMU for GPS float/invalid
  494. //#define DOCK_IGNORE_GPS true // ignore GPS fix in docking station and use IMU-only (use this if robot gets false GPS fixes in your docking station)
  495.  
  496. #define DOCK_AUTO_START true // robot will automatically continue mowing after docked automatically
  497. //#define DOCK_AUTO_START false // robot will not automatically continue mowing after docked automatically
  498.  
  499. #define DOCK_RETRY_TOUCH true // robot will retry touching docking contacts (max. 1cm) if loosing docking contacts during charging
  500. //#define DOCK_RETRY_TOUCH false // robot will not retry touching docking contacts (max. 1cm) if loosing docking contacts during charging
  501.  
  502. #define DOCK_UNDOCK_TRACKSLOW_DISTANCE 5 // set distance (m) from dock for trackslow (speed limit)
  503.  
  504. #define UNDOCK_IGNORE_GPS_DISTANCE 2 // set distance (m) from dock to ignore gps while undocking
  505.  
  506. // ---- path tracking -----------------------------------
  507.  
  508. // below this robot-to-target distance (m) a target is considered as reached
  509. #define TARGET_REACHED_TOLERANCE 0.1
  510.  
  511. // stanley control for path tracking - determines gain how fast to correct for lateral path errors
  512. #define STANLEY_CONTROL_P_NORMAL 1.1 // 3.0 for path tracking control (angular gain) when mowing
  513. #define STANLEY_CONTROL_K_NORMAL 0.1 // 1.0 for path tracking control (lateral gain) when mowing
  514.  
  515. #define STANLEY_CONTROL_P_SLOW 1.1 // 1.0 for path tracking control (angular gain) when docking tracking
  516. #define STANLEY_CONTROL_K_SLOW 0.1 // 0.2 for path tracking control (lateral gain) when docking tracking
  517.  
  518.  
  519. // ----- other options --------------------------------------------
  520.  
  521. // button control (turns on additional features via the POWER-ON button)
  522. #define BUTTON_CONTROL true // additional features activated (press-and-hold button for specific beep count:
  523. // 1 beep=stop, 6 beeps=start, 5 beeps=dock, 3 beeps=R/C mode ON/OFF, 9 beeps=shutdown, 12 beeps=WiFi WPS
  524. //#define BUTTON_CONTROL false // additional features deactivated
  525.  
  526. #define USE_TEMP_SENSOR true // only activate if temp sensor (htu21d) connected
  527. //#define USE_TEMP_SENSOR false
  528.  
  529. #define DOCK_OVERHEAT_TEMP 85 // if temperature above this degreeC, mower will dock
  530. #define DOCK_TOO_COLD_TEMP 5 // if temperature below this degreeC, mower will dock
  531.  
  532.  
  533. // activate support for model R/C control?
  534. // use PCB pin 'mow' for R/C model control speed and PCB pin 'steering' for R/C model control steering,
  535. // also connect 5v and GND and activate model R/C control via PCB P20 start button for 3 sec.
  536. // more details: https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#R.2FC_model
  537. //#define RCMODEL_ENABLE 1 // uncomment line to turn on R/C control
  538.  
  539. #define BUZZER_ENABLE 1 // comment to disable
  540.  
  541.  
  542. // ------ experimental options -------------------------
  543.  
  544. // drive curves smoothly?
  545. //#define SMOOTH_CURVES true
  546. #define SMOOTH_CURVES false
  547.  
  548. // --------- serial monitor output (CONSOLE) ------------------------
  549. // which Arduino Due USB port do you want to your for serial monitor output (CONSOLE)?
  550. // Arduino Due native USB port => choose SerialUSB
  551. // Arduino Due programming port => choose Serial
  552. #if defined (__arm__) && defined (__SAM3X8E__) // Arduino Due compatible
  553. #define BOARD "Arduino Due"
  554. #define CONSOLE SerialUSB // Arduino Due: do not change (used for Due native USB serial console)
  555. #elif __SAMD51__
  556. #define BOARD "Adafruit Grand Central M4"
  557. #define CONSOLE Serial // Adafruit Grand Central M4
  558. #elif __linux__
  559. #define BOARD "Linux"
  560. #define CONSOLE Console
  561. #else
  562. #ifdef __cplusplus
  563. #error "ERROR: you need to choose either Arduino Due or Adafruit GCM4 in Arduino IDE"
  564. #endif
  565. #endif
  566.  
  567. // ------- serial ports and baudrates---------------------------------
  568. #define CONSOLE_BAUDRATE 115200 // baudrate used for console
  569. //#define CONSOLE_BAUDRATE 921600 // baudrate used for console
  570. #define BLE_BAUDRATE 115200 // baudrate used for BLE
  571. #define BLE_NAME "Ardumower" // name for BLE module
  572. #define GPS_BAUDRATE 115200 // baudrate for GPS RTK module
  573. #define WIFI_BAUDRATE 115200 // baudrate for WIFI module
  574. #define ROBOT_BAUDRATE 19200 // baudrate for Linux serial robot (non-Ardumower)
  575.  
  576. #ifdef __SAM3X8E__ // Arduino Due
  577. #define WIFI Serial1
  578. #define ROBOT Serial1
  579. #define BLE Serial2
  580. #define GPS Serial3
  581. //#define GPS Serial // only use this for .ubx logs (sendgps.py)
  582. #elif __SAMD51__ // Adafruit Grand Central M4
  583. #define WIFI Serial2
  584. #define ROBOT Serial2
  585. #define BLE Serial3
  586. #define GPS Serial4
  587. #elif __linux__
  588. #define WIFI SerialWIFI // dummy serial device
  589. #define SERIAL_WIFI_PATH "/dev/null"
  590. #define LINUX_BLE // comment to disable BLE
  591. #define BLE SerialBLE
  592. #define SERIAL_BLE_PATH "/dev/null" // dummy serial device
  593. #define GPS SerialGPS
  594. #define SERIAL_GPS_PATH "/dev/serial/by-id/usb-u-blox_AG_-_www.u-blox.com_u-blox_GNSS_receiver-if00"
  595. #define GPS_HOST "127.0.0.1"
  596. #define GPS_PORT 2947
  597. #define ROBOT SerialROBOT
  598. #define SERIAL_ROBOT_PATH "/dev/ttyS0"
  599. #define NTRIP SerialNTRIP
  600. #define SERIAL_NTRIP_PATH "/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_00000000-if00-port0"
  601. #endif
  602.  
  603.  
  604.  
  605. // ------- I2C addresses -----------------------------
  606. #define DS1307_ADDRESS B1101000
  607. #define AT24C32_ADDRESS B1010000
  608.  
  609.  
  610. // ------- PCB1.3/Due settings -------------------------
  611. #define IOREF 3.3 // I/O reference voltage
  612.  
  613. // ------ hardware pins---------------------------------------
  614. // no configuration needed here
  615.  
  616. #ifdef __linux__
  617. // ...
  618. #else
  619. #define pinMotorEnable 37 // EN motors enable
  620. #define pinMotorLeftPWM 5 // M1_IN1 left motor PWM pin
  621. #define pinMotorLeftDir 31 // M1_IN2 left motor Dir pin
  622. #define pinMotorLeftSense A1 // M1_FB left motor current sense
  623. #define pinMotorLeftFault 25 // M1_SF left motor fault
  624.  
  625. #define pinMotorRightPWM 3 // M2_IN1 right motor PWM pin
  626. #define pinMotorRightDir 33 // M2_IN2 right motor Dir pin
  627. #define pinMotorRightSense A0 // M2_FB right motor current sense
  628. #define pinMotorRightFault 27 // M2_SF right motor fault
  629.  
  630. #define pinMotorMowPWM 2 // M1_IN1 mower motor PWM pin (if using MOSFET, use this pin)
  631. #define pinMotorMowDir 29 // M1_IN2 mower motor Dir pin (if using MOSFET, keep unconnected)
  632. #define pinMotorMowSense A3 // M1_FB mower motor current sense
  633. #define pinMotorMowFault 26 // M1_SF mower motor fault (if using MOSFET/L298N, keep unconnected)
  634. #define pinMotorMowEnable 28 // EN mower motor enable (if using MOSFET/L298N, keep unconnected)
  635. #define pinMotorMowRpm A11
  636.  
  637. #define pinFreeWheel 8 // front/rear free wheel sensor
  638. #define pinBumperLeft 39 // bumper pins
  639. #define pinBumperRight 38
  640.  
  641. #define pinDropLeft 45 // drop pins Dropsensor - Absturzsensor
  642. #define pinDropRight 23 // drop pins Dropsensor - Absturzsensor
  643.  
  644. #define pinSonarCenterTrigger 24 // ultrasonic sensor pins
  645. #define pinSonarCenterEcho 22
  646. #define pinSonarRightTrigger 30
  647. #define pinSonarRightEcho 32
  648. #define pinSonarLeftTrigger 34
  649. #define pinSonarLeftEcho 36
  650. #define pinPerimeterRight A4 // perimeter
  651. #define pinDockingReflector A4 // docking IR reflector
  652. #define pinPerimeterLeft A5
  653.  
  654. #define pinLED 13 // LED
  655. #define pinBuzzer 53 // Buzzer
  656. //#define pinTilt 35 // Tilt sensor (required for TC-G158 board)
  657. #define pinLift 35 // Lift sensor (marked as 'Tilt' on PCB1.3/1.4)
  658. #define pinButton 51 // digital ON/OFF button
  659. #define pinBatteryVoltage A2 // battery voltage sensor
  660. #define pinBatterySwitch 4 // battery-OFF switch
  661. #define pinChargeVoltage A9 // charging voltage sensor
  662. #define pinChargeCurrent A8 // charge current sensor
  663. #define pinChargeRelay 50 // charge relay
  664. #define pinRemoteMow 12 // remote control mower motor
  665. #define pinRemoteSteer 11 // remote control steering
  666. #define pinRemoteSpeed 10 // remote control speed
  667. #define pinRemoteSwitch 52 // remote control switch
  668. #define pinVoltageMeasurement A7 // test pin for your own voltage measurements
  669. #if defined(_SAM3XA_) // Arduino Due
  670. #define pinOdometryLeft DAC0 // left odometry sensor
  671. #define pinOdometryRight CANRX // right odometry sensor
  672. #define pinReservedP46 CANTX // reserved
  673. #define pinReservedP48 DAC1 // reserved
  674. #else // Adafruit Grand Central M4
  675. #define pinOdometryLeft A12 // left odometry sensor
  676. #define pinOdometryRight A14 // right odometry sensor
  677. #define pinReservedP46 A15 // reserved
  678. #define pinReservedP48 A13 // reserved
  679. #endif
  680. #define pinLawnFrontRecv 40 // lawn sensor front receive
  681. #define pinLawnFrontSend 41 // lawn sensor front sender
  682. #define pinLawnBackRecv 42 // lawn sensor back receive
  683. #define pinLawnBackSend 43 // lawn sensor back sender
  684. #define pinUserSwitch1 46 // user-defined switch 1
  685. #define pinUserSwitch2 47 // user-defined switch 2
  686. #define pinUserSwitch3 48 // user-defined switch 3
  687. #define pinRain 44 // rain sensor
  688. #define pinReservedP14 A7 // reserved
  689. #define pinReservedP22 A6 // reserved
  690. #define pinReservedP26 A10 // reserved
  691.  
  692. #ifndef SDCARD_SS_PIN
  693. #if defined(_SAM3XA_) // Arduino Due
  694. #define SDCARD_SS_PIN pinUserSwitch1
  695. #else
  696. #define SDCARD_SS_PIN 4
  697. #endif
  698. #endif
  699. #endif
  700.  
  701. // IMU (compass/gyro/accel): I2C (SCL, SDA)
  702. // Bluetooth: Serial2 (TX2, RX2)
  703. // GPS: Serial3 (TX3, RX3)
  704. // WIFI: Serial1 (TX1, RX1)
  705.  
  706. #define DEBUG(x) CONSOLE.print(x)
  707. #define DEBUGLN(x) CONSOLE.println(x)
  708.  
  709. #if defined(ENABLE_SD_LOG)
  710. #define CONSOLE sdSerial
  711. #elif defined(ENABLE_UDP)
  712. #define CONSOLE udpSerial
  713. #endif
  714.  
  715.  
  716. // the following will be used by Arduino library RingBuffer.h - to verify this Arduino library file:
  717. // 1. Arduino IDE->File->Preferences->Click on 'preferences.txt' at the bottom
  718. // 2. Locate file 'packages/arduino/hardware/sam/xxxxx/cores/arduino/RingBuffer.h
  719.  
  720. #define SERIAL_BUFFER_SIZE 4096
  721.  
  722. #ifdef BNO055
  723. #define MPU9250 // just to make mpu driver happy to compile something
  724. #endif
  725.  
  726. #ifdef ICM20948
  727. #define MPU9250 // just to make mpu driver happy to compile something
  728. #endif
  729.  
  730. #ifdef __cplusplus
  731. #include "udpserial.h"
  732. #include "sdserial.h"
  733. #include "src/agcm4/adafruit_grand_central.h"
  734. #ifdef __linux__
  735. #include "src/linux/linux.h"
  736. #include <Console.h>
  737. #endif
  738. #endif
  739.  
Advertisement
Add Comment
Please, Sign In to add comment