Yiru-Jiao / Reconstruct100CarNDSData

This repository reconstructs bird's eye view trajectories of vehicles involved in crashes and near-crashes from 100-Car Naturalistic Driving Study (NDS) radar data.
MIT License
7 stars 3 forks source link

Tag named 'speed_ekf' or 'v_efk'? #1

Closed MuteJack closed 5 months ago

MuteJack commented 5 months ago

Dear Yiru-Jiao.

Thank you for providing a good script. However, I had some problem using this code.

In 'event_matching.py' 57~58th line.

veh_j = df_sur[df_sur['target_id']==target_id][['time','x_ekf','y_ekf','psi_ekf','speed_ekf','target_id','range','forward']].copy() veh_j = veh_j.rename(columns={'x_ekf':'x','y_ekf':'y','psi_ekf':'psi','speed_ekf':'speed'})

Those lines are using a tag named 'speed_efk' and that cause the error like:

============================================================================== PS C:\Users\coldm\OneDrive\바탕 화면\100CarNDS 재현\Reconstruct100CarNDSData-main (2)\Reconstruct100CarNDSData-main> & C:/Users/coldm/AppData/Local/Microsoft/WindowsApps/python3.12.exe "c:/Users/coldm/OneDrive/바탕 화면/100CarNDS 재현/Reconstruct100CarNDSData-main (2)/Reconstruct100CarNDSData-main/event_matching.py" Processing Crash data... There are 34 trips processed Trip 8313 has no surrounding data available

Trip 8322 has 1 surrounding vehicles

Traceback (most recent call last): File "c:\Users\coldm\OneDrive\바탕 화면\100CarNDS 재현\Reconstruct100CarNDSData-main (2)\Reconstruct100CarNDSData-main\event_matching.py", line 57, in veh_j = df_sur[df_sur['target_id']==target_id][['time','x_ekf','y_ekf','psi_ekf','speed_ekf','target_id','range','forward']].copy()



  File "C:\Users\coldm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pandas\core\frame.py", line 4108, in __getitem__
    indexer = self.columns._get_indexer_strict(key, "columns")[1]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\coldm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pandas\core\indexes\base.py", line 6200, in _get_indexer_strict
    self._raise_if_missing(keyarr, indexer, axis_name)
  File "C:\Users\coldm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pandas\core\indexes\base.py", line 6252, in _raise_if_missing
    raise KeyError(f"{not_found} not in index")
KeyError: "['speed_ekf'] not in index"

================================================================================

And I think we have to use 'v_efk' insted speed_ekf'.
So I changed it and it seems works very well.

Did I misunderstand something while reading the document? 
Or was it just a mistake that occurred while writing the script?
Yiru-Jiao commented 5 months ago

Dear MuteJack,

Thanks for your comments! You are correct and I have updated the code. The data df_sur is a slice of data_sur, which is processed in processing_100Car.py by the function process_surrounding stored in data_utils.py. In the function, the filtered speed is named v_ekf rather than speed_ekf. This mistake was because I adjusted the naming of the filtered surrounding vehicle speed but forgot to change it in event matching. Thank you again for pointing this out and helping the code be more useful.

Good luck with your research! Yiru