allow to change map dimension

This commit is contained in:
HappyZ 2019-06-06 10:39:25 -05:00
parent 87c04171e1
commit 5b65228e16
2 changed files with 29 additions and 9 deletions

View File

@ -106,7 +106,8 @@ def convert_to_pickle_rss(
visualize: bool = False,
output_map: bool = False,
filters: int = None,
sampling: bool = False
sampling: bool = False,
map_dim: tuple = None
):
'''
modified from Zhuolin
@ -118,6 +119,10 @@ def convert_to_pickle_rss(
# load data and split into different types
results = load_rss_data_with_pkt_types(fp, orientation)
# define map dimension
if map_dim is None:
map_dim = (PICKLE_MAP_SIZE, PICKLE_MAP_SIZE)
# pick the most frequent type
pkt_types = [(key, len(results[key])) for key in results.keys()]
pkt_types = sorted(pkt_types, key=lambda x: x[1], reverse=True)
@ -135,14 +140,14 @@ def convert_to_pickle_rss(
# convert it to a map
# rss_map_dict = {}
rss_map = np.ones((PICKLE_MAP_SIZE, PICKLE_MAP_SIZE)) * -85.0
rss_map = np.ones(map_dim) * -85.0
factor = 0.75
for i in range(PICKLE_MAP_SIZE):
for i in range(map_dim[0]):
# if i not in rss_map_dict:
# rss_map_dict[i] = {}
# search for x_idx
upper_bound_x = loc_x_center + PICKLE_MAP_STEP * (i - (PICKLE_MAP_SIZE / 2) + 0.5)
upper_bound_x = loc_x_center + PICKLE_MAP_STEP * (i - (map_dim[0] / 2) + 0.5)
lower_bound_x = upper_bound_x - PICKLE_MAP_STEP
data_x_idxs = find_index(
data[0, :],
@ -153,9 +158,9 @@ def convert_to_pickle_rss(
if data_part.size is 0:
continue
data_y_idx = 0
for j in range(PICKLE_MAP_SIZE):
for j in range(map_dim[1]):
# search for y_idx
upper_bound_y = loc_y_center + PICKLE_MAP_STEP * (j - (PICKLE_MAP_SIZE / 2) + 0.5)
upper_bound_y = loc_y_center + PICKLE_MAP_STEP * (j - (map_dim[1] / 2) + 0.5)
lower_bound_y = upper_bound_y - PICKLE_MAP_STEP
data_y_idxs = find_index(
data_part[1, :],

View File

@ -78,7 +78,8 @@ def convert_to_pickle(
is_csi=False,
output_map=False,
sampling=False,
sampling_num=5
sampling_num=5,
map_dim=None
):
'''
'''
@ -99,7 +100,8 @@ def convert_to_pickle(
visualize=visualize,
output_map=output_map,
filters=fff,
sampling=sampling
sampling=sampling,
map_dim=map_dim
)
else:
convert_to_pickle_rss(
@ -108,7 +110,8 @@ def convert_to_pickle(
visualize=visualize,
output_map=output_map,
filters=filters,
sampling=sampling
sampling=sampling,
map_dim=map_dim
)
except KeyboardInterrupt:
print("KeyboardInterrupt happened")
@ -217,6 +220,18 @@ if __name__ == '__main__':
default=0,
help='Specify orientation of the map'
)
parser.add_argument(
'--dimension',
dest='dimension',
default=None,
help='Specify dimension/size of the map via `--dimension="width height"`, default 64x64'
)
args, __ = parser.parse_known_args()
try:
args.dimension = [int(x) for x in args.dimension.split(" ")]
except BaseException:
print("err parsing dimension..")
exit(2)
main(args)