Skip to content

Commit 97748c7

Browse files
author
Saurav Agarwal
committed
linting
1 parent 5634c25 commit 97748c7

File tree

13 files changed

+202
-341
lines changed

13 files changed

+202
-341
lines changed

cppsrc/main/coverage_algorithm.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
/*
2-
* This file is part of the CoverageControl library
3-
*
4-
* Author: Saurav Agarwal
5-
6-
* Repository: https://github.com/KumarRobotics/CoverageControl
7-
*
8-
* Copyright (c) 2024, Saurav Agarwal
9-
*
10-
* The CoverageControl library is free software: you can redistribute it and/or
11-
* modify it under the terms of the GNU General Public License as published by
12-
* the Free Software Foundation, either version 3 of the License, or (at your
13-
* option) any later version.
14-
*
15-
* The CoverageControl library is distributed in the hope that it will be
16-
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
17-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
18-
* Public License for more details.
19-
*
20-
* You should have received a copy of the GNU General Public License along with
21-
* CoverageControl library. If not, see <https://www.gnu.org/licenses/>.
22-
*/
23-
241
/*!
252
* \file coverage_algorithm.cpp
263
* \brief Program to test the CVT-based (Lloyd's) coverage control algorithms

cppsrc/main/world_idf.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
/*
2-
* This file is part of the CoverageControl library
3-
*
4-
* Author: Saurav Agarwal
5-
6-
* Repository: https://github.com/KumarRobotics/CoverageControl
7-
*
8-
* Copyright (c) 2024, Saurav Agarwal
9-
*
10-
* The CoverageControl library is free software: you can redistribute it and/or
11-
* modify it under the terms of the GNU General Public License as published by
12-
* the Free Software Foundation, either version 3 of the License, or (at your
13-
* option) any later version.
14-
*
15-
* The CoverageControl library is distributed in the hope that it will be
16-
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
17-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
18-
* Public License for more details.
19-
*
20-
* You should have received a copy of the GNU General Public License along with
21-
* CoverageControl library. If not, see <https://www.gnu.org/licenses/>.
22-
*/
23-
241
/*!
252
* \file world_idf.cpp
263
* \brief Program to test generation of IDF

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ repair-wheel-command = ""
7575
# before-test=""
7676
test-command = "pytest -ra --showlocals --ignore={project}/python/tests/deprecated {project}/python/tests/test_coverage_env_utils.py {project}/python/tests/test_coverage.py {project}/python/tests/test_env_io.py {project}/python/tests/test_map_generation.py {project}/python/tests/test_models.py {project}/python/tests/test_package.py {project}/python/tests/test_parameters.py {project}/python/tests/test_parity.py"
7777

78-
before-test = "pip install pytest torch torchvision torch_geometric && wget https://github.com/KumarRobotics/CoverageControl/releases/download/v1.1.0/pytest_data.tar.gz && tar -xvf pytest_data.tar.gz -C python/tests/ && rm pytest_data.tar.gz"
78+
before-test = "pip install pytest torch torchvision torch_geometric && wget https://github.com/KumarRobotics/CoverageControl/releases/download/v1.2.0/pytest_data.tar.gz && tar -xvf pytest_data.tar.gz -C python/tests/ && rm pytest_data.tar.gz"
7979
test-requires = []
8080
test-extras = []
8181

python/scripts/coverage_env/coverage_class.py

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,18 @@
1-
# This file is part of the CoverageControl library
2-
#
3-
# Author: Saurav Agarwal
4-
5-
# Repository: https://github.com/KumarRobotics/CoverageControl
6-
#
7-
# Copyright (c) 2024, Saurav Agarwal
8-
#
9-
# The CoverageControl library is free software: you can redistribute it and/or
10-
# modify it under the terms of the GNU General Public License as published by
11-
# the Free Software Foundation, either version 3 of the License, or (at your
12-
# option) any later version.
13-
#
14-
# The CoverageControl library is distributed in the hope that it will be
15-
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17-
# Public License for more details.
18-
#
19-
# You should have received a copy of the GNU General Public License along with
20-
# CoverageControl library. If not, see <https://www.gnu.org/licenses/>.
21-
221
"""
232
An example class to use the CoverageControl library to run a coverage algorithm
243
"""
4+
255
import sys
26-
import coverage_control as cc # Main library
27-
from coverage_control import CoverageSystem
286

7+
import coverage_control as cc # Main library
8+
from coverage_control import CoverageSystem
9+
from coverage_control.algorithms import ClairvoyantCVT as CoverageAlgorithm
2910
# Algorithms available:
3011
# ClairvoyantCVT
3112
# CentralizedCVT
3213
# DecentralizedCVT
3314
# NearOptimalCVT
34-
from coverage_control.algorithms import ClairvoyantCVT as CoverageAlgorithm
15+
3516

3617
class RunCoverageAlgorithm:
3718
"""
@@ -45,15 +26,18 @@ def __init__(self, params_filename=None):
4526
self.params_ = cc.Parameters()
4627

4728
self.env = CoverageSystem(self.params_)
48-
self.controller = CoverageAlgorithm(self.params_, self.params_.pNumRobots, self.env)
29+
self.controller = CoverageAlgorithm(
30+
self.params_, self.params_.pNumRobots, self.env
31+
)
4932

5033
def step(self):
5134
"""
5235
Run one step of the coverage algorithm
5336
"""
54-
self.controller.ComputeActions();
37+
self.controller.ComputeActions()
5538
actions = self.controller.GetActions()
5639
error_flag = self.env.StepActions(actions)
40+
5741
return error_flag
5842

5943
def execute(self):
@@ -68,19 +52,21 @@ def execute(self):
6852
while num_steps <= self.params_.pEpisodeSteps:
6953
if self.step():
7054
print(f"Error in step {num_steps}")
55+
7156
break
7257

7358
if self.controller.IsConverged():
7459
print(f"Converged in step {num_steps}")
60+
7561
break
7662

7763
num_steps = num_steps + 1
7864

7965
final_cost = self.env.GetObjectiveValue()
8066
print(f"Improvement %: {100 * (init_cost - final_cost)/init_cost:.2f}")
8167

82-
if __name__ == '__main__':
8368

69+
if __name__ == "__main__":
8470
if len(sys.argv) > 1:
8571
cc = RunCoverageAlgorithm(sys.argv[1])
8672
else:

python/scripts/coverage_env/coverage_simple.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,14 @@
1-
# This file is part of the CoverageControl library
2-
#
3-
# Author: Saurav Agarwal
4-
5-
# Repository: https://github.com/KumarRobotics/CoverageControl
6-
#
7-
# Copyright (c) 2024, Saurav Agarwal
8-
#
9-
# The CoverageControl library is free software: you can redistribute it and/or
10-
# modify it under the terms of the GNU General Public License as published by
11-
# the Free Software Foundation, either version 3 of the License, or (at your
12-
# option) any later version.
13-
#
14-
# The CoverageControl library is distributed in the hope that it will be
15-
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17-
# Public License for more details.
18-
#
19-
# You should have received a copy of the GNU General Public License along with
20-
# CoverageControl library. If not, see <https://www.gnu.org/licenses/>.
21-
221
"""
232
A simple example of using the CoverageControl library
243
"""
254

265
import coverage_control as cc
27-
6+
from coverage_control.algorithms import ClairvoyantCVT as CoverageAlgorithm
287
# Algorithms available:
298
# ClairvoyantCVT
309
# CentralizedCVT
3110
# DecentralizedCVT
3211
# NearOptimalCVT
33-
from coverage_control.algorithms import ClairvoyantCVT as CoverageAlgorithm
3412

3513
params = cc.Parameters()
3614

@@ -53,10 +31,12 @@
5331

5432
if env.StepActions(actions):
5533
print(f"Error in step {i}")
34+
5635
break
5736

5837
if controller.IsConverged():
5938
print(f"Converged in step {i}")
39+
6040
break
6141

6242
# print some metrics

python/scripts/coverage_env/world_idf.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
1-
# This file is part of the CoverageControl library
2-
#
3-
# Author: Saurav Agarwal
4-
5-
# Repository: https://github.com/KumarRobotics/CoverageControl
6-
#
7-
# Copyright (c) 2024, Saurav Agarwal
8-
#
9-
# The CoverageControl library is free software: you can redistribute it and/or
10-
# modify it under the terms of the GNU General Public License as published by
11-
# the Free Software Foundation, either version 3 of the License, or (at your
12-
# option) any later version.
13-
#
14-
# The CoverageControl library is distributed in the hope that it will be
15-
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17-
# Public License for more details.
18-
#
19-
# You should have received a copy of the GNU General Public License along with
20-
# CoverageControl library. If not, see <https://www.gnu.org/licenses/>.
211
"""
222
A simple example of using WorldIDF
233
"""
244

255
import coverage_control
26-
import numpy as np
276

287
params = coverage_control.Parameters()
298
params.pNumRobots = 1

python/scripts/coverage_env/world_map_numpy.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
# This file is part of the CoverageControl library
2-
#
3-
# Author: Saurav Agarwal
4-
5-
# Repository: https://github.com/KumarRobotics/CoverageControl
6-
#
7-
# Copyright (c) 2024, Saurav Agarwal
8-
#
9-
# The CoverageControl library is free software: you can redistribute it and/or
10-
# modify it under the terms of the GNU General Public License as published by
11-
# the Free Software Foundation, either version 3 of the License, or (at your
12-
# option) any later version.
13-
#
14-
# The CoverageControl library is distributed in the hope that it will be
15-
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17-
# Public License for more details.
18-
#
19-
# You should have received a copy of the GNU General Public License along with
20-
# CoverageControl library. If not, see <https://www.gnu.org/licenses/>.
211
"""
222
A simple example of using WorldIDF
233
"""

python/scripts/data_generation/data_generation.py

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,6 @@
1-
# This file is part of the CoverageControl library
2-
#
3-
# Author: Saurav Agarwal
4-
5-
# Repository: https://github.com/KumarRobotics/CoverageControl
6-
#
7-
# Copyright (c) 2024, Saurav Agarwal
8-
#
9-
# The CoverageControl library is free software: you can redistribute it and/or
10-
# modify it under the terms of the GNU General Public License as published by
11-
# the Free Software Foundation, either version 3 of the License, or (at your
12-
# option) any later version.
13-
#
14-
# The CoverageControl library is distributed in the hope that it will be
15-
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17-
# Public License for more details.
18-
#
19-
# You should have received a copy of the GNU General Public License along with
20-
# CoverageControl library. If not, see <https://www.gnu.org/licenses/>.
21-
221
# @file data_generation.py
232
# This file contains the code to generate a dataset for learning
243
#
25-
264
# DataDir = "${CoverageControl_ws}/datasets/lpac" # Absolute location
275
# EnvironmentConfig = "${CoverageControl_ws}/datasets/lpac/coverage_control_params.toml" # Absolute location
286
#
@@ -48,30 +26,30 @@
4826
# TrainRatio = 0.7
4927
# ValRatio = 0.2
5028
# TestRatio = 0.1
51-
52-
## @file data_generation.py
29+
# @file data_generation.py
5330
# @brief Class to generate CoverageControl dataset for LPAC architecture
54-
55-
import os
56-
import sys
57-
import pathlib
5831
import datetime
5932
import math
33+
import os
34+
import pathlib
35+
import sys
6036

6137
import coverage_control
6238
import torch
63-
from coverage_control import CoverageSystem, IOUtils
39+
from coverage_control import CoverageSystem
40+
from coverage_control import IOUtils
6441
from coverage_control.algorithms import ClairvoyantCVT as CoverageAlgorithm
6542
from coverage_control.nn import CoverageEnvUtils
6643

67-
## @ingroup python_api
44+
# @ingroup python_api
45+
46+
6847
class DatasetGenerator:
6948
"""
7049
Class to generate CoverageControl dataset for LPAC architecture
7150
"""
7251

7352
def __init__(self, config_file, append_dir=None):
74-
7553
self.config = IOUtils.load_toml(config_file)
7654
self.data_dir = IOUtils.sanitize_path(self.config["DataDir"])
7755
self.dataset_dir = self.data_dir + "/data/"

0 commit comments

Comments
 (0)