resibots / libdynamixel

C++ interface to the dynamixel actuators
GNU General Public License v2.0
9 stars 15 forks source link

Bulk/sync operations with Protocol2 #56

Open Aneoshun opened 5 years ago

Aneoshun commented 5 years ago

Hi all,

I am using X-series XM430-350 for my new hexapod robot. Following what I did in the past, I want to update the positions of my motors in one go, using bulk/sync operations. I see that it is not yet fully implemented in libdynamixel (it is for Protocol1, but not the 2), and I see as well that there are some current changes in this direction (a few recent commits in this direction, but mainly targeted to MX series).

My question is: What are your plans/timeline? How can I help/implement stuff without interfering? (Not sure I fully understand the structure of LibDynamixel, it seems that it changed a lot since the last time I had a look in this code).

PedroDesRobots commented 5 years ago

Hello @Aneoshun, Actually the libdynamixel is not yet fully implemented but we continue to upgrade it.

I'm working on using bulk/sync operations with protocol1 and 2 with all the servos but it 's not an easy part. For the moment, bulk/sync works only with MX models and protocol 1. I need to do more test and trials for protocol 2. I will create a branch called "bulk/sync" for this update.

After some analysis on MX28, the bulk_read function increases the frequency communication significantly but the sync_write function decreases the frequency, it's better to use reg_write. If you want more information on my tests let me know.

Aneoshun commented 5 years ago

Hi @PedroDesRobots Thanks for your reply.

I am surprised to read that it decreases the frequency. I wish to control 18 XM430 servos (like in the resibot hexapod) and sending the position one-by-one via reg_write seems to be way too slow (in particular waiting for the status of each motor). I am looking to use set_goal_positions, like I did in the past with protocol 1, but I had issues porting this to protocol2.

Please let me know if I can help you or tests things from my side.

Best,

PedroDesRobots commented 5 years ago

Hello @Aneoshun,

I got some good news. I have fully implemented bulk_read and sync_write for protocol 1 and 2. I tested it on MX28 (protocol 1) and XM430W350 (protocol 2), it works well for me. So lets me know if it works well for you too, you can switch on the branch "dev" (where the update is done). you can use "get_current_positions_XM" (bulk_read) and "set_goal_positions" (sync_write) in servo.hpp

example in utility.hpp : std::make_shared<servos::Xm430W350>(0)->set_goal_positions<id_t, double>(ids, angles)) std::make_shared<servos::Xm430W350>(0)->get_current_positions_XM(ids)

If it works well, I will ask for a PR on the master branch.

Like I said before, sync_write decreases the frequency but it's clearly more synchronized than reg_write. It's a trade-off to find and it could probably change from a firmware version to another... Concerning our hexapod, I tried both reg_write (resulting freq 300 Hz) and sync_write (resulting freq 35 Hz....). I invited you to test both on your hexapod and compare.

Now, the resibot hexapod is able to reach a frequency around 300Hz with 18 MX28 servos (with 3MBauds and 0 latency_timer).

Aneoshun commented 5 years ago

Awesome. I will check later this afternoon.

Aneoshun commented 5 years ago

I just had a quick test on my hexapod, and it works like I expected. Thank you very much.

As the sync_read/write instructions are broadcasted, it disables the production of status packets if I am correct, therefore, I can go quite fast in term of frequency. (I tried up to 500hz, without seeing a difference in my robot's behavior). What is the limiting aspect from your side?

mrunaljsarvaiya commented 3 years ago

Does there happen to be an implemented bulk read function for present current?