diff --git a/navipy/moving/agent.py b/navipy/moving/agent.py index 5561fde202970598a74ab6e60ef35322ffcf1e12..7dd1d6cb106919808e37107ebb6ec7ea4e2e592a 100644 --- a/navipy/moving/agent.py +++ b/navipy/moving/agent.py @@ -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: diff --git a/navipy/moving/test_agent.py b/navipy/moving/test_agent.py index d72bf34464851b2d34c1e990b35b7fe779acd81a..c482eb9da26024bbab1271b93db22156aa8561aa 100644 --- a/navipy/moving/test_agent.py +++ b/navipy/moving/test_agent.py @@ -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()