|
| 1 | +#include <torch/script.h> |
| 2 | +#include <torch/torch.h> |
| 3 | +#include <torchvision/vision.h> |
| 4 | +#include <iostream> |
| 5 | + |
| 6 | +#include <iomanip> |
| 7 | +#include <iostream> |
| 8 | +#include <random> |
| 9 | +#include <filesystem> |
| 10 | + |
| 11 | +#include <CoverageControlTorch/coverage_system.h> |
| 12 | +#include <CoverageControlTorch/generate_dataset.h> |
| 13 | + |
| 14 | +using CoverageControl::Point2; |
| 15 | +using CoverageControl::BivariateNormalDistribution; |
| 16 | +using CoverageControl::WorldIDF; |
| 17 | +using namespace torch::indexing; |
| 18 | + |
| 19 | +namespace CC = CoverageControl; |
| 20 | +namespace CCT = CoverageControlTorch; |
| 21 | + |
| 22 | +int main(int argc, char** argv) { |
| 23 | + /* if (argc != 2) { */ |
| 24 | + /* std::cout << "Usage: ./data_generation <path_to_resizer_model>" << std::endl; */ |
| 25 | + /* std::cout << "TorchVision JIT Transformer is required\n"; */ |
| 26 | + /* return 1; */ |
| 27 | + /* } */ |
| 28 | + |
| 29 | + /* // Read first argument as path to resizer model */ |
| 30 | + /* std::string resizer_model_path = argv[1]; */ |
| 31 | + /* if (!std::filesystem::exists(resizer_model_path)) { */ |
| 32 | + /* std::cout << "Error: " << resizer_model_path << " does not exist\n"; */ |
| 33 | + /* return 1; */ |
| 34 | + /* } */ |
| 35 | + |
| 36 | + /* Parameters params; */ |
| 37 | + |
| 38 | + /* std::vector <Point2> robot_positions; */ |
| 39 | + /* robot_positions.push_back(Point2(100, 100)); */ |
| 40 | + /* robot_positions.push_back(Point2(100, 10)); */ |
| 41 | + /* robot_positions.push_back(Point2(10, 70)); */ |
| 42 | + |
| 43 | + /* WorldIDF world_idf(params); */ |
| 44 | + /* params.pNumRobots = robot_positions.size(); */ |
| 45 | + /* world_idf.AddNormalDistribution(BivariateNormalDistribution(Point2(95, 95), 10)); */ |
| 46 | + |
| 47 | + /* CCT::CoverageSystem env (params, world_idf, robot_positions); */ |
| 48 | + /* torch::Tensor local_maps = torch::empty({2, params.pNumRobots, params.pLocalMapSize, params.pLocalMapSize}); */ |
| 49 | + /* std::cout << std::setprecision(10) << std::endl; */ |
| 50 | + /* env.GetAllRobotsLocalMaps(local_maps[0]); */ |
| 51 | + /* env.GetAllRobotsLocalMaps(local_maps[1]); */ |
| 52 | + /* print(local_maps[0].sum()); */ |
| 53 | + /* std::cout << local_maps.sum() << std::endl; */ |
| 54 | + /* std::cout << "shape: " << local_maps.sizes(); */ |
| 55 | + /* torch::save(local_maps[0], "test.pt"); */ |
| 56 | + |
| 57 | + /* torch::jit::script::Module resizer_model; */ |
| 58 | + /* resizer_model = torch::jit::load(resizer_model_path); */ |
| 59 | + |
| 60 | + /* std::cout << "shape of local_maps: " << local_maps[0][0].sizes() << std::endl; */ |
| 61 | + |
| 62 | + /* std::vector<torch::jit::IValue> inputs; */ |
| 63 | + /* inputs.push_back(local_maps); */ |
| 64 | + /* torch::Tensor resized_maps = resizer_model.forward(inputs).toTensor(); */ |
| 65 | + /* std::cout << "resized_maps: " << resized_maps.sizes() << std::endl; */ |
| 66 | + |
| 67 | + /* torch::Tensor comm_maps = torch::zeros({params.pNumRobots, 32, 32}); */ |
| 68 | + /* env.GetAllRobotsCommunicationMaps(comm_maps, 32); */ |
| 69 | + /* std::cout << "shape of comm_maps: " << comm_maps.sizes() << std::endl; */ |
| 70 | + |
| 71 | + /* auto sparse_comm_maps = comm_maps.to_sparse(); */ |
| 72 | + /* std::cout << sparse_comm_maps << std::endl; */ |
| 73 | + |
| 74 | + /* std::cout << torch::nonzero(comm_maps) - 16 << std::endl; */ |
| 75 | + |
| 76 | + /* torch::Tensor test_tensor = torch::zeros({5}); */ |
| 77 | + /* test_tensor[0] = 1; */ |
| 78 | + /* test_tensor[1] = 2; */ |
| 79 | + /* test_tensor[2] = 3; */ |
| 80 | + /* std::cout << test_tensor << std::endl; */ |
| 81 | + /* auto test_tensor2 = test_tensor.index({Slice(0, 3)}); */ |
| 82 | + /* std::cout << test_tensor2 << std::endl; */ |
| 83 | + /* test_tensor2[0] = 10; */ |
| 84 | + /* std::cout << test_tensor << std::endl; */ |
| 85 | + |
| 86 | + |
| 87 | + CCT::GenerateDataset dataset_generator("/root/CoverageControl_ws/data/pure_coverage/data_params.yaml");; |
| 88 | + |
| 89 | + |
| 90 | + return 0; |
| 91 | + |
| 92 | +} |
0 commit comments