############################################# ############################################# ### ### ### Drone-Radars Capstone Team ### ### Cubic Point-Cloud Map Pathfinding ### ### Updated: 21/02/2018, 1030H ### ### ### ############################################# ############################################# import numpy as np import matplotlib.pyplot as plt from matplotlib import cm from mpl_toolkits.mplot3d import Axes3D ''' Initialise the XYZ points in point cloud map (PCM) ''' NoiseToggle = 1 # Toggle 1 to enable noise, toggle 0 for no noise NoiseMu,NoiseSigma = 100.0,50.0 # Vary the mean and standard deviation of AWGN Span = 11 # Length of points in one array spanning across one axis Points = np.linspace(-5,5,Span) # Array of points spanning across one axis PCM_X = [] # X Axis coordinates of all points in point cloud PCM_Y = [] # Y Axis coordinates of all points in point cloud PCM_Z = [] # Z Axis coordinates of all points in point cloud PCM_A = [] # Amplitude (brightness) of each obstacle, 0 - Min, 255 - Max ''' Create the point cloud map (PCM) environment ''' for i in range(0,Span): for j in range(0,Span): for k in range(0,Span): PCM_X.append(Points[i]) PCM_Y.append(Points[j]) PCM_Z.append(Points[k]) PCM_X = np.array(PCM_X) PCM_Y = np.array(PCM_Y) PCM_Z = np.array(PCM_Z) ''' Create the obstacles in the PCM environment ''' for m in range(0,Span**3): if (-2.0 <= PCM_X[m] <= 2.0) and (-2.0 <= PCM_Y[m] <= 2.0) and (-2.0 <= PCM_Z[m] <= 2.0): PCM_A.append(255.0) else: PCM_A.append(0.0) PCM_A = np.array(PCM_A) ''' Generate additive Gaussian white noise ''' if NoiseToggle == 1: AWGN = np.random.normal(NoiseMu,NoiseSigma,Span**3) PCM_A += AWGN ''' Plot out the point-cloud map (PCM) environment ''' PCM_Fig = plt.figure() PCM = Axes3D(PCM_Fig) PCM.scatter(PCM_X,PCM_Y,PCM_Z,c=PCM_A,cmap=cm.rainbow) PCM.set_xlabel('X Axis') PCM.set_ylabel('Y Axis') PCM.set_zlabel('Z Axis')
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question