Skip to content
Snippets Groups Projects
Commit 16425385 authored by Olivier Bertrand's avatar Olivier Bertrand
Browse files

Correct typo in database loading of old version

parent 2a84c3fa
No related branches found
No related tags found
No related merge requests found
......@@ -513,7 +513,7 @@ class DataBaseLoad(DataBase):
warnings.warn("you are loading a database with old\
conventions, it will be transformed\
automatically into the new one")
posorients = Trajectory(rotconv, indeces=posorient.index)
posorients = Trajectory()
posorients.from_dataframe(posorient, rotconv='rxyz')
return posorients
......
......@@ -11,43 +11,44 @@ from navipy import Brain
# 0) Define a class heriting from Brain
class ASVBrain(Brain):
def __init__(self, renderer=None, channel=0):
Brain.__init__(self,renderer=renderer)
Brain.__init__(self, renderer=renderer)
# Init memory
locid = mydb.posorients[(mydb.posorients.x==0) & (mydb.posorients.y==0)].index[0]
locid = mydb.posorients[(mydb.posorients.x == 0) & (
mydb.posorients.y == 0)].index[0]
posorient = mydb.posorients.loc[locid, :]
self.update(posorient)
self.channel = channel
self.memory = self.asv()
def asv(self):
if self.channel >3:
if self.channel > 3:
return apcv(1/self.vision.scene,
self.vision.viewing_directions)[..., 3,:]
self.vision.viewing_directions)[..., 3, :]
else:
return apcv(self.vision.scene,
self.vision.viewing_directions)[..., self.channel,:]
self.vision.viewing_directions)[..., self.channel, :]
def velocity(self):
homing_vector = self.memory - self.asv()
homing_vector = np.squeeze(homing_vector)
velocity = pd.Series(data=0,
index=['dx', 'dy', 'dz',
'dalpha_0', 'dalpha_1', 'dalpha_2'])
index=['dx', 'dy', 'dz',
'dalpha_0', 'dalpha_1', 'dalpha_2'])
velocity[['dx', 'dy', 'dz']] = homing_vector
return velocity
# 1) Connect to the database
mydb_filename = '/home/bolirev/database.db'
mydb = DataBaseLoad(mydb_filename)
for channel in range(5):
for channel in range(5):
mybrain = ASVBrain(renderer=mydb, channel=channel)
# Create a grid agent
my_agent = GridAgent(mybrain)
# init position
rowid = mydb.posorients[(mydb.posorients.x==-5) & (mydb.posorients.y==-5)].index[0]
rowid = mydb.posorients[(mydb.posorients.x == -5)
& (mydb.posorients.y == -5)].index[0]
initpos = mybrain.posorients.loc[rowid]
my_agent.posorient = initpos
......@@ -64,13 +65,13 @@ for channel in range(5):
f, axarr = plt.subplots(1, 1, figsize=(10, 10))
axarr.plot(trajectory.x, trajectory.y)
gridtoplot = mydb.posorients[(mydb.posorients.x>-1) &
(mydb.posorients.y>-1) &
(mydb.posorients.x<1) &
(mydb.posorients.y<1)]
axarr.plot([0],[0],'ro')
axarr.plot(gridtoplot.x,gridtoplot.y,'.',color='gray')
axarr.set_xlim([-10,10])
axarr.set_ylim([-10,10])
gridtoplot = mydb.posorients[(mydb.posorients.x > -1) &
(mydb.posorients.y > -1) &
(mydb.posorients.x < 1) &
(mydb.posorients.y < 1)]
axarr.plot([0], [0], 'ro')
axarr.plot(gridtoplot.x, gridtoplot.y, '.', color='gray')
axarr.set_xlim([-10, 10])
axarr.set_ylim([-10, 10])
f.show()
f.savefig('plots/asv_homing_grid_channel_{}.svg'.format(channel))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment