ability-hand-api icon indicating copy to clipboard operation
ability-hand-api copied to clipboard

Add Multiple Hand Control Via RS485 Bus

Open TomaszTB opened this issue 7 months ago • 1 comments

We connected two hands to a single USB to RS485 adapter with the hope to control both hands by read/writing to one, then the other sequentially.

We tried something like the following using the C++ API, but it did not work.

AHWrapper wrapperLeft = AHWrapper(0x50, 460800);
wrapperLeft.connect();

AHWrapper wrapperRight = AHWrapper(0x51, 460800);
wrapperRight.connect();

while (running) {
    wrapperLeft.read_write_once(/* params */);
    wrapperLeft.read_write_once(/* params */);
}

We looked into the code and found that connect() should only be called once, regardless of how many AHWrappers are instantiated. E.g.:

AHWrapper wrapperLeft = AHWrapper(0x50, 460800);
AHWrapper wrapperRight = AHWrapper(0x51, 460800);
wrapperRight.connect();

while (running) {
    wrapperLeft.read_write_once(/* params */);
    wrapperLeft.read_write_once(/* params */);
}

While this works, the API is not intuitive for controlling multiple hands, and we're not sure of the behavior when the AHWrapper destructor is called multiple times. It seems fairly simple to fix by making the connect function static and adding a disconnect function.

TomaszTB avatar Jun 12 '25 20:06 TomaszTB