Advertisement
Guest User

Untitled

a guest
May 25th, 2022
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.49 KB | None | 0 0
  1. [CODE]// Ardumower Sunray
  2.  
  3. // Copyright (c) 2013-2020 by Alexander Grau, Grau GmbH
  4.  
  5. // Licensed GPLv3 for open source use
  6.  
  7. // or Grau GmbH Commercial License for commercial use (http://grauonline.de/cms2/?page_id=153)
  8.  
  9.  
  10.  
  11. /*
  12.  
  13. WARNING: all software, hardware and motor components are designed and optimized as a whole, if you
  14.  
  15. try to replace or exclude some component not as designed, you risk to damage your hardware with
  16.  
  17. the software.
  18.  
  19.  
  20.  
  21. see Wiki for installation details:
  22.  
  23. http://wiki.ardumower.de/index.php?title=Ardumower_Sunray
  24.  
  25.  
  26.  
  27. requirements:
  28.  
  29. + Ardumower chassis and Ardumower kit mowing and gear motors
  30.  
  31. + Adafruit Grand Central M4 (highly recommended) or Arduino Due
  32.  
  33. + Ardumower BLE UART module (HM-10/CC2540/CC2541)
  34.  
  35. + optional: Ardumower IMU (MPU6050/MPU9150/MPU9250/MPU9255) - choose your IMU below
  36.  
  37. + optional: Ardumower WIFI (ESP8266 ESP-01 with stock firmware)
  38.  
  39. + optional: HTU21D temperature/hbumidity sensor
  40.  
  41. + optional: sonar, bumperduino, freewheel sensor
  42.  
  43. + Ardumower RTK (ublox F9P)
  44.  
  45.  
  46.  
  47.  
  48.  
  49. 1. Rename file 'config_example.h' into 'config.h'
  50.  
  51.  
  52.  
  53. 2. Configure the options below and finally compile and upload this project.
  54.  
  55.  
  56.  
  57.  
  58.  
  59. Adafruit Grand Central M4 NOTE: You have to add SDA, SCL pull-up resistors to the board
  60.  
  61. and deactivate Due clone reset cicuit (JP13):
  62.  
  63. https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#Adafruit_Grand_Central_M4
  64.  
  65. 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.
  66.  
  67.  
  68.  
  69. Arduino Due UPLOAD NOTE:
  70.  
  71.  
  72.  
  73. If using Arduino Due 'native' USB port for uploading, choose board 'Arduino Due native' in the
  74.  
  75. Arduino IDE and COM port 'Arduino Due native port'.
  76.  
  77.  
  78.  
  79. If using Arduino Due 'programming' USB port for uploading, choose board 'Arduino Due programming' in the
  80.  
  81. Arduino IDE and COM port 'Arduino Due programming port'.
  82.  
  83.  
  84.  
  85. Also, you may choose the serial port below for serial monitor output (CONSOLE).
  86.  
  87.  
  88.  
  89. */
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97. #ifdef __cplusplus
  98.  
  99. #include "udpserial.h"
  100.  
  101. #include "sdserial.h"
  102.  
  103. #include "src/agcm4/adafruit_grand_central.h"
  104.  
  105. #ifdef __linux__
  106.  
  107. #include "src/linux/linux.h"
  108.  
  109. #include <Console.h>
  110.  
  111. #endif
  112.  
  113. #endif
  114.  
  115.  
  116.  
  117. #define DRV_SERIAL_ROBOT 1
  118.  
  119. #define DRV_ARDUMOWER 1 // keep this for Ardumower
  120.  
  121.  
  122.  
  123.  
  124.  
  125. // ------- Bluetooth4.0/BLE module -----------------------------------
  126.  
  127. // see Wiki on how to install the BLE module and configure the jumpers:
  128.  
  129. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#Bluetooth_BLE_UART_module
  130.  
  131. #define ENABLE_PASS 0 // comment out to disable password authentication
  132.  
  133. #define PASS 999999 // choose password for WiFi/BLE communication (NOTE: has to match the connection password in the App!)
  134.  
  135.  
  136.  
  137. // -------- IMU sensor ----------------------------------------------
  138.  
  139. // choose one MPU IMU (make sure to connect AD0 on the MPU board to 3.3v)
  140.  
  141. // verify in CONSOLE that your IMU was found (you will hear 8 buzzer beeps for automatic calibration at start)
  142.  
  143. // see Wiki for wiring, how to position the module, and to configure the I2C pullup jumpers:
  144.  
  145. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#IMU.2C_sensor_fusion
  146.  
  147.  
  148.  
  149. #define MPU6050
  150.  
  151.  
  152.  
  153. //#define MPU9150
  154.  
  155. //#define MPU9250 // also choose this for MPU9255
  156.  
  157. //#define BNO055
  158.  
  159.  
  160.  
  161. // should the mower turn off if IMU is tilt over? (yes: uncomment line, no: comment line)
  162.  
  163. //#define ENABLE_TILT_DETECTION 1
  164.  
  165.  
  166.  
  167. // ------- SD card map load/resume and logging ---------------------------------
  168.  
  169. // all serial console output can be logged to a (FAT32 formatted) SD card
  170.  
  171. // NOTE: for full log file inspections, we will need your sunray.ino.elf binary
  172.  
  173. // (you can find out the location of the compiled .elf file while compiling with verbose compilation switched on
  174.  
  175. // via 'File->Preferences->Full output during compile') - detailed steps here:
  176.  
  177. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#SD_card_module
  178.  
  179. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#SD_card_logging
  180.  
  181. //#define ENABLE_SD 1 // enable SD card services (resuming, logging)? (uncomment to activate)
  182.  
  183. //#define ENABLE_SD_LOG 1 // enable SD card logging? uncomment to activate (not recommended - WARNING: may slow down system!)
  184.  
  185. //#define ENABLE_SD_RESUME 1 // enable SD card map load/resume on reset? (uncomment to activate)
  186.  
  187.  
  188.  
  189.  
  190.  
  191. // ------ odometry -----------------------------------
  192.  
  193. // values below are for Ardumower chassis and Ardumower motors
  194.  
  195. // see Wiki on how to configure the odometry divider:
  196.  
  197. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#PCB1.3_odometry_divider
  198.  
  199. // NOTE: It is important to verify your odometry is working accurate.
  200.  
  201. // Follow the steps described in the Wiki to verify your odometry returns approx. 1 meter distance for
  202.  
  203. // driving the same distance on the ground (without connected GPS):
  204.  
  205. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#Odometry_test
  206.  
  207. // https://forum.ardumower.de/threads/andere-r%C3%A4der-wie-config-h-%C3%A4ndern.23865/post-41732
  208.  
  209.  
  210.  
  211. // NOTE: if using non-default Ardumower chassis and your freewheel is at frontside (gear motors at backside), have may have to swap motor cables,
  212.  
  213. // more info here: https://wiki.ardumower.de/index.php?title=Ardumower_Chassis_%27mountain_mod%27)
  214.  
  215. #define FREEWHEEL_IS_AT_BACKSIDE true // default Ardumower: true (change to false, if your freewheel is at frontside) - this is used for obstacle avoidance
  216.  
  217. #define WHEEL_BASE_CM 36 // wheel-to-wheel distance (cm)
  218.  
  219. #define WHEEL_DIAMETER 250 // wheel diameter (mm)
  220.  
  221.  
  222.  
  223. //#define ENABLE_ODOMETRY_ERROR_DETECTION true // use this to detect odometry errors
  224.  
  225. #define ENABLE_ODOMETRY_ERROR_DETECTION false
  226.  
  227.  
  228.  
  229. // choose ticks per wheel revolution :
  230.  
  231. // ...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
  232.  
  233. //#define TICKS_PER_REVOLUTION 1310 / 2 // odometry ticks per wheel revolution
  234.  
  235.  
  236.  
  237. // ...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
  238.  
  239. // #define TICKS_PER_REVOLUTION 975 / 2
  240.  
  241.  
  242.  
  243. // ...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
  244.  
  245. #define TICKS_PER_REVOLUTION 696 / 2 // odometry ticks per wheel revolution
  246.  
  247.  
  248.  
  249. // ...for the older 42mm diameter motor (white connector) https://wiki.ardumower.de/images/d/d6/Ardumower_chassis_inside_ready.jpg
  250.  
  251. //#define TICKS_PER_REVOLUTION 1050 / 2 // odometry ticks per wheel revolution
  252.  
  253.  
  254.  
  255. // ...for the brushless motor april 2021 https://wiki.ardumower.de/index.php?title=Datei:BLUnit.JPG
  256.  
  257. //#define TICKS_PER_REVOLUTION 1300 / 2 // 1194/2 odometry ticks per wheel revolution
  258.  
  259.  
  260.  
  261. // #define TICKS_PER_REVOLUTION 304 // odometry ticks per wheel revolution (RM18)
  262.  
  263.  
  264.  
  265.  
  266.  
  267. // ----- gear motors --------------------------------------------------
  268.  
  269. // for brushless motors, study the sections (drivers, adapter, protection etc.) in the Wiki (https://wiki.ardumower.de/index.php?title=DIY_Brushless_Driver_Board)
  270.  
  271. // #define MOTOR_DRIVER_BRUSHLESS 1 // uncomment this for new brushless motor drivers
  272.  
  273.  
  274.  
  275. #define MOTOR_OVERLOAD_CURRENT 0.8 // gear motors overload current (amps)
  276.  
  277.  
  278.  
  279. //#define USE_LINEAR_SPEED_RAMP true // use a speed ramp for the linear speed
  280.  
  281. #define USE_LINEAR_SPEED_RAMP false // do not use a speed ramp
  282.  
  283.  
  284.  
  285. // motor speed control (PID coefficients) - these values are tuned for Ardumower motors
  286.  
  287. // general information about PID controllers: https://wiki.ardumower.de/index.php?title=PID_control
  288.  
  289. #define MOTOR_PID_KP 2.0 // 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)
  290.  
  291. #define MOTOR_PID_KI 0.03 // do not change 0.03
  292.  
  293. #define MOTOR_PID_KD 0.03 // do not change 0.03
  294.  
  295.  
  296.  
  297. //#define MOTOR_LEFT_SWAP_DIRECTION 1 // uncomment to swap left motor direction
  298.  
  299. //#define MOTOR_RIGHT_SWAP_DIRECTION 1 // uncomment to swap right motor direction
  300.  
  301.  
  302.  
  303. // ------------ dynamic gear motors speed ----------------
  304.  
  305. // speed will be adjusted by the mowing motor current. If USE_MOWMOTOR_CURRENT_AVERAGE is set to false, the Speed
  306.  
  307. // will be changed if the mow Current is lower or higher than MOWMOTOR_CURRENT_FACTOR * MOW_OVERLOAD_CURRENT.
  308.  
  309. // If USE_MOWMOTOR_CURRENT_AVERAGE is set to true the algorithm will detect the current at the middle PWM of the mowMotor.
  310.  
  311. // The mowing average will be calculate over 10000 loops and start at MOWMOTOR_CURRENT_FACTOR.
  312.  
  313. #define ENABLE_DYNAMIC_MOWER_SPEED false
  314.  
  315. #define SPEED_ACCELERATION 0.005 // Speed factor will be changed with every programm loop
  316.  
  317.  
  318.  
  319. #define SPEED_FACTOR_MAX 1.2
  320.  
  321. #define SPEED_FACTOR_MIN 0.5
  322.  
  323. #define USE_MOWMOTOR_CURRENT_AVERAGE true
  324.  
  325. #define MOWMOTOR_CURRENT_FACTOR 0.25
  326.  
  327.  
  328.  
  329.  
  330.  
  331. // ----- mowing motor -------------------------------------------------
  332.  
  333. // 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
  334.  
  335. // certain time (normally a few seconds) and the mower will try again and set a virtual obstacle after too many tries
  336.  
  337. // On the other hand, the overload detection will detect situations the fault signal cannot detect: slightly higher current for a longer time
  338.  
  339.  
  340.  
  341. #define MOW_OVERLOAD_CURRENT 2.0 // mowing motor overload current (amps)
  342.  
  343.  
  344.  
  345. // should the direction of mowing motor toggle each start? (yes: true, no: false)
  346.  
  347. #define MOW_TOGGLE_DIR true
  348.  
  349. //#define MOW_TOGGLE_DIR false
  350.  
  351.  
  352.  
  353. // should the error on motor overload detection be enabled?
  354.  
  355. //#define ENABLE_OVERLOAD_DETECTION true // robot will stop on overload
  356.  
  357. #define ENABLE_OVERLOAD_DETECTION false // robot will slow down on overload
  358.  
  359.  
  360.  
  361. // should the motor fault (error) detection be enabled?
  362.  
  363. #define ENABLE_FAULT_DETECTION true
  364.  
  365. //#define ENABLE_FAULT_DETECTION false // use this if you keep getting 'motor error'
  366.  
  367.  
  368.  
  369. // ----------- dynamic mowingm motor RPM --------------
  370.  
  371. // RPM of the mow motor will be adjust over the actual current of the mow motor. If the motor needs more current the PWM will be higher.
  372.  
  373. // it can be used 3 different functions for the calculation of the PWM depended´nt on the mowMotor current. The root-Function is recommended
  374.  
  375. #define ENABLE_DYNAMIC_MOWMOTOR false // set true to activate, set false to deactivate
  376.  
  377. #define DYNAMIC_MOWMOTOR_ALGORITHM 2 // 1 - linear; 2 - root-Function; 3 - square-Function
  378.  
  379. #define MIN_MOW_RPM 170 //minimum value of mow RPM
  380.  
  381. #define MAX_MOW_RPM 255 // maximum value is 255
  382.  
  383.  
  384.  
  385.  
  386.  
  387. // ------ WIFI module (ESP8266 ESP-01 with ESP firmware 2.2.1) --------------------------------
  388.  
  389. // NOTE: all settings (maps, absolute position source etc.) are stored in your phone - when using another
  390.  
  391. // device for the WIFI connection (PC etc.), you will have to transfer those settings (share maps via app,
  392.  
  393. // re-enter absolute position source etc) !
  394.  
  395. // see Wiki on how to install the WIFI module and configure the WIFI jumpers:
  396.  
  397. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#Bluetooth_BLE_UART_module
  398.  
  399.  
  400.  
  401. #define START_AP false // should WIFI module start its own access point?
  402.  
  403. #define WIFI_IP 192,168,2,15 // choose IP e.g. 192,168,4,1 (comment out for dynamic IP/DHCP) - NOTE: use commans instead of points
  404.  
  405. #define WIFI_SSID "myssid" // choose WiFi network ID
  406.  
  407. #define WIFI_PASS "mypassword" // choose WiFi network password
  408.  
  409.  
  410.  
  411. // client (app) ---> server (robot)
  412.  
  413. #define ENABLE_SERVER true // must be enabled if robot should act as server (recommended)
  414.  
  415. //#define ENABLE_SERVER false // must be disabled if robot should act as client (requires external relay server)
  416.  
  417.  
  418.  
  419. // 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)
  420.  
  421. // client (app) ---> relay server <--- client (robot)
  422.  
  423. #define ENABLE_RELAY false // must be enabled to use relay server
  424.  
  425. #define RELAY_USER "username" // choose a unique user name/number!
  426.  
  427. #define RELAY_MACHINE "robot1" // choose a unique robot id
  428.  
  429. #define RELAY_HOST "grauonline.net" // relay server name
  430.  
  431. #define RELAY_PORT 5000 // relay server port
  432.  
  433.  
  434.  
  435. //#define ENABLE_UDP 1 // enable console for UDP? (for developers only)
  436.  
  437. #define UDP_SERVER_IP 192,168,2,56 // remote UDP IP and port to connect to
  438.  
  439. #define UDP_SERVER_PORT 4210
  440.  
  441.  
  442.  
  443. // --------- NTRIP client (linux only, highly experimental) ---------------------------------
  444.  
  445. //#define ENABLE_NTRIP 1 // must be activated to use Linux NTRIP
  446.  
  447. #define NTRIP_HOST "se.cr.et.ip" // sapos nrw
  448.  
  449. #define NTRIP_PORT 7071
  450.  
  451. #define NTRIP_MOUNT "secret"
  452.  
  453. #define NTRIP_USER "secret"
  454.  
  455. #define NTRIP_PASS "secret"
  456.  
  457.  
  458.  
  459. // ------ MQTT (for ESP8266 only, highly experimental - ENABLE_SERVER must be set to false for this to work :-/ ) -----------------------------
  460.  
  461. // you can access your robot using a MQTT broker - choose a topic prefix for your robot below - available MQTT topics:
  462.  
  463. // robot1/cmd (cmd can be: start, stop, dock)
  464.  
  465. // robot1/op (current robot operation as text)
  466.  
  467. // robot1/gps/sol (current gps solution as text)
  468.  
  469. // robot1/gps/pos (current gps position as text)
  470.  
  471. //#define ENABLE_MQTT true // start MQTT client? (true for yes, false for no)
  472.  
  473. #define ENABLE_MQTT false
  474.  
  475. #define MQTT_TOPIC_PREFIX "robot1" // the MQTT topic prefix for your robot
  476.  
  477. #define MQTT_SERVER "192.168.2.47" // your MQTT broker IP or hostname (e.g. "broker.mqtt-dashboard.com")
  478.  
  479. #define MQTT_PORT 1883
  480.  
  481.  
  482.  
  483.  
  484.  
  485. // ------ ultrasonic sensor -----------------------------
  486.  
  487. // see Wiki on how to install the ultrasonic sensors:
  488.  
  489. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#Ultrasonic_sensor
  490.  
  491.  
  492.  
  493. #define SONAR_ENABLE true
  494.  
  495. //#define SONAR_ENABLE false
  496.  
  497. #define SONAR_TRIGGER_OBSTACLES true // should sonar be used to trigger obstacles? if not, mower will only slow down
  498.  
  499. #define SONAR_LEFT_OBSTACLE_CM 10 // stop mowing operation below this distance (cm)
  500.  
  501. #define SONAR_CENTER_OBSTACLE_CM 10 // stop mowing operation below this distance (cm)
  502.  
  503. #define SONAR_RIGHT_OBSTACLE_CM 10 // stop mowing operation below this distance (cm)
  504.  
  505.  
  506.  
  507. // ------ rain sensor ----------------------------------------------------------
  508.  
  509. //JUSTIN
  510.  
  511. //#define RAIN_ENABLE true // if activated, mower will dock when rain sensor triggers
  512.  
  513. #define RAIN_ENABLE false
  514.  
  515.  
  516.  
  517. // ------ time-of-flight distance sensor (VL53L0X) -----------------------------
  518.  
  519. // do not use this sensor (not recommended)
  520.  
  521. //#define TOF_ENABLE true
  522.  
  523. #define TOF_ENABLE false
  524.  
  525. #define TOF_OBSTACLE_CM 100 // stop mowing operation below this distance (cm)
  526.  
  527.  
  528.  
  529.  
  530.  
  531. // ------ bumper sensor (bumperduino, freewheel etc.) ----------------
  532.  
  533. // see Wiki on how to install bumperduino or freewheel sensor:
  534.  
  535. // https://wiki.ardumower.de/index.php?title=Bumper_sensor
  536.  
  537. // https://wiki.ardumower.de/index.php?title=Free_wheel_sensor
  538.  
  539. #define BUMPER_ENABLE true
  540.  
  541. // #define BUMPER_ENABLE false
  542.  
  543. #define BUMPER_DEADTIME 1000 // linear motion dead-time (ms) after bumper is allowed to trigger
  544.  
  545.  
  546.  
  547.  
  548.  
  549. // ----- battery charging current measurement (INA169) --------------
  550.  
  551. // the Marotronics charger outputs max 1.5A
  552.  
  553. // ( https://www.marotronics.de/Ladegeraete-fuer-den-Ardumower-Akkus-24V-mit-Status-LED-auch-fuer-Li-Ion-Akkus )
  554.  
  555. // so we are using the INA169 in non-bridged mode (max. 2.5A)
  556.  
  557. // ( https://www.marotronics.de/INA169-Analog-DC-Current-Sensor-Breakout-60V-25A-5A-Marotronics )
  558.  
  559.  
  560.  
  561. //#define CURRENT_FACTOR 0.5 // PCB1.3 (non-bridged INA169, max. 2.5A)
  562.  
  563. //#define CURRENT_FACTOR 1.0 // PCB1.3 (bridged INA169, max. 5A)
  564.  
  565. #define CURRENT_FACTOR 1.98 // PCB1.4 (non-bridged INA169, max. 2.5A)
  566.  
  567. //#define CURRENT_FACTOR 2.941 // PCB1.4 (bridged INA169, max. 5A)
  568.  
  569.  
  570.  
  571. #define GO_HOME_VOLTAGE 21.5 // start going to dock below this voltage
  572.  
  573. // The battery will charge if both battery voltage is below that value and charging current is above that value.
  574.  
  575. #define BAT_FULL_VOLTAGE 28.7 // start mowing again at this voltage
  576.  
  577. #define BAT_FULL_CURRENT 0.2 // start mowing again below this charging current (amps)
  578.  
  579.  
  580.  
  581. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#Automatic_battery_switch_off
  582.  
  583. #define BAT_SWITCH_OFF_IDLE false // switch off if idle (JP8 must be set to autom.)
  584.  
  585. //#define BAT_SWITCH_OFF_UNDERVOLTAGE true // switch off if undervoltage (JP8 must be set to autom.)
  586.  
  587. //JUSTIN
  588.  
  589. #define BAT_SWITCH_OFF_UNDERVOLTAGE false // switch off if undervoltage (JP8 must be set to autom.)
  590.  
  591.  
  592.  
  593.  
  594.  
  595. // ------ GPS ------------------------------------------
  596.  
  597. // ------- RTK GPS module -----------------------------------
  598.  
  599. // see Wiki on how to install the GPS module and configure the jumpers:
  600.  
  601. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#Bluetooth_BLE_UART_module
  602.  
  603. //
  604.  
  605. // NOTE: if you experience GPS checksum errors, try to increase UART FIFO size:
  606.  
  607. // 1. Arduino IDE->File->Preferences->Click on 'preferences.txt' at the bottom
  608.  
  609. // 2. Locate file 'packages/arduino/hardware/sam/xxxxx/cores/arduino/RingBuffer.h'
  610.  
  611. // (for Adafruit Grand Central M4: 'packages\adafruit\hardware\samd\xxxxx\cores\arduino\RingBuffer.h')
  612.  
  613. // change: #define SERIAL_BUFFER_SIZE 256 into into: #define SERIAL_BUFFER_SIZE 1024
  614.  
  615.  
  616.  
  617. //#define GPS_USE_TCP 1 // comment out for serial gps, activate for TCP client-based GPS
  618.  
  619. //#define GPS_SKYTRAQ 1 // comment out for ublox gps, uncomment for skytraq gps/NMEA
  620.  
  621.  
  622.  
  623. #define REQUIRE_VALID_GPS true // mower will pause if no float and no fix GPS solution during mowing (recommended)
  624.  
  625. //#define REQUIRE_VALID_GPS false // mower will continue to mow if no float or no fix solution (not recommended)
  626.  
  627.  
  628.  
  629. #define GPS_SPEED_DETECTION true // will detect obstacles via GPS feedback (no speed) - recommended
  630.  
  631. //#define GPS_SPEED_DETECTION false
  632.  
  633.  
  634.  
  635. // detect if robot is actually moving (obstacle detection via GPS feedback)
  636.  
  637. #define GPS_MOTION_DETECTION true // if robot is not moving trigger obstacle avoidance (recommended)
  638.  
  639. //#define GPS_MOTION_DETECTION false // ignore if robot is not moving
  640.  
  641. #define GPS_MOTION_DETECTION_TIMEOUT 5 // timeout for motion (secs)
  642.  
  643.  
  644.  
  645. // configure ublox f9p with optimal settings (will be stored in f9p RAM only)
  646.  
  647. // NOTE: due to a PCB1.3 bug GPS_RX pin is not working and you have to fix this by a wire:
  648.  
  649. // https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#PCB1.3_GPS_pin_fix_and_wire_fix (see 'GPS wire fix')
  650.  
  651. #define GPS_REBOOT_RECOVERY true // allow GPS receiver rebooting (recommended - requires GPS wire fix above! otherwise firmware will stuck at boot!)
  652.  
  653. //#define GPS_REBOOT_RECOVERY false // do not allow rebooting GPS receiver (no GPS wire fix required)
  654.  
  655.  
  656.  
  657. #define GPS_CONFIG true // configure GPS receiver (recommended - requires GPS wire fix above! otherwise firmware will stuck at boot!)
  658.  
  659. //#define GPS_CONFIG false // do not configure GPS receiver (no GPS wire fix required)
  660.  
  661.  
  662.  
  663. #define GPS_CONFIG_FILTER true // use signal strength filter? (recommended to get rid of 'FIX jumps') - adjust filter settings below
  664.  
  665. //#define GPS_CONFIG_FILTER false // use this if you have difficulties to get a FIX solution (uses ublox default filter settings)
  666.  
  667. #define CPG_CONFIG_FILTER_MINELEV 10 // Min SV elevation degree: 14 (high elevation, less robust), 10 (low elevation, robust)
  668.  
  669. #define CPG_CONFIG_FILTER_NCNOTHRS 10 // C/N0 Threshold #SVs: 10 (robust), 6 (less robust)
  670.  
  671. #define CPG_CONFIG_FILTER_CNOTHRS 30 // 30 dbHz (robust), 13 dbHz (less robust)
  672.  
  673.  
  674.  
  675.  
  676.  
  677. // ------ obstacle detection and avoidance -------------------------
  678.  
  679.  
  680.  
  681. #define ENABLE_PATH_FINDER true // path finder calculates routes around exclusions and obstacles
  682.  
  683. //#define ENABLE_PATH_FINDER false
  684.  
  685. #define ALLOW_ROUTE_OUTSIDE_PERI_METER 1.0 // max. distance (m) to allow routing from outside perimeter
  686.  
  687. // (increase if you get 'no map route' errors near perimeter)
  688.  
  689.  
  690.  
  691. #define OBSTACLE_DETECTION_ROTATION true // detect robot rotation stuck (requires IMU)
  692.  
  693. // #define OBSTACLE_DETECTION_ROTATION false // NOTE: recommended to turn this off for slope environment
  694.  
  695.  
  696.  
  697. #define OBSTACLE_AVOIDANCE true // try to find a way around obstacle
  698.  
  699. //#define OBSTACLE_AVOIDANCE false // stop robot on obstacle
  700.  
  701. #define OBSTACLE_DIAMETER 1.2 // choose diameter of obstacles placed in front of robot (m) for obstacle avoidance
  702.  
  703.  
  704.  
  705. // detect robot being kidnapped? robot will try GPS recovery if distance to tracked path is greater than a certain value
  706.  
  707. // (false GPS fix recovery), and if that fails go into error
  708.  
  709. #define KIDNAP_DETECT true // recommended
  710.  
  711. //#define KIDNAP_DETECT false
  712.  
  713. #define KIDNAP_DETECT_ALLOWED_PATH_TOLERANCE 1.0 // allowed path tolerance (m)
  714.  
  715.  
  716.  
  717.  
  718.  
  719. // ------ docking --------------------------------------
  720.  
  721. // is a docking station available?
  722.  
  723. #define DOCKING_STATION true // use this if docking station available and mower should dock automatically
  724.  
  725. //#define DOCKING_STATION false // mower will just stop after mowing instead of docking automatically
  726.  
  727.  
  728.  
  729. #define DOCK_IGNORE_GPS false // use GPS fix in docking station and IMU for GPS float/invalid
  730.  
  731. //#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)
  732.  
  733.  
  734.  
  735. //#define DOCK_AUTO_START true // robot will automatically continue mowing after docked automatically
  736.  
  737. #define DOCK_AUTO_START false // robot will not automatically continue mowing after docked automatically
  738.  
  739.  
  740.  
  741.  
  742.  
  743. // ---- path tracking -----------------------------------
  744.  
  745. // stanley control for path tracking - determines gain how fast to correct for lateral path errors
  746.  
  747. #define STANLEY_CONTROL_P_NORMAL 3.0 // 3.0 for path tracking control (angular gain) when mowing
  748.  
  749. #define STANLEY_CONTROL_K_NORMAL 1.0 // 1.0 for path tracking control (lateral gain) when mowing
  750.  
  751.  
  752.  
  753. #define STANLEY_CONTROL_P_SLOW 3.0 // 3.0 for path tracking control (angular gain) when docking tracking
  754.  
  755. #define STANLEY_CONTROL_K_SLOW 0.1 // 0.1 for path tracking control (lateral gain) when docking tracking
  756.  
  757.  
  758.  
  759.  
  760.  
  761. // ----- other options --------------------------------------------
  762.  
  763.  
  764.  
  765. // button control (turns on additional features via the POWER-ON button)
  766.  
  767. #define BUTTON_CONTROL true // additional features activated (press-and-hold button for specific beep count:
  768.  
  769. // 1 beep=start/stop, 5 beeps=dock, 3 beeps=R/C mode ON/OFF)
  770.  
  771. //#define BUTTON_CONTROL false // additional features deactivated
  772.  
  773.  
  774.  
  775. //#define USE_TEMP_SENSOR // only activate if temp sensor (htu21d) connected
  776.  
  777.  
  778.  
  779. // activate support for model R/C control?
  780.  
  781. // use PCB pin 'mow' for R/C model control speed and PCB pin 'steering' for R/C model control steering,
  782.  
  783. // also connect 5v and GND and activate model R/C control via PCB P20 start button for 3 sec.
  784.  
  785. // more details: https://wiki.ardumower.de/index.php?title=Ardumower_Sunray#R.2FC_model
  786.  
  787. //#define RCMODEL_ENABLE true
  788.  
  789. #define RCMODEL_ENABLE false
  790.  
  791.  
  792.  
  793.  
  794.  
  795. // ------ experimental options -------------------------
  796.  
  797.  
  798.  
  799. // drive curves smoothly?
  800.  
  801. //#define SMOOTH_CURVES true
  802.  
  803. #define SMOOTH_CURVES false
  804.  
  805.  
  806.  
  807. // --------- serial monitor output (CONSOLE) ------------------------
  808.  
  809. // which Arduino Due USB port do you want to your for serial monitor output (CONSOLE)?
  810.  
  811. // Arduino Due native USB port => choose SerialUSB
  812.  
  813. // Arduino Due programming port => choose Serial
  814.  
  815. #ifdef _SAM3XA_
  816.  
  817. #define BOARD "Arduino Due"
  818.  
  819. #define CONSOLE SerialUSB // Arduino Due: do not change (used for Due native USB serial console)
  820.  
  821. #elif __SAMD51__
  822.  
  823. #define BOARD "Adafruit Grand Central M4"
  824.  
  825. #define CONSOLE Serial // Adafruit Grand Central M4
  826.  
  827. #elif __linux__
  828.  
  829. #define BOARD "Linux"
  830.  
  831. #define CONSOLE Console
  832.  
  833. #endif
  834.  
  835.  
  836.  
  837. // ------- serial ports and baudrates---------------------------------
  838.  
  839. #define CONSOLE_BAUDRATE 115200 // baudrate used for console
  840.  
  841. //#define CONSOLE_BAUDRATE 921600 // baudrate used for console
  842.  
  843. #define BLE_BAUDRATE 115200 // baudrate used for BLE
  844.  
  845. #define BLE_NAME "Ardumower" // name for BLE module
  846.  
  847. #define GPS_BAUDRATE 115200 // baudrate for GPS RTK module
  848.  
  849. #define WIFI_BAUDRATE 115200 // baudrate for WIFI module
  850.  
  851. #define ROBOT_BAUDRATE 115200 // baudrate for Linux serial robot (non-Ardumower)
  852.  
  853.  
  854.  
  855. #ifdef _SAM3XA_ // Arduino Due
  856.  
  857. #define WIFI Serial1
  858.  
  859. #define ROBOT Serial1
  860.  
  861. #define BLE Serial2
  862.  
  863. #define GPS Serial3
  864.  
  865. //#define GPS Serial // only use this for .ubx logs (sendgps.py)
  866.  
  867. #elif __SAMD51__ // Adafruit Grand Central M4
  868.  
  869. #define WIFI Serial2
  870.  
  871. #define ROBOT Serial2
  872.  
  873. #define BLE Serial3
  874.  
  875. #define GPS Serial4
  876.  
  877. #elif __linux__
  878.  
  879. #define WIFI SerialWIFI
  880.  
  881. #define SERIAL_WIFI_PATH "/dev/null"
  882.  
  883. #define BLE SerialBLE
  884.  
  885. #define GPS SerialGPS
  886.  
  887. #define SERIAL_GPS_PATH "/dev/serial/by-id/usb-u-blox_AG_-_www.u-blox.com_u-blox_GNSS_receiver-if00"
  888.  
  889. #define GPS_HOST "127.0.0.1"
  890.  
  891. #define GPS_PORT 2947
  892.  
  893. #define ROBOT SerialROBOT
  894.  
  895. #define SERIAL_ROBOT_PATH "/dev/ttyUSB1"
  896.  
  897. #define NTRIP SerialNTRIP
  898.  
  899. #define SERIAL_NTRIP_PATH "/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_00000000-if00-port0"
  900.  
  901. #endif
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909. // ------- I2C addresses -----------------------------
  910.  
  911. #define DS1307_ADDRESS B1101000
  912.  
  913. #define AT24C32_ADDRESS B1010000
  914.  
  915.  
  916.  
  917.  
  918.  
  919. // ------- PCB1.3/Due settings -------------------------
  920.  
  921. #define IOREF 3.3 // I/O reference voltage
  922.  
  923.  
  924.  
  925. // ------ hardware pins---------------------------------------
  926.  
  927. // no configuration needed here
  928.  
  929. #define pinMotorEnable 37 // EN motors enable
  930.  
  931. #define pinMotorLeftPWM 5 // M1_IN1 left motor PWM pin
  932.  
  933. #define pinMotorLeftDir 31 // M1_IN2 left motor Dir pin
  934.  
  935. #define pinMotorLeftSense A1 // M1_FB left motor current sense
  936.  
  937. #define pinMotorLeftFault 25 // M1_SF left motor fault
  938.  
  939.  
  940.  
  941. #define pinMotorRightPWM 3 // M2_IN1 right motor PWM pin
  942.  
  943. #define pinMotorRightDir 33 // M2_IN2 right motor Dir pin
  944.  
  945. #define pinMotorRightSense A0 // M2_FB right motor current sense
  946.  
  947. #define pinMotorRightFault 27 // M2_SF right motor fault
  948.  
  949.  
  950.  
  951. #define pinMotorMowPWM 2 // M1_IN1 mower motor PWM pin (if using MOSFET, use this pin)
  952.  
  953. #define pinMotorMowDir 29 // M1_IN2 mower motor Dir pin (if using MOSFET, keep unconnected)
  954.  
  955. #define pinMotorMowSense A3 // M1_FB mower motor current sense
  956.  
  957. #define pinMotorMowFault 26 // M1_SF mower motor fault (if using MOSFET/L298N, keep unconnected)
  958.  
  959. #define pinMotorMowEnable 28 // EN mower motor enable (if using MOSFET/L298N, keep unconnected)
  960.  
  961. #define pinMotorMowRpm A11
  962.  
  963.  
  964.  
  965. #define pinFreeWheel 8 // front/rear free wheel sensor
  966.  
  967. #define pinBumperLeft 39 // bumper pins
  968.  
  969. #define pinBumperRight 38
  970.  
  971.  
  972.  
  973. #define pinDropLeft 45 // drop pins Dropsensor - Absturzsensor
  974.  
  975. #define pinDropRight 23 // drop pins Dropsensor - Absturzsensor
  976.  
  977.  
  978.  
  979. #define pinSonarCenterTrigger 24 // ultrasonic sensor pins
  980.  
  981. #define pinSonarCenterEcho 22
  982.  
  983. #define pinSonarRightTrigger 30
  984.  
  985. #define pinSonarRightEcho 32
  986.  
  987. #define pinSonarLeftTrigger 34
  988.  
  989. #define pinSonarLeftEcho 36
  990.  
  991. #define pinPerimeterRight A4 // perimeter
  992.  
  993. #define pinDockingReflector A4 // docking IR reflector
  994.  
  995. #define pinPerimeterLeft A5
  996.  
  997.  
  998.  
  999. #define pinLED 13 // LED
  1000.  
  1001. #define pinBuzzer 53 // Buzzer
  1002.  
  1003. #define pinTilt 35 // Tilt sensor (required for TC-G158 board)
  1004.  
  1005. #define pinButton 51 // digital ON/OFF button
  1006.  
  1007. #define pinBatteryVoltage A2 // battery voltage sensor
  1008.  
  1009. #define pinBatterySwitch 4 // battery-OFF switch
  1010.  
  1011. #define pinChargeVoltage A9 // charging voltage sensor
  1012.  
  1013. #define pinChargeCurrent A8 // charge current sensor
  1014.  
  1015. #define pinChargeRelay 50 // charge relay
  1016.  
  1017. #define pinRemoteMow 12 // remote control mower motor
  1018.  
  1019. #define pinRemoteSteer 11 // remote control steering
  1020.  
  1021. #define pinRemoteSpeed 10 // remote control speed
  1022.  
  1023. #define pinRemoteSwitch 52 // remote control switch
  1024.  
  1025. #define pinVoltageMeasurement A7 // test pin for your own voltage measurements
  1026.  
  1027. #if defined(_SAM3XA_) // Arduino Due
  1028.  
  1029. #define pinOdometryLeft DAC0 // left odometry sensor
  1030.  
  1031. #define pinOdometryRight CANRX // right odometry sensor
  1032.  
  1033. #define pinReservedP46 CANTX // reserved
  1034.  
  1035. #define pinReservedP48 DAC1 // reserved
  1036.  
  1037. #else // Adafruit Grand Central M4
  1038.  
  1039. #define pinOdometryLeft A12 // left odometry sensor
  1040.  
  1041. #define pinOdometryRight A14 // right odometry sensor
  1042.  
  1043. #define pinReservedP46 A15 // reserved
  1044.  
  1045. #define pinReservedP48 A13 // reserved
  1046.  
  1047. #endif
  1048.  
  1049. #define pinLawnFrontRecv 40 // lawn sensor front receive
  1050.  
  1051. #define pinLawnFrontSend 41 // lawn sensor front sender
  1052.  
  1053. #define pinLawnBackRecv 42 // lawn sensor back receive
  1054.  
  1055. #define pinLawnBackSend 43 // lawn sensor back sender
  1056.  
  1057. #define pinUserSwitch1 46 // user-defined switch 1
  1058.  
  1059. #define pinUserSwitch2 47 // user-defined switch 2
  1060.  
  1061. #define pinUserSwitch3 48 // user-defined switch 3
  1062.  
  1063. #define pinRain 44 // rain sensor
  1064.  
  1065. #define pinReservedP14 A7 // reserved
  1066.  
  1067. #define pinReservedP22 A6 // reserved
  1068.  
  1069. #define pinReservedP26 A10 // reserved
  1070.  
  1071.  
  1072.  
  1073. // IMU (compass/gyro/accel): I2C (SCL, SDA)
  1074.  
  1075. // Bluetooth: Serial2 (TX2, RX2)
  1076.  
  1077. // GPS: Serial3 (TX3, RX3)
  1078.  
  1079. // WIFI: Serial1 (TX1, RX1)
  1080.  
  1081.  
  1082.  
  1083. #define DEBUG(x) CONSOLE.print(x)
  1084.  
  1085. #define DEBUGLN(x) CONSOLE.println(x)
  1086.  
  1087.  
  1088.  
  1089. #if defined(ENABLE_SD_LOG)
  1090.  
  1091. #define CONSOLE sdSerial
  1092.  
  1093. #elif defined(ENABLE_UDP)
  1094.  
  1095. #define CONSOLE udpSerial
  1096.  
  1097. #endif
  1098.  
  1099.  
  1100.  
  1101. #ifndef SDCARD_SS_PIN
  1102.  
  1103. #if defined(_SAM3XA_) // Arduino Due
  1104.  
  1105. #define SDCARD_SS_PIN pinUserSwitch1
  1106.  
  1107. #else
  1108.  
  1109. #define SDCARD_SS_PIN 4
  1110.  
  1111. #endif
  1112.  
  1113. #endif
  1114.  
  1115.  
  1116.  
  1117. // the following will be used by Arduino library RingBuffer.h - to verify this Arduino library file:
  1118.  
  1119. // 1. Arduino IDE->File->Preferences->Click on 'preferences.txt' at the bottom
  1120.  
  1121. // 2. Locate file 'packages/arduino/hardware/sam/xxxxx/cores/arduino/RingBuffer.h
  1122.  
  1123.  
  1124.  
  1125. #define SERIAL_BUFFER_SIZE 1024
  1126.  
  1127.  
  1128.  
  1129. #ifdef BNO055
  1130.  
  1131. #define MPU9250 // just to make mpu driver happy to compile something
  1132.  
  1133. #endif[/CODE]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement