16 from __future__
import print_function
20 from geometry_msgs.msg
import Vector3, Inertia
21 from uuv_gazebo_ros_plugins_msgs.msg
import UnderwaterObjectModel
24 PKG =
'uuv_gazebo_ros_plugins' 25 NAME =
'test_sphere_vehicle' 27 import roslib; roslib.load_manifest(PKG)
42 rospy.wait_for_service(
'/vehicle/get_model_properties')
44 get_models = rospy.ServiceProxy(
'/vehicle/get_model_properties',
48 self.assertEqual(len(models.link_names), 1)
49 self.assertEqual(len(models.models), 1)
53 models.link_names[0],
'vehicle/base_link',
54 'Link name is invalid, name=' + str(models.link_names[0]))
57 self.assertIsInstance(models.models[0].added_mass, tuple)
58 self.assertIsInstance(models.models[0].linear_damping, tuple)
59 self.assertIsInstance(models.models[0].linear_damping_forward_speed, tuple)
60 self.assertIsInstance(models.models[0].quadratic_damping, tuple)
61 self.assertIsInstance(models.models[0].volume, float)
62 self.assertIsInstance(models.models[0].bbox_length, float)
63 self.assertIsInstance(models.models[0].bbox_width, float)
64 self.assertIsInstance(models.models[0].bbox_height, float)
65 self.assertIsInstance(models.models[0].fluid_density, float)
66 self.assertIsInstance(models.models[0].neutrally_buoyant, bool)
67 self.assertIsInstance(models.models[0].cob, Vector3)
68 self.assertIsInstance(models.models[0].inertia, Inertia)
71 self.assertEqual(len(models.models[0].added_mass), 36)
72 self.assertEqual(len(models.models[0].linear_damping), 36)
73 self.assertEqual(len(models.models[0].linear_damping_forward_speed), 36)
74 self.assertEqual(len(models.models[0].quadratic_damping), 36)
77 self.assertEqual(models.models[0].fluid_density, 1028.0)
78 self.assertEqual(models.models[0].volume, 0.009727626)
79 self.assertEqual(models.models[0].bbox_height, 1.0)
80 self.assertEqual(models.models[0].bbox_length, 1.0)
81 self.assertEqual(models.models[0].bbox_width, 1.0)
84 rospy.wait_for_service(
'/vehicle/get_model_properties')
86 get_models = rospy.ServiceProxy(
'/vehicle/get_model_properties',
90 d_idxs = [i*6 + j
for i, j
in zip(range(3), range(3))]
91 sphere_ma = 2.0 / 3.0 * models.models[0].fluid_density * np.pi * \
93 for i
in range(len(models.models[0].added_mass)):
95 self.assertLess(abs(models.models[0].added_mass[i] - sphere_ma), 0.001)
97 self.assertEqual(models.models[0].added_mass[i], 0.0)
100 rospy.wait_for_service(
'/vehicle/get_model_properties')
102 get_models = rospy.ServiceProxy(
'/vehicle/get_model_properties',
104 models = get_models()
106 area_section = np.pi * RADIUS**2
107 dq = -0.5 * models.models[0].fluid_density * CD * area_section
109 d_idxs = [i*6 + j
for i, j
in zip(range(3), range(3))]
110 for i
in range(len(models.models[0].quadratic_damping)):
112 self.assertLess(abs(models.models[0].quadratic_damping[i] - dq), 0.001)
114 self.assertEqual(models.models[0].quadratic_damping[i], 0.0)
117 if __name__ ==
'__main__':
119 rosunit.unitrun(PKG, NAME, TestSphereVehicle)
def test_nonlinear_damping_coefs(self)
def test_get_model_parameters(self)
def test_added_mass_coefs(self)