I feel like I spent the most time planning out what to do and how to implement it, than actually writing code. That's probably the case usually, but for this Check-in, it seemed to be more accurate than other times. The features/tasks that took up most of my time, however, were trying to integrate an OBJ Loader and implementing UCS.
In order to be able to load in cylinders as well as other more complex 3D models, I wanted in integrate an OBJ Loader into my program. Googling it, one of the first results was the Tiny OBJ Loader, so I thought I would give it a try. There was little to no commenting or helpful documentation on the GitHub repo, and also when I tried to look outside of the repo for hints into how to use the single, massive .cpp file that housed everything. I eventually got it loading a model file in, but the next mystery was how to render it using the data structures that the Loader had just created and filled up. This part was even more difficult than figuring out how to load in the file and I ended up only being able to render part of a cylinder after toying with it for 3 days over Spring Break. After this time, I gave up and decided to just display spheres as my obstacles instead.
The next big road bump was understanding the concepts behind UCS as well as understanding how to implement the search using my configuration of data structures. This took most of a day to read through sites and examples of implementations before I had something that looked reasonable. However, after running it a few times, it seemed as though half the time it found a path and half the time it didn't and the priority queue became empty before the goal was reached. After a lot of staring and mulling things over, I concluded that I must have an error in my PRM::UCS()
and in my CSpace::isValidSegment()
functions.
After some time, I realized that I must've been marking my Nodes as visited prematurely. After some thought, I realized that I needed to mark Node_i after the path leading from Start -> Node_i was popped off of the queue and therefore chosen as the current best path. After simply reordering some lines, it seemed promising.
However, I noticed that my graphs didn't have as many connections as they should have, judging by the placement of the Nodes when my scene was rendered. I was sure that my math was right, but after revisiting the problem a day later, I realized that my projection calculation was incorrect since I never normalized the vector onto which I was projecting. By adding that one line to my CSpace::isValidSegment()
function, my graph appeared to be as full as it should be.