test_waypoint.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright (c) 2016 The UUV Simulator Authors.
3 # All rights reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 import roslib
18 
19 PKG = 'uuv_trajectory_control'
20 roslib.load_manifest(PKG)
21 
22 import sys
23 import unittest
24 from uuv_waypoints import Waypoint
25 
26 
27 class TestWaypoint(unittest.TestCase):
29  wp0 = Waypoint(x=1, y=2, z=3)
30  wp1 = Waypoint(x=1, y=2, z=3)
31  self.assertEquals(wp0, wp1, 'Waypoints equal operator failed')
32 
34  wp0 = Waypoint(x=1, y=2, z=3)
35  wp1 = Waypoint(x=6, y=5, z=4)
36  self.assertNotEquals(wp0, wp1, 'Waypoints unequal operator failed')
37 
39  wp = Waypoint()
40  wp.violates_constraint = True
41  self.assertTrue(wp.violates_constraint, 'Constraint violation flag not correctly set')
42 
44  wp = Waypoint(x=0, y=2, z=0)
45  self.assertEquals(wp.dist([0, 4, 0]), 2, 'Distance calculation is wrong')
46  self.assertEquals(wp.dist([2, 2, 0]), 2, 'Distance calculation is wrong')
47  self.assertEquals(wp.dist([0, 2, 2]), 2, 'Distance calculation is wrong')
48 
49  def test_to_message(self):
50  wp0 = Waypoint(x=1, y=2, z=3)
51  wp1 = Waypoint()
52  wp1.from_message(wp0.to_message())
53  self.assertEquals(wp0, wp1, "Waypoint to message conversion failed")
54 
55 
56 if __name__ == '__main__':
57  import rosunit
58  rosunit.unitrun(PKG, 'test_waypoint', TestWaypoint)
def test_violate_constraint_flag(self)


uuv_trajectory_control
Author(s):
autogenerated on Thu Jun 18 2020 03:28:42