PyTeapot-Quaternion-Euler-cube-rotation icon indicating copy to clipboard operation
PyTeapot-Quaternion-Euler-cube-rotation copied to clipboard

[TODO] Read data from file for visualisation

Open sandeepnmenon opened this issue 2 years ago • 3 comments

Raising issue as per TODO.

Would like to submit PR for the same

sandeepnmenon avatar Mar 04 '22 18:03 sandeepnmenon

Raised PR #10 Please review.

sandeepnmenon avatar Mar 07 '22 15:03 sandeepnmenon

Hi sorry quite busy right now. Might review over the weekend.

thecountoftuscany avatar Mar 09 '22 02:03 thecountoftuscany

if your file is csv then just read the file using pandas, construct the message yourself and send it over UDP.

That's what I am doing right now and it does the trick

example:

df_csv = pd.read_csv(PATH_CSV)
time = df_csv['loggingTime(txt)']


quat_w = df_csv['motionQuaternionW(R)']
quat_x = df_csv['motionQuaternionX(R)']
quat_y = df_csv['motionQuaternionY(R)']
quat_z = df_csv['motionQuaternionZ(R)']

yaw = df_csv['motionYaw(rad)']
pitch = df_csv['motionPitch(rad)']
roll = df_csv['motionRoll(rad)']

UDP_IP = "0.0.0.0"
UDP_PORT = 5005
START_indx = 9350
END_indx = 10000
MESSAGE = 'w' + str(quat_w[1]) + 'wa' + str(quat_x[1]) + 'ab' + str(quat_y[1]) + 'bc' + str(quat_z[1]) + 'c'

print("UDP target IP:", UDP_IP)
print("UDP target port:", UDP_PORT)
print("message:", MESSAGE)
print(f"Time {time[1]}")

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
i = START_indx
# while True:
while i < END_indx:
    MESSAGE = 'w' + str(quat_w[i]) + 'wa' + str(quat_x[i]) + 'ab' + str(quat_y[i]) + 'bc' + str(quat_z[i]) + 'c'
    sock.sendto(bytes(MESSAGE, "utf-8"), (UDP_IP, UDP_PORT))
    print(f"Time: {time[i]}, i: {i}")
    i += 1
    input()

note: I use "input()" so the code runs when I want it so I can go over line by line

AsternA avatar Jul 29 '22 19:07 AsternA