myCobot icon indicating copy to clipboard operation
myCobot copied to clipboard

AtomMain 2.8.1 has broken Encoder Values

Open peteh opened this issue 4 years ago • 8 comments

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.

peteh avatar May 29 '21 15:05 peteh

Please try Atom2.8

zlj-zz avatar Jun 01 '21 15:06 zlj-zz

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.

peteh avatar Jun 03 '21 01:06 peteh

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.

zlj-zz avatar Jun 03 '21 09:06 zlj-zz

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

peteh avatar Jun 03 '21 16:06 peteh

I am sorry, maybe I didn't find out. where you get the -1?

m_mycobotBasic.getEncoder(i + 1);

here?

zlj-zz avatar Jun 04 '21 08:06 zlj-zz

Yes, this function seems to return -1.

peteh avatar Jun 04 '21 14:06 peteh

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.😊

zlj-zz avatar Jun 04 '21 19:06 zlj-zz

Possibly relates https://github.com/elephantrobotics/pymycobot/issues/17

eacousineau avatar Jun 25 '21 21:06 eacousineau