Hello,
For hybrid, we're using encoders on our drive train as well as various other sensors to place ourselves on an imaginary (x,y) coordinate grid on the field.
I have created code that allows you to store a list of points. It consists of a structure with two values (x and y) as well as a pointer to point to the next structure of the same type.
Basically, coodrinates are inserted into the heap using dynamic memory allocation (using the malloc funciton). Using the functions I created, these lists are then strung together using pointers. Using pointers, you can insert another block between two blocks in the list (say if we have to navigate around something) or delete blocks.
Look at my code for details. I've commented it as best I can.
I have seen this type of data structure called either Link Listing or Memory Blocks.
All of my code has been taken almost line-for-line by
How to Program C by H.M. Deitel and P.M. Deitel, with a few cosmetic changes.
My problem is that despite including stdio.h and stdlib.h, the compiler claims that the funcion malloc does not exist, giving me the "use of function without prototype" and then an entire slew of errors.
Upon further inspection, I found that the default stdlib.h and stdio.h don't even contain a function prototype for malloc!
I am using MPLAB
Is there something I'm missing? Any help would be
Greatly appreciated. My code is attached to this post.
EDIT: After searching a bit I found
this. Can I use this in the way I want to?