Skip to content

Commit

Permalink
Merge pull request #29 from joelbeedle/26-bug-queue-specification-in-…
Browse files Browse the repository at this point in the history
…headless-mode-issue-with-user-input

26 bug queue specification in headless mode issue with user input
  • Loading branch information
joelbeedle authored Jul 31, 2024
2 parents 1b8a339 + 4264425 commit 0aca18e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
22 changes: 22 additions & 0 deletions testbed/plot/plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,26 @@ void plot(std::string log_file_path) {
return;
}

void add_rtf_to_csv(std::string log_file_path, int num_drones, int num_targets,
double rtf) {
std::filesystem::path results_dir =
exec_path / ".." / ".." / "testbed" / "results";
std::filesystem::path file_path = results_dir;
std::filesystem::path csv_filename = file_path / "results.csv";

std::cout << log_file_path << std::endl;
std::cout << "Adding RTF to " << csv_filename << std::endl;
{
std::ofstream csvFile(csv_filename, std::ios::app);
if (csvFile.tellp() == 0) { // Check if the file is empty
csvFile << "num_drones,num_targets,rtf\n";
}
}

std::ofstream csvFile;
csvFile.open(csv_filename, std::ios::app);
csvFile << num_drones << "," << num_targets << "," << rtf << "\n";
csvFile.close();
}

} // namespace testbed
3 changes: 3 additions & 0 deletions testbed/plot/plot.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <salsa/core/map.h>

#include <filesystem>
#include <fstream>
#include <string>

namespace testbed {
Expand All @@ -16,6 +17,8 @@ extern bool plot_drone_heatmap;
extern bool plot_drone_distances;

void plot(std::string log_file_path);
void add_rtf_to_csv(std::string log_file_path, int num_drones, int num_targets,
double rtf);
void init_python();
void finalize_python();
} // namespace testbed
Expand Down
5 changes: 5 additions & 0 deletions testbed/testbed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,11 @@ int run_headless(bool verbose) {
std::cout << std::endl;
std::cout << "Finished test " << test.behaviour_name << " ";
std::cout << "(RTF: " << ratio << ")" << std::endl;
if (verbose) {
spdlog::info("Adding test to results csv");
testbed::add_rtf_to_csv(sim->getCurrentLogFile(), test.num_drones,
test.num_targets, ratio);
}
testbed::plot(sim->getCurrentLogFile());
} catch (const std::exception &e) {
spdlog::error("Error: {}", e.what());
Expand Down
25 changes: 20 additions & 5 deletions testbed/user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@ void user() {
50000, 1200.0f, "Tree", "Default"};

// Load the test queue with our tree tests
// 10, 100, 500, 1000
// 100, 1000, 10000
std::vector<int> num_drones = {10, 100, 500, 1000};
std::vector<int> num_targets = {100, 1000, 10000};
int num_trials = 5;

for (int drones : num_drones) {
for (int targets : num_targets) {
for (int i = 0; i < num_trials; i++) {
config.num_drones = drones;
config.num_targets = targets;
salsa::TestQueue::push(config);
}
}
}
salsa::TestQueue::save("performance_table_queue");

salsa::TestQueue::getTests().clear();
auto names = salsa::behaviour::Registry::get().behaviour_names();
for (auto &name : names) {
config.behaviour_name = name;
Expand All @@ -93,9 +111,6 @@ void user() {
config.num_drones = i;
salsa::TestQueue::push(config);
}
}

salsa::TestQueue::save("example_queue");
}
salsa::TestQueue::save("example_queue");

} // namespace testbed
} // namespace testbed

0 comments on commit 0aca18e

Please sign in to comment.