| Can anyone give some examples how a "proper" robot control application looks like? I once was working on an DIY delta robot and the software layout is something I never understood how to do right, I fear. I had no idea how to go about it, and if I remember correctly, I wrote the firmware to do the following every 10ms: (I was bare-metal C/C++ on a Cortex-m3.) * Calculate new desired position of effector. * Calculate new desired angle of every stepper motor. * For every stepper motor, calculate deviation between current and desired angle. * Program the timers to generate a PWM signal to make deviation zero. (Note: This whole thing was open loop, so I fed the PWM signal back into a counter to track the motor angles.) Each of these bullet points was implemented as individual function, taking input parameters as function parameters and returning the result as return value. For reference, this is how it looked like: https://youtu.be/9NzlfX5X_W8?t=23 At one point, I was wondering if I shouldn't just call the last function for the final value, and have it call the previous functions (and thereby calculate the input values) on demand. This would look a bit more functional-like, but I didn't see any benefits besides stylistic ones. Is functional programming a thing in embedded robot control software? While building that demonstrator I realized that my attempt at doing so was a very shabby one. It's not enough to have in mind the acceleration/deceleration of the effector for smooth looks. If you would do things right, you would have to watch the torque and motion parameters of each individual joint. You would probably have to calculate the whole motion profile in advance. But I have no idea how I would go about doing that. Do you simply run a loop and iterate over time? What if you realize you violate some constraints at some point? Adjust some initial values by some fixed offset and run anew? I suppose there are smarter attempts. edit: Not a HN heavy user, wow do I make lists right? |