myCobot
                                
                                
                                
                                    myCobot copied to clipboard
                            
                            
                            
                        AtomMain 2.8.1 has broken Encoder Values
In 2.8.1 Atom Main, the encoder values are not updating or just wrong.
The following code will not show correct encoder values:
for (int i = 0; i < 6; i++)
{
    angles.joint_angle[i] = m_mycobotBasic.getEncoder(i + 1);
}
It can also be reproduced by flashing the latest MainControl app into Basic and trying to record and replay a motion. The replaying will not work and move to random poses instead of the expected track.
The bug seems to have been introduced with 2.8.1. Version 2.8 is working properly.
Please try Atom2.8
That is more reliable but also sometimes gives me -1 for encoder values.
I currently workaround it by trying to read the value up to 3 times which is more robust. However, this interferes with timing.
The reason for -1 is that the serial port does not read the data, which may be read too fast. So that the serial port can't react.
If you are reading data continuously, you can skip them when you get [] or -1.
I'm technically using the code you're using for teaching in the MainControl application. This code has the same issue with Atom 2.8. It is not visible because some of the next measurements will have correct values and -1 are ignored when commanding.
How can I make sure that I do not send too fast?
BTW: I'm programming on the Basic controller directly adapting the MainControl application
I am sorry, maybe I didn't find out. where you get  the -1?
m_mycobotBasic.getEncoder(i + 1);
here?
Yes, this function seems to return -1.
OK. The reason is that valid data cannot be read. I think you just need to skip -1.
API will only throw out the possible existence of wrong data, and the user will deal with this situation.😊
Possibly relates https://github.com/elephantrobotics/pymycobot/issues/17