本文整理汇总了Python中driver.Driver.calc_errors方法的典型用法代码示例。如果您正苦于以下问题:Python Driver.calc_errors方法的具体用法?Python Driver.calc_errors怎么用?Python Driver.calc_errors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类driver.Driver
的用法示例。
在下文中一共展示了Driver.calc_errors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestDriverCalculations
# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import calc_errors [as 别名]
class TestDriverCalculations(unittest.TestCase):
# sign conventions (revised):
# axis: x axis is parallel to goal, y axis is to- the left when facing
# the goal direction, z-axis is oriented up
# positive heading error - rotated counter clockwise from goal
# positve offset error - positive y-axis,
def setUp(self):
self.driver_obj = Driver()
def test_equal_odom(self):
# print('test_equal_odom')
location = easy_Odom(x=0, y=0, v=0.0, heading=0.0, frame='map')
goal = easy_Odom(x=0, y=0, v=0.0, heading=0.0, frame='map')
along, off, heading = self.driver_obj.calc_errors(location=location, goal=goal)
self.assertTrue(is_close(along, 0))
self.assertTrue(is_close(off, 0))
self.assertTrue(is_close(heading, 0))
def test_aheadx_target1(self):
# print('test_ahead_target')
location = easy_Odom(x=0, y=0, v=0.0, heading=0.0, frame='map')
goal = easy_Odom(x=1.0, y=0, v=0.0, heading=0.0, frame='map')
along, off, heading = self.driver_obj.calc_errors(location=location, goal=goal)
self.assertTrue(is_close(along, -1.0))
self.assertTrue(is_close(off, 0))
self.assertTrue(is_close(heading, 0))
def test_aheadx_target2(self):
# print('test_ahead_target')
location = easy_Odom(x=0, y=0, v=0.0, heading=0.0, frame='map')
goal = easy_Odom(x=2.0, y=0, v=0.0, heading=0.0, frame='map')
along, off, heading = self.driver_obj.calc_errors(location=location, goal=goal)
self.assertTrue(is_close(along, -2.0))
self.assertTrue(is_close(off, 0))
self.assertTrue(is_close(heading, 0))
def test_aheadx_target3(self):
# print('test_ahead_target')
location = easy_Odom(x=0, y=0, v=0.0, heading=0.0, frame='map')
goal = easy_Odom(x=3.0, y=0, v=0.0, heading=0.0, frame='map')
along, off, heading = self.driver_obj.calc_errors(location=location, goal=goal)
self.assertTrue(is_close(along, -3.0))
self.assertTrue(is_close(off, 0))
self.assertTrue(is_close(heading, 0))
def test_behindx_target1(self):
# print('test_behind_target')
location = easy_Odom(x=0, y=0, v=0.0, heading=0.0, frame='map')
goal = easy_Odom(x=-1.0, y=0, v=0.0, heading=0.0, frame='map')
along, off, heading = self.driver_obj.calc_errors(location=location, goal=goal)
self.assertTrue(is_close(along, 1.0))
self.assertTrue(is_close(off, 0))
self.assertTrue(is_close(heading, 0))
def test_behindx_target2(self):
# print('test_behind_target')
location = easy_Odom(x=0, y=0, v=0.0, heading=0.0, frame='map')
goal = easy_Odom(x=-2.0, y=0, v=0.0, heading=0.0, frame='map')
along, off, heading = self.driver_obj.calc_errors(location=location, goal=goal)
self.assertTrue(is_close(along, 2.0))
self.assertTrue(is_close(off, 0))
self.assertTrue(is_close(heading, 0))
def test_behindx_target3(self):
# print('test_behind_target')
location = easy_Odom(x=0, y=0, v=0.0, heading=0.0, frame='map')
goal = easy_Odom(x=-3.0, y=0, v=0.0, heading=0.0, frame='map')
along, off, heading = self.driver_obj.calc_errors(location=location, goal=goal)
self.assertTrue(is_close(along, 3.0))
self.assertTrue(is_close(off, 0))
self.assertTrue(is_close(heading, 0))
def test_aheady_target1(self):
# print('test_ahead_target')
location = easy_Odom(x=0, y=0, v=0.0, heading=math.pi/2.0, frame='map')
goal = easy_Odom(x=0.0, y=1.0, v=0.0, heading=math.pi/2.0, frame='map')
along, off, heading = self.driver_obj.calc_errors(location=location, goal=goal)
self.assertTrue(is_close(along, -1.0))
self.assertTrue(is_close(off, 0))
self.assertTrue(is_close(heading, 0))
def test_aheady_target2(self):
# print('test_ahead_target')
location = easy_Odom(x=0, y=0, v=0.0, heading=math.pi/2.0, frame='map')
goal = easy_Odom(x=0.0, y=2.0, v=0.0, heading=math.pi/2.0, frame='map')
along, off, heading = self.driver_obj.calc_errors(location=location, goal=goal)
self.assertTrue(is_close(along, -2.0))
self.assertTrue(is_close(off, 0))
self.assertTrue(is_close(heading, 0))
def test_aheady_target3(self):
# print('test_ahead_target')
location = easy_Odom(x=0, y=0, v=0.0, heading=math.pi/2.0, frame='map')
goal = easy_Odom(x=0.0, y=3.0, v=0.0, heading=math.pi/2.0, frame='map')
along, off, heading = self.driver_obj.calc_errors(location=location, goal=goal)
self.assertTrue(is_close(along, -3.0))
self.assertTrue(is_close(off, 0))
self.assertTrue(is_close(heading, 0))
#.........这里部分代码省略.........