darwinop/webots-cross-compilation — Issue #8: SYNC_WRITE within webots wrappers
Author: vmatos
Created: 2012-02-09 17:12:01+00:00
State: open

Hello,
It is my intention of discussing this matter openly, so that someone who might have an idea can join us.

Each write and read to the servos seems to suffer some kind of 1ms overhead, from my experience.
So, if one chooses to setPosition() all the servos inside a 'for' cycle, it will take 20 individual WRITE position commands, 1 for each servo. This kind of 'for' cycle will take around 30 ms.

On the other hand, if we create a sync write command, the write commands for the servos will be serialized, and there will be no overhead.
I've tested this, and it seems that it doesn't even take 1ms. Which I find it strange, maybe I'm not timing correctly the sync write.

I'll write about these timing issues in robotsource.org

@fabienrohrer ,
How could we create a SYNC_WRITE command within the webots wrappers?
We need to fill in a packet with all the joint positions, and then send the packet.
Pseudo code follows (example code is in my sync_write branch):
```
for(i=1:all servos) {
packet[n++] = id
packet[n++] = value low byte
packet[n++] = value high byte
}
send packet
```
Therefore Servo::setPosition() would not send a write command with the joint value, maybe could only update a position table?
What would then trigger the sync write?

How could this be integrated in the Webots API without introducing changes to the API itself?