FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
CoverageControl/python/tests/deprecated/testplot.py at main · KumarRobotics/CoverageControl · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
KumarRobotics
/
CoverageControl
Public
Notifications
You must be signed in to change notification settings
Fork
6
Star
27
Code
Issues
1
Pull requests
1
Discussions
Actions
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
CoverageControl
/
python
/
tests
/
deprecated
/
testplot.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
82 lines (73 loc) · 2.77 KB
Breadcrumbs
CoverageControl
/
python
/
tests
/
deprecated
/
testplot.py
Copy path
File metadata and controls
82 lines (73 loc) · 2.77 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import
numpy
as
np
import
math
import
pyCoverageControl
# Main library
from
pyCoverageControl
import
Point2
# for defining points
from
pyCoverageControl
import
PointVector
# for defining list of points
# We can visualize the map in python
import
matplotlib
.
pylab
as
plt
import
seaborn
as
sns
colormap
=
sns
.
color_palette
(
"light:b"
,
as_cmap
=
True
)
def
plot_map
(
map
):
ax
=
sns
.
heatmap
(
map
.
transpose
(),
vmax
=
1
,
cmap
=
colormap
,
square
=
True
)
ax
.
invert_yaxis
()
nrow
,
ncol
=
map
.
shape
if
(
nrow
>
50
and
nrow
<
500
):
septicks
=
5
**
(
math
.
floor
(
math
.
log
(
nrow
,
5
))
-
1
)
else
:
septicks
=
10
**
(
math
.
floor
(
math
.
log
(
nrow
,
10
))
-
1
)
plt
.
xticks
(
np
.
arange
(
0
,
nrow
,
septicks
),
np
.
arange
(
0
,
nrow
,
septicks
))
plt
.
yticks
(
np
.
arange
(
0
,
ncol
,
septicks
),
np
.
arange
(
0
,
ncol
,
septicks
))
plt
.
show
()
################
## Parameters ##
################
# The parameters can be changed from python without needing to recompile.
# The parameters are given in config/parameters.yaml
# After changing the parameters, use the following function call to use the yaml file.
# Make sure the path of the file is correct
params_
=
pyCoverageControl
.
Parameters
(
'params/parameters.yaml'
)
############
## Point2 ##
############
# Point2 has two atrributes x and y
pt
=
Point2
(
0
,
0
)
# Needs two arguments for x and y
print
(
pt
)
pt
[
0
]
=
5
pt
[
1
]
=
10
print
(
pt
[
0
])
point_list
=
PointVector
()
point_list
.
append
(
pt
)
pt1
=
Point2
(
512
,
512
)
point_list
.
append
(
pt1
)
#################################
## BivariateNormalDistribution ##
#################################
from
pyCoverageControl
import
BivariateNormalDistribution
as
BND
# for defining bivariate normal distributions
dist1
=
BND
()
# zero-mean, sigma = 1, circular
mean
=
Point2
(
512
,
512
)
sigma
=
20
peak_val
=
200
dist2
=
BND
(
mean
,
sigma
,
peak_val
)
# circular gaussian
mean3
=
Point2
(
900
,
100
)
sigma_skewed
=
Point2
(
2
,
3
)
rho
=
0.5
dist3
=
BND
(
mean3
,
sigma_skewed
,
rho
,
peak_val
)
# general BND
##############
## WorldIDF ##
##############
from
pyCoverageControl
import
WorldIDF
# for defining world idf
world_idf
=
WorldIDF
(
params_
)
world_idf
.
AddNormalDistribution
(
dist1
);
# Add a distribution to the idf
world_idf
.
AddNormalDistribution
(
dist2
);
# Add a distribution to the idf
# world_idf.AddNormalDistribution(dist3); # Add a distribution to the idf
print
(
"Calling CUDA"
)
world_idf
.
GenerateMapCuda
()
# Generate map, use GenerateMap() for cpu version
world_idf
.
PrintMapSize
()
# world_idf.WriteWorldMap("map.dat"); # Writes the matrix to the file. Map should have been generated before writing
map
=
world_idf
.
GetWorldMap
();
# Get the world map as numpy nd-array. You can only "view", i.e., flags.writeable = False, flags.owndata = False
normalization_factor
=
world_idf
.
GetNormalizationFactor
();
print
(
map
.
dtype
)
print
(
map
.
flags
)
print
(
type
(
map
))
print
(
map
[
0
,
0
])
plot_map
(
map
)
Back
|
FazBrowse Home
|
New Git URL