Hello,
I’m trying to build a Dragster robot, with a line follower, to be the fastest possible, with freeRTOS, ESP32 and VSCode.
I have already made one (simple) test program…
Criteria:
The robot must follow a black straight line;
Must stop when detects the finishing line;
Initially I have tried to do this with 3 tasks:
motors control with only P;
line follower;
stop the motors
However this method endend up to be a pain in the… and somehow complicated.
(For) Now, I changed to one task only
Questions: Is this the best way to do it - One task to rule them all?
You should be much more precise in your description if you want meaningful answers. First of all, what exactly were the problems you encountered in the three task implementation? Just trying to pinpoint that normally provides you with a number of insights into where you design flaws might be.
In general, what you need to analyze is concurrency - where it really occurrs in your envisioned system and how to implement it. Frequently people design a multitasked system just because that looks good to them, but if you look closer, a subset of the tasks in practice act as co routines, passing the baton back on forth, really implementing a single threaded computation, needlessly distributed over multiple tasks.
So again, make a model of your system that shows how your components and modules interact and where you can benefit from breaking your computations into concurrent strands of execution. At that stage you will also need to identify deadlines and latency requirements so you can think about priorities of your tasks and isrs. Then define the interactions (interprocess communication) and dependencies between your strands of execution. Then build your system up from that model.
Note that you don’t really need sophisticated tools for that important first step. A writing pad and a pen will do fine.