Created
November 10, 2019 01:03
-
-
Save dmalawey/944ee8024f822d46f4b7cb9645ff15d5 to your computer and use it in GitHub Desktop.
reconditioning of lidar readings and practice with numPy
This file contains hidden or 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
# the Lidar returns some error values when it can't get a measurement. | |
# any value below 16mm indicates a bad reading or other problem. | |
# this code is practice for trimming the bad readings out of the array | |
# containing distances & angles. | |
import numpy as np | |
np.set_printoptions(suppress=True) | |
# create an array with some distances which returned invalid (ie 0, 0.002) | |
scan= np.array([ \ | |
[ 1.471, -24.875],\ | |
[ 1.357, -19.87 ],\ | |
[ 0., -14.864],\ | |
[ 0.268, -9.858],\ | |
[ 0.258, -4.853],\ | |
[ 0.002, 0.153],\ | |
[ 0.002, 5.159],\ | |
[ 0.002, 10.164]]) | |
print("\n scan \n", scan) # verify the values stored properly | |
dist = scan[:,0] # store just first column | |
print("\n distances:\n", dist) | |
angles = scan[:,1] # store just 2nd column | |
print("\n angles:\n", angles) | |
valid = np.where(dist > 0.016) # find values 16mm | |
print("\n valid:\n", valid ) | |
myNums = dist[valid] # get valid distances | |
print("\n myNums:\n", myNums) | |
myAng = angles[valid] # get corresponding valid angles | |
print("\n myAng:\n", myAng) | |
output = np.vstack((myNums,myAng)) # recombine columns | |
print("\n output:\n",output) | |
n = output.T # transpose the matrix | |
print("\n final output: \n", n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment