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

rename angles in moving module to match database

parent 99126702
No related branches found
No related tags found
No related merge requests found
...@@ -71,8 +71,8 @@ class AbstractAgent(): ...@@ -71,8 +71,8 @@ class AbstractAgent():
if isinstance(posorients_vel, pd.Series) is False: if isinstance(posorients_vel, pd.Series) is False:
raise TypeError('posorients_vel should be a pandas Series') raise TypeError('posorients_vel should be a pandas Series')
for col in ['x', 'y', 'z', 'yaw', 'pitch', 'roll', for col in ['x', 'y', 'z', 'alpha_0', 'alpha_1', 'alpha_2',
'dx', 'dy', 'dz', 'dyaw', 'dpitch', 'droll']: 'dx', 'dy', 'dz', 'dalpha_0', 'dalpha_1', 'dalpha_2']:
if col not in posorients_vel.index: if col not in posorients_vel.index:
raise KeyError( raise KeyError(
'posorients_vel should have {} as index'.format(col)) 'posorients_vel should have {} as index'.format(col))
...@@ -85,13 +85,13 @@ class AbstractAgent(): ...@@ -85,13 +85,13 @@ class AbstractAgent():
# Compute the closest possible position # Compute the closest possible position
if posorients_vel is None: if posorients_vel is None:
posorients_vel[['x', 'y', 'z', posorients_vel[['x', 'y', 'z',
'yaw', 'pitch', 'roll']] = \ 'alpha_0', 'alpha_1', 'alpha_2']] = \
navimomath.closest_pos_memory_friendly( navimomath.closest_pos_memory_friendly(
posorients_vel, posorients_vel,
self.db) self.db)
else: else:
posorients_vel[['x', 'y', 'z', posorients_vel[['x', 'y', 'z',
'yaw', 'pitch', 'roll']] = \ 'alpha_0', 'alpha_1', 'alpha_2']] = \
navimomath.closest_pos( navimomath.closest_pos(
posorients_vel, posorients_vel,
self.__posorients) self.__posorients)
...@@ -108,9 +108,9 @@ class Single(AbstractAgent): ...@@ -108,9 +108,9 @@ class Single(AbstractAgent):
self.__posorientvel = pd.Series( self.__posorientvel = pd.Series(
index=['x', 'y', 'z', index=['x', 'y', 'z',
'yaw', 'pitch', 'roll', 'alpha_0', 'alpha_1', 'alpha_2',
'dx', 'dy', 'dz', 'dx', 'dy', 'dz',
'dyaw', 'dpitch', 'droll'], 'dalpha_0', 'dalpha_1', 'dalpha_2'],
dtype=np.float) dtype=np.float)
if isinstance(initial_condition, pd.Series): if isinstance(initial_condition, pd.Series):
...@@ -151,11 +151,11 @@ class Single(AbstractAgent): ...@@ -151,11 +151,11 @@ class Single(AbstractAgent):
@property @property
def orientation(self): def orientation(self):
return self.__posorientvel.loc[['yaw', 'pitch', 'roll']] return self.__posorientvel.loc[['alpha_0', 'alpha_1', 'alpha_2']]
@property @property
def angular_velocity(self): def angular_velocity(self):
return self.__posorientvel.loc[['dyaw', 'dpitch', 'droll']] return self.__posorientvel.loc[['dalpha_0', 'dalpha_1', 'dalpha_2']]
@angular_velocity.setter @angular_velocity.setter
def angular_velocity(self, angvel): def angular_velocity(self, angvel):
...@@ -163,9 +163,9 @@ class Single(AbstractAgent): ...@@ -163,9 +163,9 @@ class Single(AbstractAgent):
if is_numeric_dtype(angvel): if is_numeric_dtype(angvel):
# Use explicitly vel.dx, ... # Use explicitly vel.dx, ...
# to make sure that the Series contain those # to make sure that the Series contain those
self.__posorientvel.dyaw = angvel.dyaw self.__posorientvel.dalpha_0 = angvel.dalpha_0
self.__posorientvel.dpitch = angvel.dpitch self.__posorientvel.dalpha_1 = angvel.dalpha_1
self.__posorientvel.droll = angvel.droll self.__posorientvel.dalpha_2 = angvel.dalpha_2
else: else:
raise TypeError('vel should be numeric') raise TypeError('vel should be numeric')
else: else:
......
...@@ -40,8 +40,8 @@ class TestNavipyMovingAgent(unittest.TestCase): ...@@ -40,8 +40,8 @@ class TestNavipyMovingAgent(unittest.TestCase):
agent.abstractmove('NotPandasSeries') agent.abstractmove('NotPandasSeries')
posorient_vel = pd.Series() posorient_vel = pd.Series()
for col in ['x', 'y', 'z', 'yaw', 'pitch', 'roll', for col in ['x', 'y', 'z', 'alpha_0', 'alpha_1', 'alpha_2',
'dx', 'dy', 'dz', 'dyaw', 'dpitch', 'droll']: 'dx', 'dy', 'dz', 'dalpha_0', 'dalpha_1', 'dalpha_2']:
with self.assertRaises(KeyError): with self.assertRaises(KeyError):
agent.abstractmove(posorient_vel) agent.abstractmove(posorient_vel)
posorient_vel[col] = 2 posorient_vel[col] = 2
...@@ -52,9 +52,9 @@ class TestNavipyMovingAgent(unittest.TestCase): ...@@ -52,9 +52,9 @@ class TestNavipyMovingAgent(unittest.TestCase):
posorient_vel = pd.Series(data=0, posorient_vel = pd.Series(data=0,
index=['x', 'y', 'z', index=['x', 'y', 'z',
'yaw', 'pitch', 'roll', 'alpha_0', 'alpha_1', 'alpha_2',
'dx', 'dy', 'dz', 'dx', 'dy', 'dz',
'dyaw', 'dpitch', 'droll']) 'dalpha_0', 'dalpha_1', 'dalpha_2'])
pos = self.mydb.read_posorient(rowid=1) pos = self.mydb.read_posorient(rowid=1)
posorient_vel.loc[['x', 'y', 'z']] = pos.loc[['x', 'y', 'z']] posorient_vel.loc[['x', 'y', 'z']] = pos.loc[['x', 'y', 'z']]
...@@ -81,9 +81,9 @@ class TestNavipyMovingAgent(unittest.TestCase): ...@@ -81,9 +81,9 @@ class TestNavipyMovingAgent(unittest.TestCase):
def test_velocity_setter(self): def test_velocity_setter(self):
posorient_vel = pd.Series(data=np.random.rand(12), posorient_vel = pd.Series(data=np.random.rand(12),
index=['x', 'y', 'z', index=['x', 'y', 'z',
'yaw', 'pitch', 'roll', 'alpha_0', 'alpha_1', 'alpha_2',
'dx', 'dy', 'dz', 'dx', 'dy', 'dz',
'dyaw', 'dpitch', 'droll']) 'dalpha_0', 'dalpha_1', 'dalpha_2'])
agent = naviagent.Single(self.mydb, agent = naviagent.Single(self.mydb,
posorient_vel, posorient_vel,
memory_friendly=False) memory_friendly=False)
...@@ -96,15 +96,15 @@ class TestNavipyMovingAgent(unittest.TestCase): ...@@ -96,15 +96,15 @@ class TestNavipyMovingAgent(unittest.TestCase):
def test_angular_velocity(self): def test_angular_velocity(self):
posorient_vel = pd.Series(data=np.random.rand(12), posorient_vel = pd.Series(data=np.random.rand(12),
index=['x', 'y', 'z', index=['x', 'y', 'z',
'yaw', 'pitch', 'roll', 'alpha_0', 'alpha_1', 'alpha_2',
'dx', 'dy', 'dz', 'dx', 'dy', 'dz',
'dyaw', 'dpitch', 'droll']) 'dalpha_0', 'dalpha_1', 'dalpha_2'])
agent = naviagent.Single(self.mydb, agent = naviagent.Single(self.mydb,
posorient_vel, posorient_vel,
memory_friendly=False) memory_friendly=False)
agent.angular_velocity = posorient_vel agent.angular_velocity = posorient_vel
self.assertTrue( self.assertTrue(
posorient_vel.loc[['dyaw', 'dpitch', 'droll']].equals( posorient_vel.loc[['dalpha_0', 'dalpha_1', 'dalpha_2']].equals(
agent.angular_velocity), agent.angular_velocity),
'angular velocity setter failed') 'angular velocity setter failed')
...@@ -182,10 +182,10 @@ class TestNavipyMovingAgent(unittest.TestCase): ...@@ -182,10 +182,10 @@ class TestNavipyMovingAgent(unittest.TestCase):
# Two loops attractors # Two loops attractors
graph_edges = list() graph_edges = list()
for snode, enode in zip(graph_nodes[:11], for snode, enode in zip(graph_nodes[:11],
np.roll(graph_nodes[:11], 1)): np.alpha_2(graph_nodes[:11], 1)):
graph_edges.append((snode, enode)) graph_edges.append((snode, enode))
for snode, enode in zip(graph_nodes[11:], for snode, enode in zip(graph_nodes[11:],
np.roll(graph_nodes[11:], 1)): np.alpha_2(graph_nodes[11:], 1)):
graph_edges.append((snode, enode)) graph_edges.append((snode, enode))
graph = nx.DiGraph() graph = nx.DiGraph()
......
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