Skip to content

Commit eb1d907

Browse files
author
David Cox
committed
Initial refactoring / cleanup
1 parent 659714c commit eb1d907

17 files changed

+235
-164
lines changed

RatSLAM2/plot_graph.py

-142
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

sketch.py renamed to old/sketch.py

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

RatSLAM2/README renamed to ratslam/README

+6-6
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Classes -
8686
pc_network: Pose Cell Network
8787

8888
Classes -
89-
pc_Network(ndarray shape)
89+
PoseCellNetwork(ndarray shape)
9090
attributes
9191

9292
shape: ndarray initially [PC_DIM_XY, PC_DIM_XY, PC_DIM_TH] == [61, 61, 36] for shape of pose cell network matrix
@@ -112,14 +112,14 @@ Classes -
112112
avg_thwrap: ndarray initially [33, 34, ...35, 0, 1... 60, 0, 1, 2]
113113
max_pc: tuple initially (0, 0, 0)
114114

115-
create_pcWeights(int dim, int var)
115+
create_pc_weights(int dim, int var)
116116

117117
Takes in two integer arguments dim and var, creates 3D matrix with shape [dim, dim, dim], stores weight values depending on
118118
distance from the matrix center, normalizes values in matrix, and returns matrix.
119119

120120
returns ndarray of weighted values
121121

122-
activityMatrix(ndarray xywrap, ndarray thwrap, int wdim, ndarray pcw)
122+
compute_activity_matrix(ndarray xywrap, ndarray thwrap, int wdim, ndarray pcw)
123123

124124
Creates an zero matrix with same shape as pose cell network, and finds indices of nonzero values in pose cell network. Then multiplies
125125
each nonzero value by the Gaussian weight distribution pcw which is added to the zero matrix indices that correspond with the nonzero value pose
@@ -192,7 +192,7 @@ Classes -
192192
d: float initially 0
193193
heading_rad: float initially 0
194194

195-
exp_map(pc_network pc_Network posecellnetwork, localView templateCollection tempCol)
195+
exp_map(pc_network PoseCellNetwork posecellnetwork, localView templateCollection tempCol)
196196
attributes
197197

198198
exps: list initially empty
@@ -260,13 +260,13 @@ Functions -
260260

261261
returns String of image directory
262262

263-
initialize_em(localView templateCollection tempCol, vod2 VisOdom vod, pc_network pc_Network pcnet)
263+
initialize_em(localView templateCollection tempCol, vod2 VisOdom vod, pc_network PoseCellNetwork pcnet)
264264

265265
returns exp_map
266266

267267
initialize_pc(localView templateCollection tempCol, vod2 VisOdom vod)
268268

269-
returns pc_Network
269+
returns PoseCellNetwork
270270

271271
initialize_lv
272272

ratslam/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from experience_map import *
2+
from local_view_cell import *
3+
from pose_cell_network import *
4+
from visual_odometer import *

RatSLAM2/em.py renamed to ratslam/experience_map.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def Get_Signed_Delta_Rad(angle1, angle2):
4040
angle = 0(2*pi-delta_angle)
4141
return angle
4242

43-
class exp:
43+
class Experience:
4444
def __init__(self, **kwargs):
4545
self.x_pc = kwargs.pop('x_pc', 0)
4646
self.y_pc = kwargs.pop('y_pc', 0)
@@ -55,14 +55,14 @@ def __init__(self, **kwargs):
5555

5656
self.facing_rad = kwargs.pop('facing_rad', 0)
5757

58-
class link:
58+
class ExperienceLink:
5959
def __init__(self, **kwargs):
6060
self.exp_id = kwargs.pop('exp_id', 0)
6161
self.facing_rad = kwargs.pop('facing_rad', 0)
6262
self.d = kwargs.pop('d', 0)
6363
self.heading_rad = kwargs.pop('heading_rad', 0)
6464

65-
class exp_map:
65+
class ExperienceMap:
6666
def __init__(self, posecellnetwork, tempcol):
6767
self.exps = []
6868
self.exp_id = kwargs.pop('exp_id', None)

RatSLAM2/localView.py renamed to ratslam/local_view_cell.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
44
@author: Christine
55
'''
6-
from pylab import *
7-
import vod2
6+
#from pylab import *
7+
#import vod2
88

9-
class template: #same thing as local view cell
9+
class VisualTemplate: #same thing as local view cell
1010

1111
def __init__ (self, curr_xsums, **kwargs):
1212

@@ -22,7 +22,7 @@ def __init__ (self, curr_xsums, **kwargs):
2222

2323
self.exps = [] #list of exp_id associated with visual template
2424

25-
class templateCollection:
25+
class VisualTemplateCollection:
2626

2727
def __init__ (self, **kwargs):
2828

RatSLAM2/pc_network.py renamed to ratslam/pose_cell_network.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
44
@author: Christine
55
'''
6-
import localView as lv
6+
import local_view_cell as lv
77
from pylab import *
88

9-
class pc_Network:
9+
class PoseCellNetwork:
1010

1111
def __init__(self, shape, **kwargs):
1212

@@ -24,14 +24,14 @@ def __init__(self, shape, **kwargs):
2424
e_dim_half = self.e_wdim/2
2525
self.e_xywrap = append(append(arange(PC_DIM_XY-e_dim_half, PC_DIM_XY), arange(0, PC_DIM_XY)), arange(0, PC_DIM_XY-e_dim_half))
2626
self.e_thwrap = append(append(arange(PC_DIM_TH-e_dim_half, PC_DIM_TH), arange(0, PC_DIM_TH)), arange(0, PC_DIM_TH-e_dim_half))
27-
self.e_pcw = self.create_pcWeights(self.e_wdim, 1)
27+
self.e_pcw = self.create_pc_weights(self.e_wdim, 1)
2828

2929
#inhibition constants
3030
self.i_wdim = kwargs.pop('i_wdim', 5)
3131
i_dim_half = self.i_wdim/2
3232
self.i_xywrap = append(append(arange(PC_DIM_XY-i_dim_half, PC_DIM_XY), arange(0, PC_DIM_XY)), arange(0, PC_DIM_XY-i_dim_half))
3333
self.i_thwrap = append(append(arange(PC_DIM_TH-i_dim_half, PC_DIM_TH), arange(0, PC_DIM_TH)), arange(0, PC_DIM_TH-i_dim_half))
34-
self.i_pcw = self.create_pcWeights(self.i_wdim, 2)
34+
self.i_pcw = self.create_pc_weights(self.i_wdim, 2)
3535

3636
self.global_inhibition = kwargs.pop('global_pc_inhibition', 0.00002)
3737
self.c_size_th = kwargs.pop('c_size_th', 2*float64(pi)/36)
@@ -50,7 +50,7 @@ def __init__(self, shape, **kwargs):
5050

5151
self.max_pc = [0, 0, 0]
5252

53-
def create_pcWeights(self, dim, var): #dim is dimension and var is variance
53+
def create_pc_weights(self, dim, var): #dim is dimension and var is variance
5454
weight = zeros([dim, dim, dim])
5555
dim_centre = math.floor(dim/2)
5656

@@ -64,7 +64,7 @@ def create_pcWeights(self, dim, var): #dim is dimension and var is variance
6464

6565
return weight
6666

67-
def activityMatrix(self, xywrap, thwrap, wdim, pcw):
67+
def compute_activity_matrix(self, xywrap, thwrap, wdim, pcw):
6868

6969
#returns gaussian distribution of excitation/inhibition pc activity
7070
pca_new = zeros(self.shape)
@@ -113,10 +113,10 @@ def update(self, ododelta, v_temp):
113113
self.posecells[act_x, act_y, act_th] += energy;
114114

115115
#excitation weighted matrix
116-
self.posecells = self.activityMatrix(self.e_xywrap, self.e_thwrap, self.e_wdim, self.e_pcw)
116+
self.posecells = self.compute_activity_matrix(self.e_xywrap, self.e_thwrap, self.e_wdim, self.e_pcw)
117117

118118
#inhibition weighted matrix
119-
self.posecells = self.posecells - self.activityMatrix(self.i_xywrap, self.i_thwrap, self.i_wdim, self.i_pcw)
119+
self.posecells = self.posecells - self.compute_activity_matrix(self.i_xywrap, self.i_thwrap, self.i_wdim, self.i_pcw)
120120

121121
#global inhibition
122122
self.posecells[self.posecells<self.global_inhibition] = 0

RatSLAM2/vod2.py renamed to ratslam/visual_odometer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def rs_compare_segments(seg1, seg2, slen, cwl):
3838

3939
return (offset, sdif)
4040

41-
class VisOdom:
41+
class VisualOdometer:
4242

4343
def __init__(self, **kwargs):
4444

0 commit comments

Comments
 (0)