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