Exemplo n.º 1
0
# Set up environment #args

beacons = [
    Beacon(np.array([0.2, 0.2])),
    Beacon(np.array([1.2, 0.5])),
    Beacon(np.array([0.2, 0.8]))
]
#obstacles = [RectangularObstacle(np.array([[0.75, 0.2], [0.75, 0.4], [0.85, 0.4], [0.85,0.2]], float).T),\
#             RectangularObstacle(np.array([[0.5,0.85], [1.15,0.85], [1.15,0.6], [0.5,0.6]], float).T)]
obstacles = []

s = SimEnv2D(bounds=[-0.1, 1.5, -0.1, 1], beacons=beacons, obstacles=obstacles)

x0 = np.array([0, 0.5, 0, 0])
car = SimpleCar(x0)
car.attach_sensor(BeaconSensor(decay_coeff=25), lambda x: x[0:2])

s.add_robot(car)

# Number of timesteps
T = 30  #arg

# Dynamics and measurement noise
num_states = car.NX
num_ctrls = car.NU
num_measure = len(beacons) + 1  #arg/make part of robot observe
Q = np.mat(np.diag([1e-5] * num_states))  #arg
Q[2, 2] = 1e-8  # Gets out of hand if noise in theta or phi
Q[3, 3] = 1e-8  # Can also add theta/phi to measurement like Sameep #TODO?
R = np.mat(np.diag([0.005] * num_measure))  #arg
Exemplo n.º 2
0
import random
from math import log
from numpy.random import multivariate_normal as mvn
from kalman_filter import ekf_update
from covar import cov2vec, vec2cov
from optimize import scp_solver_beliefs
from scipy.io import loadmat
import matplotlib.animation as animation

# Set up environment #args

beacons = [Beacon(np.array([0.3, 0.7])), Beacon(np.array([1, 0.7]))]
s = SimEnv2D(bounds=[-0.1, 1.3, -0.1, 1], beacons=beacons)

x0 = np.array([0, 0, np.pi / 4, 0])
car = SimpleCar(x0)
car.attach_sensor(BeaconSensor(decay_coeff=100), lambda x: x[0:2])

s.add_robot(car)

# Number of timesteps
T = 30  # arg

# Dynamics and measurement noise
num_states = car.NX
num_ctrls = car.NU
num_measure = len(beacons) + 1  # arg/make part of robot observe
Q = np.mat(np.diag([1e-3] * num_states))  # arg
Q[2, 2] = 1e-8  # Gets out of hand if noise in theta or phi
Q[3, 3] = 1e-8  # Can also add theta/phi to measurement like Sameep #TODO?
R = np.mat(np.diag([0.0005] * num_measure))  # arg
Exemplo n.º 3
0
colors = ['b', 'g', 'r', 'c', 'm', 'y']
# Set up environment #args

beacons=[Beacon(np.array([0.2,0.2])),
         Beacon(np.array([1.2, 0.5])),
         Beacon(np.array([0.2, 0.8]))]
#obstacles = [RectangularObstacle(np.array([[0.75, 0.2], [0.75, 0.4], [0.85, 0.4], [0.85,0.2]], float).T),\
#             RectangularObstacle(np.array([[0.5,0.85], [1.15,0.85], [1.15,0.6], [0.5,0.6]], float).T)]

obstacles=[]

s = SimEnv2D(bounds=[-0.1, 1.5, -0.1, 1], beacons=beacons, obstacles=obstacles)

ball = np.array([1.4, 0.30])
x0 = np.array([0, 0.5, 0, 0])
car = SimpleCar(x0)
car.attach_sensor(BeaconSensor(decay_coeff=25), lambda x: x[0:2])

localizer = LocalizerBot(car,ball)
x0 = np.mat(localizer.x)
localizer.attach_sensor(FOVSensor(localizer.x, fov_angle=2*pi, decay_coeff=25), lambda x: localizer.fov_state(x))

s.add_robot(localizer)

# Number of timesteps
T = 30 #arg

# Dynamics and measurement noise
num_states = localizer.NX
num_ctrls = localizer.NU
num_measure = len(beacons)+1+1 #arg/make part of robot observe
# Set up environment #args

beacons=[Beacon(np.array([1.2, 0.7])),
         Beacon(np.array([0.2, 0.8]))]
obstacles = [RectangularObstacle(np.array([[0.75, 0.2], [0.75, 0.4], [0.85, 0.4], [0.85,0.2]], float).T),\
             RectangularObstacle(np.array([[0.5,0.85], [1.15,0.85], [1.15,0.6], [0.5,0.6]], float).T)]
obstacles=[]

s = SimEnv2D(bounds=[-0.1, 1.5, -0.1, 1], beacons=beacons, obstacles=obstacles)

ball = np.array([1.4, 0.30])
ball = np.array([1.35, 0])
#ball = np.array([0.8, 0.35])
ball = np.array([1.3, 0.8])
x0 = np.array([0, 0.5, 0, 0])
car = SimpleCar(x0)
car.attach_sensor(BeaconSensor(decay_coeff=25), lambda x: x[0:2])

localizer = LocalizerBot(car,ball)
x0 = np.mat(localizer.x)
#localizer.attach_sensor(FOVSensor(localizer.x, fov_angle=2*pi, decay_coeff=25), lambda x: localizer.fov_state(x))
#localizer.attach_sensor(FOVSensor(localizer.x, fov_angle=2*pi, decay_coeff=25), lambda x: localizer.fov_state(x))
w = 0.05
f = 0.1
localizer.attach_sensor(ExtendedCamera2D(f, localizer.x, w, ks=[-0.33, 0.1],
        radial_distortion=True, field_of_view=True, depth_of_field=False),
        lambda x: localizer.fov_state(x))
#localizer.attach_sensor(PinholeCamera2D(f, localizer.x, w),
        #lambda x: localizer.fov_state(x))

s.add_robot(localizer)