20 from tf_quaternion
import transformations
21 from uuv_thrusters
import ThrusterManager
24 PKG =
'uuv_thruster_manager' 25 roslib.load_manifest(PKG)
30 np.array([1, 0, 0, 0]),
31 np.array([0, 1, 0, 0]),
32 np.array([0, 0, 1, 0])
36 thrust_body = transformations.quaternion_matrix(orientation).dot(
37 axis.transpose())[0:3]
38 torque_body = np.cross(pos, thrust_body)
39 return np.hstack((thrust_body, torque_body)).transpose()
45 pos = np.random.rand(3)
46 q = transformations.random_quaternion()
55 self.assertEqual(thruster.index, IDX)
56 self.assertEqual(thruster.topic, TOPIC)
57 self.assertTrue((thruster.tam_column ==
get_force_vector(pos, q, axis)).all())
62 pos = np.random.rand(3)
63 q = transformations.random_quaternion()
64 gain = random.random()
66 thruster = Thruster.create_thruster(
75 self.assertEqual(thruster.index, IDX)
76 self.assertEqual(thruster.topic, TOPIC)
77 self.assertTrue((thruster.tam_column ==
get_force_vector(pos, q, axis)).all())
79 self.assertEqual(thruster.get_thrust_value(0), 0)
80 self.assertEqual(thruster.get_command_value(0), 0)
82 command = np.linspace(-100, 100, 10)
84 y = thruster.get_thrust_value(x)
85 self.assertEqual(y, gain * np.abs(x) * x)
87 thrust = np.linspace(-50000, 50000, 10)
89 y = thruster.get_command_value(x)
90 self.assertEqual(y, np.sign(x) * np.sqrt(np.abs(x) / gain))
93 input_values = np.linspace(-50, 50, 10)
94 output_values = np.linspace(-10000, 10000, 10)
96 gain = 20000.0 / 100.0
100 pos = np.random.rand(3)
101 q = transformations.random_quaternion()
103 thruster = Thruster.create_thruster(
111 output=output_values)
113 self.assertEqual(thruster.index, IDX)
114 self.assertEqual(thruster.topic, TOPIC)
115 self.assertTrue((thruster.tam_column ==
get_force_vector(pos, q, axis)).all())
117 self.assertTrue(np.isclose(thruster.get_thrust_value(0), 0))
118 self.assertTrue(np.isclose(thruster.get_command_value(0), 0))
120 x = random.random() * 10
121 self.assertTrue(np.isclose(thruster.get_thrust_value(x), gain * x))
122 y = random.random() * 10000
123 self.assertTrue(np.isclose(thruster.get_command_value(y), y / gain))
125 if __name__ ==
'__main__':
127 rosunit.unitrun(PKG,
'test_thrusters', TestThrusters)
def test_thruster_proportional(self)
def test_thruster_custom(self)
def get_force_vector(pos, orientation, axis)