diff --git a/config/radar4.yml b/config/radar4.yml index 9255be7..07d8d96 100644 --- a/config/radar4.yml +++ b/config/radar4.yml @@ -15,8 +15,8 @@ process: ambiguity: delayMin: -10 delayMax: 300 - dopplerMin: -300 - dopplerMax: 300 + dopplerMin: -250 + dopplerMax: 250 clutter: delayMin: -10 delayMax: 300 diff --git a/src/blah2.cpp b/src/blah2.cpp index 28d90a8..16d31d0 100644 --- a/src/blah2.cpp +++ b/src/blah2.cpp @@ -206,6 +206,7 @@ int main(int argc, char **argv) // output map data map->set_metrics(); mapJson = map->to_json(); + mapJson = map->delay_bin_to_km(mapJson, fs); if (saveMap) { map->save(mapJson, saveMapPath); diff --git a/src/data/Map.cpp b/src/data/Map.cpp index 46cf8ca..d0d99af 100644 --- a/src/data/Map.cpp +++ b/src/data/Map.cpp @@ -121,7 +121,7 @@ std::string Map::to_json() rapidjson::Value arrayDelay(rapidjson::kArrayType); for (int i = 0; i < delay.size(); i++) { - arrayDelay.PushBack(delay_km[i], allocator); + arrayDelay.PushBack(delay[i], allocator); } // store Doppler array @@ -141,7 +141,6 @@ std::string Map::to_json() document.AddMember("maxPower", maxPower, allocator); document.AddMember("delay", arrayDelay, allocator); document.AddMember("doppler", arrayDoppler, allocator); - document.AddMember("timestamp", timestamp, allocator); document.AddMember(rapidjson::Value("data", document.GetAllocator()).Move(), array, document.GetAllocator()); rapidjson::StringBuffer strbuf; @@ -152,6 +151,28 @@ std::string Map::to_json() return strbuf.GetString(); } +template +std::string Map::delay_bin_to_km(std::string json, uint32_t fs) +{ + rapidjson::Document document; + document.SetObject(); + rapidjson::Document::AllocatorType &allocator = document.GetAllocator(); + document.Parse(json.c_str()); + + document["delay"].Clear(); + for (int i = 0; i < delay.size(); i++) + { + document["delay"].PushBack(1.0*delay[i]*(299792458/(double)fs)/1000, allocator); + } + + rapidjson::StringBuffer strbuf; + rapidjson::Writer writer(strbuf); + writer.SetMaxDecimalPlaces(2); + document.Accept(writer); + + return strbuf.GetString(); +} + template void Map::set_metrics() { diff --git a/src/data/Map.h b/src/data/Map.h index 2a94e72..3ffe002 100644 --- a/src/data/Map.h +++ b/src/data/Map.h @@ -32,9 +32,6 @@ public: /// @brief Delay units of map data (bins). std::deque delay; - - /// @brief Delay units of map data (km). - std::deque delay_km; /// @brief Doppler units of map data (Hz). std::deque doppler; @@ -97,6 +94,12 @@ public: /// @return JSON string. std::string to_json(); + /// @brief Update JSON to convert delay bins to km. + /// @param json Input JSON string with delay field. + /// @param fs Sampling frequency (Hz). + /// @return JSON string. + std::string delay_bin_to_km(std::string json, uint32_t fs); + /// @brief Append the map to a save file. /// @param json JSON string of map and metadata. /// @param path Path of file to save. diff --git a/src/process/ambiguity/Ambiguity.cpp b/src/process/ambiguity/Ambiguity.cpp index b6cef4b..ed05230 100644 --- a/src/process/ambiguity/Ambiguity.cpp +++ b/src/process/ambiguity/Ambiguity.cpp @@ -79,7 +79,6 @@ Ambiguity::Ambiguity(int32_t _delayMin, int32_t _delayMax, int32_t _dopplerMin, for (int i = 0; i < nDelayBins; i++) { map->delay.push_back(delay[i]); - map->delay_km.push_back(((double)delay[i] * (299792458/(double)fs)) / 1000); } for (int i = 0; i < nDopplerBins; i++) {