本文整理汇总了Python中map.Map.sample_seed方法的典型用法代码示例。如果您正苦于以下问题:Python Map.sample_seed方法的具体用法?Python Map.sample_seed怎么用?Python Map.sample_seed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map.Map
的用法示例。
在下文中一共展示了Map.sample_seed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Map
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import sample_seed [as 别名]
__author__ = 'mbarnes1'
import unittest
import sys
import matplotlib.pyplot as plt
import matplotlib.cm as cm
sys.path.append('../')
from map import Map
from particlefilter import Particle
map = Map('../../data/map/synthetic_small.dat')
map.sample_seed(1000)
class MyTestCase(unittest.TestCase):
def setUp(self):
print 'Setting up'
def test_query(self):
self.assertEqual(map.query(0, 0), 1)
self.assertEqual(map.query(0, 40), 1)
self.assertEqual(map.query(0, 90), 0)
self.assertEqual(map.query(50, 0), 0)
self.assertEqual(map.query(50, 50), 1)
self.assertEqual(map.query(50, 90), 0)
self.assertEqual(map.query(90, 0), 0)
self.assertEqual(map.query(90, 50), 1)
self.assertEqual(map.query(90, 90), 0)
def test_display(self):
particles = []
for _ in range(0, 5):
示例2: MyTestCase
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import sample_seed [as 别名]
class MyTestCase(unittest.TestCase):
def setUp(self):
self.map = Map('../../data/map/synthetic_small.dat')
self.map.sample_seed(100)
self.particles = list()
for _ in range(0, 100):
particle = Particle(self.map)
particle.x = 0
particle.y = 40
particle.theta = 0
particle.odometry = [0, 0, 0]
self.particles.append(particle)
self.particle = particle
def test_straight_right(self):
motion_model = MotionModel(0, 0, 0, 0)
odometry = [0, 0, 0]
for _ in range(0, 100):
odometry[0] += 1
motion_model.update(self.particle, odometry, 0)
self.assertEqual(self.particle.x, 100)
self.assertEqual(self.particle.y, 40)
self.assertEqual(self.particle.theta, 0)
def test_straight_up(self):
motion_model = MotionModel(0, 0, 0, 0)
odometry = [0, 0, 0]
self.particle.x = 40
self.particle.y = 0
self.particle.theta = math.pi/2
for _ in range(0, 100):
odometry[0] += 1
motion_model.update(self.particle, odometry, 0)
self.assertEqual(self.particle.x, 40)
self.assertEqual(self.particle.y, 100)
self.assertEqual(self.particle.theta, math.pi/2)
def test_sidestep_right(self):
motion_model = MotionModel(0, 0, 0, 0)
odometry = [0, 0, 0]
self.particle.x = 0
self.particle.y = 40
self.particle.theta = math.pi/2
for _ in range(0, 100):
odometry[1] -= 1
motion_model.update(self.particle, odometry, 0)
self.assertEqual(self.particle.x, 100)
self.assertEqual(self.particle.y, 40)
self.assertEqual(self.particle.theta, math.pi/2)
def test_turn_left(self):
motion_model = MotionModel(0, 0, 0, 0)
odometry = [0, 0, 0]
self.particle.x = 0
self.particle.y = 40
self.particle.theta = 0
for _ in range(0, 10):
odometry[2] += math.pi/20
motion_model.update(self.particle, odometry, 0)
self.assertEqual(self.particle.x, 0)
self.assertEqual(self.particle.y, 40)
self.assertEqual(self.particle.theta, math.pi/2)
def test_turn_right(self):
motion_model = MotionModel(0, 0, 0, 0)
odometry = [0, 0, 0]
self.particle.x = 0
self.particle.y = 40
self.particle.theta = 0
for _ in range(0, 10):
odometry[2] -= math.pi/20
motion_model.update(self.particle, odometry, 0)
self.assertEqual(self.particle.x, 0)
self.assertEqual(self.particle.y, 40)
self.assertEqual(self.particle.theta, -math.pi/2)
def test_forward_back(self):
motion_model = MotionModel(0, 0, 0, 0)
odometry = [0, 0, 0]
self.particle.x = 0
self.particle.y = 40
self.particle.theta = 0
for _ in range(0, 10):
odometry[0] += 1
motion_model.update(self.particle, odometry, 0)
for _ in range(0, 10):
odometry[2] += math.pi/10
motion_model.update(self.particle, odometry, 0)
for _ in range(0, 10):
odometry[0] += 1
motion_model.update(self.particle, odometry, 0)
self.assertEqual(self.particle.x, 0)
self.assertEqual(self.particle.y, 40)
self.assertEqual(self.particle.theta, math.pi)
def test_circle(self):
motion_model = MotionModel(0, 0, 0, 0)
odometry = [0, 0, 0]
self.particle.x = 0
self.particle.y = 40
#.........这里部分代码省略.........