elephantrobotics / pymycobot

This is a python API for ElephantRobotics product.
MIT License
106 stars 52 forks source link

does set_fresh_mode=1 execute only the latest command (clearing the queue)? #69

Open Jonas-Metzger opened 1 week ago

Jonas-Metzger commented 1 week ago

Hi, based on your docs, and looking how the robot seems to respond to instructions, it seems that

set_fresh_mode=0 is executing the 'command queue' in a first-in-first-out fashion.

and

set_fresh_mode=1 is executing the most recent command first, but not clearing the queue, so it may subsequently execute commands that were sent earlier. This can result in a jittering movement if the commands are sent at too high a frequency.

In my application, I would love to have the robot only execute the most recent command, and ignore/drop all commands of the same type (i.e. joint_radians or gripper_state) that were sent earlier -- never executing them. This will make it always move to the most recent target state, and prevent jittering, regardless of the frequency at which I send my commands. The robot could be controlled in a much more responsive way.

Is there a way to clear the queue manually? Then I could manually implement this functionality by always clearing the queue before I send a new command.

Thank you for your help!

anla-xu commented 1 week ago

Set set_fresh_mode=1, the robot will execute the latest received command and clear the previously received commands. Does this setting not meet your needs?