Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # %%
- import time
- import serial
- import matplotlib.pyplot as plt
- from mpl_toolkits import mplot3d
- ser=serial.Serial('COM4',115200)
- dmxb= []
- dmyb= []
- dmzb= []
- dmzm= []
- dmym= []
- dmxm= []
- for i in range(100):
- read=ser.readline()
- if read :
- decode=read.decode()
- string=decode.strip()
- split=string.split(',')
- # rlb,ptb,ywb,gxb,gyb,gzb,l1b,l2b,l3b,mxb,myb,mzb,axb,ayb,azb,vxb,vyb,vzb,sys,gys,acs,mgs,axm,aym,azm,gxm,gym,gzm,mxm,mym,mzm=string.split(',')
- rlb,ptb,ywb,gxb,gyb,gzb,\
- l1b,l2b,l3b,mxb,myb,mzb,\
- axb,ayb,azb,vxb,vyb,vzb,\
- sys,gys,acs,mgs,axm,aym,\
- azm,gxm,gym,gzm,mxm,mym,mzm\
- =[float(x) for x in string.split(',')]
- print(mxb)
- dmxb.append(mxb)
- print(myb)
- dmyb.append(myb)
- print(mzb)
- dmzb.append(mzb)
- print(mxm)
- dmxm.append(mxm)
- print(mym)
- dmym.append(mym)
- print(mzm)
- dmzm.append(mzm)
- ser.close()
- fig = plt.figure(figsize = (10, 7))
- ax = plt.axes(projection ="3d")
- # Creating plot
- ax.scatter3D(mxb, myb, mzb, color = "green")
- plt.title("simple 3D scatter plot")
- # show plot
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement