Created
December 23, 2018 08:33
-
-
Save nyukhalov/153d4788eadeb341f69a6f6e11a99436 to your computer and use it in GitHub Desktop.
Homogenous Transformation for Particle Filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import math | |
def h_transform(observation_coords, particle_coords, particle_heading): | |
mat = np.matrix([ | |
[math.cos(particle_heading), -math.sin(particle_heading), particle_coords[0]], | |
[math.sin(particle_heading), math.cos(particle_heading), particle_coords[1]], | |
[0, 0, 1] | |
]) | |
vec = np.matrix([ | |
[observation_coords[0]], | |
[observation_coords[1]], | |
[1] | |
]) | |
ret = mat * vec | |
return (ret.item(0), ret.item(1)) | |
observation_coords = (0,-4) | |
particle_coords = (4,5) | |
particle_heading = -math.pi / 2 | |
print(h_transform(observation_coords, particle_coords, particle_heading)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment