V2Xgithub / WiLabV2Xsim

V2X simulator
GNU General Public License v3.0
79 stars 32 forks source link

add support for counting hidden node events, and add unit tests #27

Closed chestnutcase closed 12 months ago

chestnutcase commented 1 year ago

hi v2xsim maintainers,

i have more features in my fork that i created for my own research, that i would like to contribute back to upstream before i start working on the full traffic trace support.

this feature creates a new output parameter, printHiddenNodeEvents, that counts the number of errors that happened due to the hidden node problem. This is not the same as the existing countHiddenNodeProb that is no longer tested, this only looks at errors and the awareness matrix to decide. It should also be faster because I used vectorization as much as possible, the old code used lots of nested for loops.

Also, I would like to start writing automated test suites for the simulator to it is easier for future maintainers to do regression tests. In this commit I show an example of how unit tests for the simulator can be written. I am using MATLAB's built in test framework, see tutorial here. I also use the package/namespace feature to avoid polluting the global namespace since we are going to have many many function names.

For reference, the tests in this branch can be run after adding the Tests folder to MATLAB path and running in the command window:

run(v2xsim_tests.unit.out.test_countHiddenNodeEvents)
chestnutcase commented 1 year ago

Also just to share, here are tracefiles I generated that will intentionally cause alot of hidden terminal problems - three highways separated by a distance roughly the transmission range.

They currently work with the partial tracefile support i have implemented that was merged back into upstream.

htp_highway_150m.txt htp_highway_200m.txt htp_highway_50m.txt

htp_highway_100m.txt

chestnutcase commented 12 months ago

closing pull request, will merge with the main PR for project overhaul