Closed RafigRzayev closed 2 years ago
Same problem, please help us
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?
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
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?
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?
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):
pip install pygame PyOpenGL PySerial
COM11
(Tx), COM12
(Rx)) on Windows.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()
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:
Updated(28th July, 2022). I changed my settings and now the program runs well. Thanks!
Sure no problem. Closing issue for now, feel free to reopen if it still doesn't work.
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!
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:
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?