I am currently working on a rover that runs on an Arduino Uno, and I am having some trouble with creating a coordinate matrix for navigation. Essentially, the coordinate matrix's job is to be updated every rotation of the wheel, and just store variables representing the home base that it has to return to (0,0) and coordinates where the rover detected certain obstacles. How would I go about making this matrix?
So you have a fixed ground base referential (X,Y) and your vehicle is moving within this 2D space and you want to calculate and maintain the position of objects (obstacles or home base) in the vehicle referential?
A 2 dimensional array would be the obvious choice but memory is limited. What magnitude are the coordinates to be stored and how many of them are there on each axis ?
I think OP wants to maintain objects positions in the coordinate system relative to the vehicle.
you could have dx and dy at 0 because you just rotated in place so the route back home or the location of the obstacles have rotated and you need a 2D rotation matrix applied to all objects coordinates to bring them back to the vehicle's coordinate system
it's probably easier to think in terms of fixed coordinate system so that obstacles have an absolute, non changing position and maintain the position and rotation of the vehicle (a vector) in this global coordinate system.
why not a list of coordinates for the rover itself and any obstacles.
atan() can be used to determine the angle between the rover and any desired target position (e.g an obstacle, origin) using the dx/dy between the two points.
I linked to the std::list because I figured the next question would be "what's a list?" and that page has a good explanation. If I just linked to a CS definition of a list, it would most likely be ignored. This way there's a snowball's chance that OP would learn something.
if OP wanted key points to be always relative to the vehicle's coordinate system then you need to account for vehicle's rotation (vehicle can be at the same global location but heading in different ways)
in this example, for the first picture the rock would be negative Y in the car's coordinate system but if you rotate the car the rock would be in the positive Y. Yet the car is still at the same (X,Y) point in the global fixed referential.