Closed zylos146 closed 2 years ago
Need to check that all patterns work, but otherwise a lot of the PR comments are addressed now. Will continue to do cleanup if I notice anything
Once this PR is merged in, I want to work on building a Pattern Registry, so they can be automatically detected when a library is included. I also want to discuss the concept of Directors as I laid out in the new README.
Make Pattern independent of depth being used as translation. Have translation be handled in StrokeEngine, so we can smoothly translate patterns?
What happens when goToPos
is called while a motion command is executing?
Mutex or lock over Motor Movement. Only one source can take a lock and send motion commands at a time. Prevents erratic behavior due to users using goToPos without disabling StrokeEngine first
Add more protection to goToPos
to reject commands in invalid motor state (Not homed, etc)
Move homing start into Event Handler
Reactive / Observer for Motion? Or continue to use goToPos?
Directors will be very similar to patterns/drivers, where StrokeEngine provides registery, and help attaching/hooking up, but external libraries provide the actual Directors. Some basic Directors might be included
Rail length detection via Sensor-less homing techniques
How do we handle worst-case scenario failures, like a FreeRTOS task returning, causing an ESP abort, and the microcontroller rebooting? Can we intercept that process so we can gracefully emergency stop?
I don't thick a critical failure can be intercepted to execute code. The only chance would be to check on reset reason, and if it was a crash execute some safety function.
In practice more often then not when this happens the code would stick in a death loop. This would defeat this purpose.
So it's not finished yet, but I'm pretty close to allowing JS-based Pattern building via DukTape. You'd be able to add a pattern like the following.
addPattern("Simple Stroke", {
isOutStroke: false
}, function (timestamp, isAtTarget) {
var position = 0
if (isAtTarget) {
this.isOutStroke = !this.isOutStroke
if (this.isOutStroke) {
position = this.stroke
} else {
position = 0
}
}
return {
position,
speed: this.speed,
acceleration: this.acceleration
}
})
May I suggest to separate those two topics? But yes, I already hat eyed with DukTape for this purpose.
Is the motor part of this PR ready for testing? Once it is all in the experimental branch I would write the generic stepper motor driver and put it to tests on my machine.
It's relatively close. The reason I had started with DukTape is because adding the lock/unlockTask was part of a re-write to have the Motion Generation more task-oriented, rather than polling-based.
I can see if I can revert to an earlier checkout in the branch and continue getting the motor part ready for testing.
But yeah, I can understand wanting it separated. I think I got a bit carried away with investigating DukTape, and should focus on getting the basic PR ready first
I've pushed the duktape integration into https://github.com/theelims/StrokeEngine/tree/duktape-integration
I'll move the other un-related changes I had bundled with the Duktape changes back to this PR
WIP currently - Lots of bugs and polishing needed