// #define MPU6050
//#define MPU9150
#define MPU9250 // also choose this for MPU9255
//#define BNO055
//#define ICM20948
#define MPU_ADDR 0x69 // I2C address (0x68 if AD0=LOW, 0x69 if AD0=HIGH)
// imu fifo rate (Hz)
#define IMU_FIFO_RATE 5
// should the mower turn off if IMU is tilt over? (yes: uncomment line, no: comment line)
#define ENABLE_TILT_DETECTION 1
// --------- lift sensor (e.g. Alfred mower) ---------------------------------------------
// should the lift sensor be enabled? (yes: uncomment line, no: comment line)
//#define ENABLE_LIFT_DETECTION 1
// should the lift sensor be used for obstacle avoidance (if not, mower will simply go into error if lifted)
// #define LIFT_OBSTACLE_AVOIDANCE 1
////////////////////////////////////////////////////////////////////////////////////////////////////
//Modsection START
//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...
//Experimental Modfunctions/Options/Speeds/Time etc. for different stuff and movement operations. Please read the descriptions. Cheers.
//Mower general times and speeds with their condition parameters, this section is the easiest to be tuned for one´s needs... so feel free and just tune to what you want to see on the lawn
#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
#define OVERLOADSPEED 0.15 // (m/s) if there is a overloadcurrent of a motordriver, mower will use OVERLOADSPEED
#define TRACKSLOWSPEED 0.20 // (m/s) e.g the docking speed or functions of the future
#define NEARWAYPOINTSPEED 0.25 // (m/s) the speed of mower when reaching/leaving a waypoint
#define NEARWAYPOINTDISTANCE 0.45 // (m) the distance of mower if approaching and leaving a waypoint and thus triggers NEARWAYPOINTSPEED of mower
#define FLOATSPEED 0.25 // (m/s) on GPS FLOAT SOLUTION, mower will use FLOATSPEED
#define SONARSPEED 0.15 // (m/s) if sonar enabled and used, on sonar trigger mower will use SONARSPEED
#define OBSTACLEAVOIDANCESPEED 0.35 // (m/s) on obstacle evade operations, mower will use OBSTACLEAVOIDANCESPEED
#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
#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)
#define GLOBALSPEEDLIMIT true // if true, MOTOR_MAX_SPEED and MOTOR_MIN_SPEED will limit possible code bugs or inputs directly in
motor.cpp
#define MOTOR_MAX_SPEED 0.60 // (m/s) maximum mower speed
#define MOTOR_MIN_SPEED 0.05 // (m/s) minimal mower speed
//rotation speeds, also this is easy to tune for your expectations
#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)
#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)
#define ROTATETOTARGETSPEED2 40.0 // (deg/s) if angle difference to point is between ANGLEDIFF1 and ANGLEDIFF2 then this value will be used...
#define ROTATETOTARGETSPEED3 25.0 // (deg/s) if angle difference to point is less than ANGLEDIFF2 then this value will be used...
#define ANGLEDIFF1 30.0 // (deg) if angle to point is more than ANGLEDIFF1 --> ROTATETOTARGETSPEED1 will be used
#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...
#define ANGLEPRECISE 5.0 // (deg) if Angle to point ist within 5deg, mower will continue with Linetracker.cpp Stanleycode and NEARWAYPOINT setup
//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)
//CONFIG HINT: for the following options it is important if you have mow
motor odometrie: USE_MOW_RPM_SET, ADAPTIVE_SPEED_MODE, ESCAPE_LAWN_MODE. If you do not have odometrie: use mode 1 on both cases and set USE_MOW_RPM_SET = false, if you have odometrie use mode 2 on both cases and set USE_MOW_RPM_SET = true (recommended)
#define USE_MOW_RPM_SET false // uses RPM instead of PWM to set mowmotor (RPM_FAULT_DETECTION of orig Sunray is best to be set TRUE for all RPM based functions!!)
#define MOWMOTOR_RPM_OFFSET 110 // compensate small RPM offsets (positive if RPM reading is less then RPM setpoint)
#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
#define MOWMOTOR_PID_KI 0.002 // (0.04 (Mowmotordriver DRV8308/JYQD))
#define MOWMOTOR_PID_KD 0.00 // (0.0000 (Mowmotordriver DRV8308/JYQD))
//adaptive_speed settings on RPM or LOAD of mowmotor (consider if you have mowmotor odometrie)
#define ADAPTIVE_SPEED false // if true, mowing speed will adjust to RPM or MOWMOTORPOWER of mow
motor on all forward speed mow operations
#define ADAPTIVE_SPEED_MODE 1 // (1, 2) adaptive speed modes. mode 1 - uses mowmotorpower measurement for speeding up/down; mode 2 - uses rpm measurement of mowmotor for speeding up/down
#define MOWPOWERMAX_AUTO true // uses highest actual measured mowPower during operation, if true MOWPOWERMAX is ignored
#define MOWPOWERMIN 10.0 // (Watt) idle Power of Mowmotor or minimum load power of mowmotor, if under this load mower will have maximum speed
#define MOWPOWERMAX 35.0 // (Watt) max load power of mowmotor, when hitting this load mower will be at minspeed
#define MOW_RPM_NORMAL 3000 // (3200)(rpm, only used if USE_MOW_RPM_SET = true) 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!)
#define MOW_RPM_SLOW 3300 // (3400)(rpm, only used if USE_MOW_RPM_SET = true) mow
motor rpm when MOW_RPMtr_SLOW (%) of MOW_RPM_NORMAL (rpm) is met. Should be higher or the same as MOW_RPM_NORMAL
#define MOW_RPM_RETRY 3600 // (3600)(rpm, only used if USE_MOW_RPM_SET = true) 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)
#define MOW_PWM_NORMAL 185 // (pwm, only used if USE_MOW_RPM_SET = false) pwm of mow
motor for normal mowing
#define MOW_PWM_SLOW 205 // (pwm, only used if USE_MOW_RPM_SET = false) pwm of mow
motor when during mowing a keepslow state is triggered. Should be higher or the same as MOW_PWM_NORMAL
#define MOW_PWM_RETRY 235 // (pwm, only used if USE_MOW_RPM_SET = false) pwm of mow
motor when during mowing a retryslow state is triggered (after escape lawn). Should be higher or the same as MOW_PWM_SLOW
//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
#define ESCAPE_LAWN false // 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
#define ESCAPE_LAWN_MODE 1 // (1, 2) escape lawn modes to trigger escape becouse of high motormow load: mode 1 - uses mowmotorpower for triggering, mode 2 - uses rpm for triggering
#define MOW_POWERtr_STALL 80 // (%, only used if ESCAPE_LAWN_MODE = 1) if power of mowmotor exceeds e.g 90% of MOWPOWERMAX, escapelawn is triggered
#define MOW_POWERtr_SLOW 70 // (%, only used if ESCAPE_LAWN_MODE = 1) if power of mowmotor exceeds e.g 70% of MOWPOWERMAX, keepslow is triggered
#define MOW_RPMtr_STALL 60 // (70)(%, only used if ESCAPE_LAWN_MODE = 2) if RPM of mowmotor stalls under % of MOW_RPM_NORMAL mower will back up with ESCAPELAWNDISTANCE and ESCAPELAWNSPEED and try again
#define MOW_RPMtr_SLOW 80 // (85)(%, only used if ESCAPE_LAWN_MODE = 2) if RPM of mowmotor stalls under % of MOW_RPM_NORMAL mower will trigger a keepSlow state with KEEPSLOWSPEED
#define ESCAPELAWNSPEED 0.35 // (m/s) speed of mower reverse due to MOW_RPM_STALL trigger
#define ESCAPELAWNDISTANCE 0.5 // (m) distance mower reverses with ESCAPELAWNSPEED due to MOW_RPM_STALL triggered
#define ESCAPELAWNWAITTIME 5000 // (ms)after reversing the second time within ESCAPELAWNTIMER, mower will wait for this time before continue (recover rpm)
#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
#define ESCAPELAWN_DEADTIME 3000 // (ms)deadtime between allowed ESCAPELAWN triggers (deadtime should be the reverse time of action and be calculated in code :| )
#define MAXRETRY 5 // number of possible retries of ESCAPELAWN within ESCAPELAWNTIMER until there will be an obstacle error or obstacle avoidance
#define MAXRETRYOBSTACLE false // if true, ESCAPELAWN will trigger Obstacle avoidance when to many MAXRETRY´s and will not trigger an error
#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
#define KEEPSLOWSPEED 0.25 // mower will use this speed if there is a rpm stall (%) of mowingblades defined by MOW_RPMtr_SLOW
#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
#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.
//stanley options for experiments
#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)
#define STANLEYNORMALMUL false // if true, StanleyNormal parameters in Sunray-App will be multiplied by 10! (0,1 = 1) (for testing)
//svol0s GPS reboot option after undocking-->mowing
#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)
#define GPSWAITREBOOT 15000 // (ms) time to wait after rebooting gps for response from ublox?
#define GPS_STABLETIME 30000 // (ms) GPS Time with fix solution, before continueing from DOCK_POINT_GPS_REBOOT after undock
#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
#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)
//keep mower from rotating in dock by all means, needs situation dependent tuning, so be aware!
#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!
#define DOCK_NO_ROTATION_DISTANCE 1.2 // (m) distance to dockpoint to stop angular motion of mower, make sure mower comes straight to dock and the point distance from dockpoint to pointbefore is double this number!
#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.
#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
//GPS
#define GPS_RESET_WAIT_FIX true // reset GPS if mower is in a float timeout?
#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
#define GPS_NO_SPEED_TIME 2000 // (ms) time for GPS no speed trigger --> obstacle
//other
#define MOW_START_AT_WAYMOW true // mowmotor only starts if way state of mower is waymow for the first time, used for mowmotor not starting directly at dock, but at mow area. This is a onetime trigger that only works when mower is ---> undocking ---> wayfree ---> mowarea ---> start mowmotor. After this, mowmotor will behave like it used to be
//obstacle behaviour when OBSTACLE_ROTATION is enabled and escapeForward is triggered due to IMUYaw difference (wheel at backside, popo situation)
#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)
#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)
//try to fix 8308 driver with pwm (keep FALSE if you have no issues or no DRV8308, this is for experiments only) ---> to be removed
#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
#define DRVFIXITERATIONS 5 // iterations of code for pwm of drivers to be PWM_GEAR and PWM_MOW (below)
#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
#define PWM_GEAR 1 // PWM for DRVFIX efforts..
#define PWM_MOW 1 // PWM for DRVFIX efforts..
//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)
#define MOVE_REGULARLY true // if true, mower will move in dock in given MOVE_AGAIN_AFTER time, kk: move mower to keep 8308 alive
#define MOVE_AGAIN_AFTER 10.0 // kk: move the mower every xx minutes
#define MOVING_TIME 400 // kk: time (ms) for moving back
#define SWITCH_OFF_TRACTION_MOTORS true // should tractionmotors be disabled in dock?
//LOG
#define OUTPUT_ENABLED false // output standard Sunray_FW LOG in serial monitor and SDlog
#define CALC_LOOPTIME false // calc and output the sunray loop time in serial monitor and SDlog
#define TUNING_LOG true // outputs valuable var-states of sunray for debugging tuning functions or just for observation and insights
#define TUNING_LOG_TIME 5000 // (ms) periodic output time of TUNING_LOG
#define DEBUG_LOG true // adds output informations on changed mower states, functions and operations
//Modsection END
\#define FREEWHEEL_IS_AT_BACKSIDE true // default Ardumower: true (change to false, if your freewheel is at frontside) - this is used for obstacle avoidance
#define WHEEL_BASE_CM 36 // wheel-to-wheel distance (cm)
#define WHEEL_DIAMETER 250 // (250) wheel diameter (mm)
#define MOWER_SIZE 60 // mower / chassis size / length in cm
#define ENABLE_ODOMETRY_ERROR_DETECTION true // use this to detect odometry erros
//#define ENABLE_ODOMETRY_ERROR_DETECTION false
// choose ticks per wheel revolution :
#define TICKS_PER_REVOLUTION 696 /2 // odometry ticks per wheel revolution
// ...for the older 42mm diameter
motor (white connector)
https://wiki.ardumower.de/images/d/d6/Ardumower_chassis_inside_ready.jpg
#define MOTOR_MOW_TICKS_PER_REVOLUTION 12 /2 //ACT BLDC
MOTOR from Shop = 6! (DRV8308/JYQD)
// ----- gear motors --------------------------------------------------
// for
brushless motors, study the sections (drivers, adapter, protection etc.) in the Wiki (
https://wiki.ardumower.de/index.php?title=DIY_Brushless_Driver_Board)
// #define MOTOR_DRIVER_BRUSHLESS 1 // uncomment this for new
brushless motor drivers
//#define MOTOR_DRIVER_BRUSHLESS_MOW_DRV8308 1 // uncomment for
brushless DRV8308 driver and mowing
motor
//#define MOTOR_DRIVER_BRUSHLESS_MOW_A4931 1 // uncomment for
brushless A3931 driver and mowing
motor
//#define MOTOR_DRIVER_BRUSHLESS_MOW_BLDC8015A 1 // uncomment for
brushless BLDC8015A driver and mowing
motor
// #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/)
//#define MOTOR_DRIVER_BRUSHLESS_MOW_OWL 1 // uncomment for
brushless owlDrive mowing
motor
// #define MOTOR_DRIVER_BRUSHLESS_GEARS_DRV8308 1 // uncomment for
brushless DRV8308 driver and gear/traction motors
//#define MOTOR_DRIVER_BRUSHLESS_GEARS_A4931 1 // uncomment for
brushless A4931 driver and gear/traction motors
//#define MOTOR_DRIVER_BRUSHLESS_GEARS_BLDC8015A 1 // uncomment for
brushless BLDC8015A driver and gear/traction motors
//#define MOTOR_DRIVER_BRUSHLESS_GEARS_JYQD 1 // uncomment for
brushless JYQD driver and gears/traction
motor
//#define MOTOR_DRIVER_BRUSHLESS_GEARS_OWL 1 // uncomment for
brushless owlDrive gears/traction
motor
#define MOTOR_FAULT_CURRENT 6.0 // gear motors fault current (amps)
#define MOTOR_TOO_LOW_CURRENT 0.005 // gear
motor too low current (amps)
#define MOTOR_OVERLOAD_CURRENT 0.8 // gear motors overload current (amps)
#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)
//#define USE_LINEAR_SPEED_RAMP false // do not use a speed ramp
//
motor speed control (PID coefficients) - these values are tuned for Ardumower motors
// general information about PID controllers:
https://wiki.ardumower.de/index.php?title=PID_control
#define MOTOR_PID_LP 0.0 // encoder low-pass filter (use for low encoder tickcount - use zero to disable)
#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)
#define MOTOR_PID_KI 0.03 // do not change 0.03
#define MOTOR_PID_KD 0.03 // do not change 0.03
#define MOTOR_PID_LIMIT 255 // output limit - do not change 255
#define MOTOR_PID_RAMP 0 // output derivative limit - do not change 0
//#define MOTOR_LEFT_SWAP_DIRECTION 1 // uncomment to swap left
motor direction
//#define MOTOR_RIGHT_SWAP_DIRECTION 1 // uncomment to swap right
motor direction
// ----- mowing
motor -------------------------------------------------
#define ENABLE_MOW_MOTOR true // Default is true, set false for testing purpose to switch off mow
motor permanently
#define MOW_FAULT_CURRENT 8 // mowing
motor fault current (amps)
#define MOW_TOO_LOW_CURRENT 0.005 // mowing
motor too low current (amps)
#define MOW_OVERLOAD_CURRENT 3.5 // mowing
motor overload current (amps)
// should the direction of mowing
motor toggle each start? (yes: true, no: false)
#define MOW_TOGGLE_DIR true
//#define MOW_TOGGLE_DIR false
// should the error on
motor overload detection be enabled?
#define ENABLE_OVERLOAD_DETECTION true // robot will stop on overload
//#define ENABLE_OVERLOAD_DETECTION false // robot will slow down on overload
// should the
motor fault (error) detection be enabled?
#define ENABLE_FAULT_DETECTION true
//#define ENABLE_FAULT_DETECTION false // use this if you keep getting '
motor error'
#define ENABLE_RPM_FAULT_DETECTION false // use mow rpm signal to detect a
motor fault (requires mowing
motor with rpm output!)
//#define ENABLE_RPM_FAULT_DETECTION false // do not use mow rpm signal to detect a
motor fault
// should the robot trigger obstacle avoidance on
motor errors if
motor recovery failed?
#define ENABLE_FAULT_OBSTACLE_AVOIDANCE true