MASSAGE mode is now useable again for now.
(no more random driving and unexpected shaking)
A full rework is still planned.
- Fix setFade method (did not change anything when not writing to nvs)
- joystick/massage:
- reverse motor direction every 2nd cycle to preving driving
- simplify modes (now only FW/REV and LEFT/RIGHT)
- use joystick angle to vary the duty cycle
- optimize delay and duty calculation (min max config)
- drop hysteresis (not much use, just much code)
Briefly tested this - brake works as intended
- Add config options brakeDecel and brakePauseBefureResume
- control: update brakeStartThresholdDuty at startup
and maxDuty change for each motor
- motorctl: drop/simplify decel boost to brake
(faster deceleration at certain threshold)
When moving the joystick in other direction than driving
the deceleration gets speed up.
The boost scales with how far the stick is in other
direction up to a maximum
Some issues with this approach see notes in code
when moving the joystick in opposite direction the
deceleration gets boosted depending on how large
the opposite target duty is up to a maximum
Needs testing, switching between ROTATE mode might
cause issues
Rework joystick command generation
Fix timeout no commands received in motorctl
Successfully tested this state on actual hardware:
turning behavior is significantly improved - does not get slower when turning anymore
joystick:
- add boost of inner tire when turning
- add threshold where ratio snaps to 1
- optimize structure, logging
control:
- rename maxDuty to maxDutyStraight to be more clear
- add methods to change and get new variable RelativeBoostPer for menu item
menu:
- add new item to set maxRelativeBoost config parameter
motorctl:
- fix timeout not working:
previously when not receiving commands for 15s the duty was set to 0 for 1 handle cycle only
Tested new control modes on actual hardware.
Adjust new code so the modes kind of work now, as proof of concept.
Still needs major optimization and fixes though.
motorctl:
- add config option to disable logging for particular instance
- add some definitions to finetune control modes
- rework current and speed mode, so they actually kind of work
- fix TCS to not cause deadlock motors off
menu:
- add item set motorControlMode (select DUTY, CURRENT, SPEED)
- fix missing item maxDuty
speedsensor: fix return type
very experimental needs testing/debugging,
other control modes can currently be selected by editing the class definition in motorctl.hpp
menu/config
- add menu item to enable/disable traction control system
main: pass ptr to other motor to motor object
speedsensor: add method to get last update time
motorctl: handle loop:
- re-arrange some code sections
- add several methods to get current status (needed from other motor for tcs)
- add sketchy code for different control modes DUTY, CURRENT, SPEED (very basic implementation)
- add experimental code for traction control
display.cpp:
Optimize battery voltage measurement
While calibrating noticed it is very non-linear
- outsource function to scale using lookup table
- add lookup table to batvoltage measurement
inserted many values to lookup table while testing
currentsensors:
Fix current value jumping around between 0 and 0.2 on display
while standstill
- add parameter snapToZeroThreshold
motorctl, currentsensor:
- add config option for inverted current sensor
- adjust loglevels
config:
- Adjust gpio pins to actual wiring (not breakout board for testing)
- Add min pulse durations for speedsensors (measurements with scope)
- Adjust config to currently mounted encoders
control, buzzer:
- adjust beeping
- Add feature for optinal delay to buzzer class:
have some pause after beeps instead of immediately
continuing with next queued sequence
Major changes in motorctl and control to optimize performance
by freeing unnecessary cpu usage by motorctl task
Needs testing on actual hardware!
motorctl:
- slow down handle loop when duty is at target (wait for new command)
- create separate task for each motor
- setTarget method also accepts motorCommand directly now
control.cpp:
- redurce stress on motorctl by removing unnecessary commands
- set motors to idle at mode change only, instead of every iteration (IDLE, MENU, ADJUST)
- HTTP, JOYSTICK: only update motors when stick data actually changed
- simplify code
- add method for idling both motors
- use motorcommands directly in setTarget()
http:cpp:
- dont block control task with getData() method
- handle timeout independent of one queue event
- prevents unresponsive system for http-timeout when changing mode from HTTP
menu:
- optimize set-value page: send static content only once
so only update value -> significant performance boost
- formatting
- reset control timeout to prevent unintended exit and bugged display
- menu item: add option to show a default value (function ptr)
- add default value to adjust fading
- add beeping
motorctl:
- dont write to nvs when value is unchanged
Changes in menu for accel/decel time are now persistent after
restarts
main: initialize nvs and pass pointer to motorctl task
motorctl:
- add method to get default configured value
- add name to config -> adjust logging
- add methods to read and write msFadeAccel and msFadeDecel from nvs
- outsource task_fans and task_buzzer from main.cpp to their source files
- use task parameters to pass necessary configs and objects
- adjust task priorities (display was too low)
Since moving all objects to heap encoder started to lag
interrupt not recognizing some single events in MENU
fast executen of motordriver setTarget caused the lag,
initialize it in STACK while still using a pointer now
- All files:
Modify almost all files to adjust functions and classes to
work with pointers to objects passed at task creation
instead of global variables from config.hpp
- Remove/clear config.hpp to get rid of all global variables
- main.cpp
- Create pointer to all shared (used in multiple tasks) objects in main
- remove evaluatedSwitch button object,
since joystick library is used to get switch events
- changes HTTP-mode
- always init http-server (do not enable/disable at mode change)
- pass url-handle function to init-htpp function
- add lambda function to pass method of instance for thatMajor Rework all files - Remove global variables, pass pointers to tasks
- All files:
Modify almost all files to adjust functions and classes to
work with pointers to objects passed at task creation
instead of global variables from config.hpp
- Remove/clear config.hpp to get rid of all global variables
- main.cpp
- Create pointer to all shared (used in multiple tasks) objects in main
- remove evaluatedSwitch button object,
since joystick library is used to get switch events
- changes HTTP-mode
- always init http-server (do not enable/disable at mode change)
- pass url-handle function to init-htpp function
- add lambda function to pass method of instance for that
NOTES: - tested on breakoutboard only
- known issue that slow encoder events are not recognized
(especially in menu) - slowing down motorctl helps
- make motorctl compatible with different drivers
- pass set function instead of specific motor object
- add lambda function in config.cpp
- update config to use one new sabertooth driver instead of two single100a
- main test controlled motor
since board_single uses mostly the same code as board_control and
board_motorctl several files are outsorced to common folder to prevent
dupliate code and different versions