Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I got an error in the "set_end_effector_params()" function #1

Open
hoshianaaa opened this issue Feb 16, 2021 · 4 comments
Open

I got an error in the "set_end_effector_params()" function #1

hoshianaaa opened this issue Feb 16, 2021 · 4 comments

Comments

@hoshianaaa
Copy link

hoshianaaa commented Feb 16, 2021

I added bot.set_end_effector_params (60,0,0) in homing.py.
When I ran it, I got the following error:

Traceback (most recent call last):
File "examples/homing.py", line 17, in
bot.set_end_effector_params(60, 0, 0)
File "/home/hoshina/dobot-python/lib/interface.py", line 130, in set_end_effector_params
request = Message([0xAA, 0xAA], 2, 60, True, False, [bias_x, bias_y, bias_z], direction='out')
File "/home/hoshina/dobot-python/lib/message.py", line 19, in init
self.raw_params = self.parse_params('out')
File "/home/hoshina/dobot-python/lib/message.py", line 95, in parse_params
return parser(self.params)
File "/home/hoshina/dobot-python/lib/parsers.py", line 43, in
60: [lambda x: struct.unpack('<' + 'f' * 3, bytearray(x)), None, lambda x: struct.unpack('<Q', bytearray(x))[0], lambda x: list(struct.pack('<' + 'f' * 4, *x))],
struct.error: pack expected 4 items for packing (got 3)`

Do you know how to fix the error?

@AlexGustafsson
Copy link
Owner

I think this is one of the functions that weren't very well documented in the official documentation for the low-level API.

There might be an error here:

60: [lambda x: struct.unpack('<' + 'f' * 3, bytearray(x)), None, lambda x: struct.unpack('<Q', bytearray(x))[0], lambda x: list(struct.pack('<' + 'f' * 4, *x))],
.

The set_end_effector_params only seem to be intended to take three parameters, but the parser expects four.

Try to modify lib/parsers.py, line 43 to use 'f' * 3 instead of 'f' * 4:

- 60: [lambda x: struct.unpack('<' + 'f' * 3, bytearray(x)), None, lambda x: struct.unpack('<Q', bytearray(x))[0], lambda x: list(struct.pack('<' + 'f' * 4, *x))],
+ 60: [lambda x: struct.unpack('<' + 'f' * 3, bytearray(x)), None, lambda x: struct.unpack('<Q', bytearray(x))[0], lambda x: list(struct.pack('<' + 'f' * 3, *x))],

@hoshianaaa
Copy link
Author

hoshianaaa commented Feb 18, 2021

Thank you for your reply.
When I tried it, But I got the following error:

Traceback (most recent call last):
File "examples/homing.py", line 17, in
bot.set_end_effector_params(60, 0, 0)
File "/home/hoshina/dobot-python/lib/interface.py", line 131, in set_end_effector_params
return self.send(request)
File "/home/hoshina/dobot-python/lib/interface.py", line 24, in send
response = Message.read(self.serial)
File "/home/hoshina/dobot-python/lib/message.py", line 63, in read
return Message.parse(header + bytes([length]) + payload + checksum)
File "/home/hoshina/dobot-python/lib/message.py", line 50, in parse
return Message(header, length, id, rw, is_queued, params)
File "/home/hoshina/dobot-python/lib/message.py", line 16, in init
self.params = self.parse_params('in')
File "/home/hoshina/dobot-python/lib/message.py", line 83, in parse_params
return parser(self.raw_params)
File "/home/hoshina/dobot-python/lib/parsers.py", line 43, in
60: [lambda x: struct.unpack('<' + 'f' * 3, bytearray(x)), None, lambda x: struct.unpack('<Q', bytearray(x))[0], lambda x: list(struct.pack('<' + 'f' * 3, *x))],
struct.error: unpack requires a buffer of 12 bytes

@hoshianaaa
Copy link
Author

After that, Dobot Magician froze and stopped working without restarting the power supply.

@AlexGustafsson
Copy link
Owner

Unfortunately this seems to be an instance where the documentation didn't match reality, and I wasn't able to properly test the functionality. I don't have my hands on a robot right now. If you have the time and interest, the documentation I used to implement the functionality is available here: https://download.dobot.cc/product-manual/dobot-magician/pdf/en/Dobot-Communication-Protocol-V1.1.5.pdf.

With some trial and error, you may find how set_end_effector_params should actually be called and fix the mistake in this library.

I'll keep this open, but for now I won't be able to be much of help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants