thecountoftuscany / PyTeapot-Quaternion-Euler-cube-rotation

Visualization of IMU orientation from quaternion or Euler angles with a rotating cube
GNU General Public License v3.0
144 stars 42 forks source link

Application: Black screen, not-responding #11

Closed RafigRzayev closed 2 years ago

RafigRzayev commented 2 years ago

Hi,

I tried to run the application on my Windows, but the window is black and is not responding. I believe it is same issue as mentioned in https://github.com/thecountoftuscany/PyTeapot-Quaternion-Euler-cube-rotation/issues/5

Below you can find the screenshots describing the issue and my prerequisites installation: screenshotpy

Captureimu

I guess I have some dependency missing, but I don't get any kind of error. If someone has done Windows installation could you please guide what to do regarding other pre-requisites?

WillChen0207 commented 2 years ago

Same problem, please help us

thecountoftuscany commented 2 years ago

It seems like you have the the dependencies installed. Did you configure the UDP IP if using WiFi, or set useSerial to True if using serial port for communication (and also set the right serial port in place of /dev/ttyUSB0)? Try using the serial port first to see if it works. If the problem is with using UDP sockets, perhaps @Takaklas can help since they implemented that functionality?

WillChen0207 commented 2 years ago

Glad to receive your response. I confirmed thet I had the dependencies installed already and changed useSerial to True as you suggested. Anyway I'm trying to test my new-bought IMU sensor, but the program always gets stuck and when it exit the error info is:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8 in position 0: invalid start byte

I tried to change utf-8 to gbk, ascii, gb2312, etc. , but none of them works. Can you help me out? Thanks again

thecountoftuscany commented 2 years ago

Is there an error stack trace? Any traceback to which line the error originates? Also, which version of python are you using? Are you already sending the IMU data on your computer's serial port in the format mentioned in the readme? Did you change to that particular serial port in the code?

WillChen0207 commented 2 years ago

The full error stack trace is as below:

Traceback (most recent call last): File "C:/.../PyTeapot-Quaternion-Euler-cube-rotation/pyteapot.py", line 203, in main() File "C:/.../PyTeapot-Quaternion-Euler-cube-rotation/pyteapot.py", line 43, in main [yaw, pitch, roll] = read_data() File "C:/.../PyTeapot-Quaternion-Euler-cube-rotation/pyteapot.py", line 102, in read_data line = ser.readline().decode('UTF-8').replace('\n', '') UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8 in position 0: invalid start byte

My python version is 3.8.8. I just used official upper machine software of this IMU and confirmed my PC reads the data correctly. As I am new in this area, I just change my setting as that of the upper machine, like this:

useSerial = True # set true for using serial for data transmission, false for wifi useQuat = False # set true for using quaternions, false for using y,p,r angles if(useSerial): import serial ser = serial.Serial('com5', 115200) else: import socket ...

Did I set those params correctly? Or the data from IMU needs to be formatted as some standards first?

thecountoftuscany commented 2 years ago

Yes the IMU data needs to be formatted as defined in the readme (see the String passed over Serial or WiFi section). You can connect the IMU to a microcontroller like Arduino and write a simple program to read the IMU data and send it on your computer's serial port in the format specified in the readme. Also, I just ran my application on Windows for the first time and it ran perfectly fine. Just reiterating the steps I performed from scratch (you can ignore steps 2, 3 if you wrote a program to send your IMU's actual data on the serial port):

  1. pip install pygame PyOpenGL PySerial
  2. Since I don't have a physical device to send IMU data over serial port, I used com0com to fake a pair of virtual COM ports (labelled COM11 (Tx), COM12 (Rx)) on Windows.
  3. Wrote a bare minimum python script to send fake data on the Tx COM port:
    import serial
    ser = serial.Serial('COM11', 38400)
    while True:
    ser.write(b'w0.09wa-0.12ab-0.09bc0.98cy168.8099yp12.7914pr-11.8401r\n')
    ser.close()
  4. Set useSerial to True and used the right COM port (in my case COM12). I had to do nothing else for the program to work. Here's a screenshot: image
WillChen0207 commented 2 years ago

Thank you, I believe that's the problem. I'll try later and thanks again.

Updated(28th July, 2022). I changed my settings and now the program runs well. Thanks!

thecountoftuscany commented 2 years ago

Sure no problem. Closing issue for now, feel free to reopen if it still doesn't work.

RafigRzayev commented 2 years ago

I changed following lines and it is working now: useSerial = False to useSerial = True

ser = serial.Serial('/dev/ttyUSB0', 38400) to ser = serial.Serial('COM6', 115200)

Thank you!