Skip to content

Commit

Permalink
use explicit prefix+suffix on ports
Browse files Browse the repository at this point in the history
  • Loading branch information
jgvictores committed Jan 21, 2020
1 parent 9fc1e41 commit f006bb0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 29 deletions.
24 changes: 13 additions & 11 deletions libraries/YarpPlugins/RealToSimControlboard/DeviceDriverImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ bool RealToSimControlboard::open(yarp::os::Searchable& config)
}
CD_DEBUG("%s\n", controlledDeviceList->toString().c_str());

std::string name = config.find("name").asString();
std::string remotePrefix;
if(config.check("remotePrefix", "global prefix to remote ports"))
{
remotePrefix = config.find("remotePrefix").asString();
}

std::map<std::string,int> controlledDeviceNameToIdx;
for(size_t controlledDeviceIdx=0; controlledDeviceIdx< controlledDeviceList->size(); controlledDeviceIdx++)
Expand All @@ -43,18 +47,16 @@ bool RealToSimControlboard::open(yarp::os::Searchable& config)
yarp::os::Property controlledDeviceOptions;
controlledDeviceOptions.fromString(controlledDeviceGroup.toString());

if(controlledDeviceOptions.check("remote"))
if(controlledDeviceOptions.check("remoteSuffix", "suffix used for local and remote of each remote_controlboard"))
{
std::string remote(name);
remote += controlledDeviceOptions.find("remote").asString();
controlledDeviceOptions.unput("remote");
std::string remote(remotePrefix);
remote += controlledDeviceOptions.find("remoteSuffix").asString();
controlledDeviceOptions.unput("remoteSuffix");
controlledDeviceOptions.put("remote",remote);
}
if(controlledDeviceOptions.check("local"))
{
std::string local(name);
local += controlledDeviceOptions.find("local").asString();
controlledDeviceOptions.unput("local");

std::string local(remotePrefix);
local += controlledDeviceOptions.find("localSuffix").asString();
controlledDeviceOptions.unput("localSuffix");
controlledDeviceOptions.put("local",local);
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/YarpPlugins/RealToSimControlboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ teoSim dextra
```

```bash
yarpdev --device RealToSimControlboard --context RealToSimControlboard --from leftDextra.ini --name /teoSim/leftDextra
yarpdev --device RealToSimControlboard --context RealToSimControlboard --from leftDextra.ini --name /teoSim/leftHand --remotePrefix /teoSim/leftDextra
```

## Example with Lacquey Fetch
Expand All @@ -37,5 +37,5 @@ teoSim
```

```bash
yarpdev --device RealToSimControlboard --context RealToSimControlboard --from lacqueyFetch.ini --name /teoSim/leftLacqueyFetch
yarpdev --device RealToSimControlboard --context RealToSimControlboard --from lacqueyFetch.ini --name /teoSim/leftHand --remotePrefix /teoSim/leftLacqueyFetch
```
14 changes: 8 additions & 6 deletions share/contexts/RealToSimControlboard/lacqueyFetch.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@
name /lacqueyFetch
period 60

remotePrefix /lacqueyFetch

remotes (externalFinger internalFinger thumb)

[externalFinger]
device remote_controlboard
local /realToSimControlboard/externalFinger
remote /externalFinger
localSuffix /realToSimControlboard/externalFinger
remoteSuffix /externalFinger

[internalFinger]
device remote_controlboard
local /realToSimControlboard/internalFinger
remote /internalFinger
localSuffix /realToSimControlboard/internalFinger
remoteSuffix /internalFinger

[thumb]
device remote_controlboard
local /realToSimControlboard/thumb
remote /thumb
localSuffix /realToSimControlboard/thumb
remoteSuffix /thumb

[exposed_joint_0]
externalFinger (joint 0 transformation linear m 1 b 0)
Expand Down
22 changes: 12 additions & 10 deletions share/contexts/RealToSimControlboard/leftDextra.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,34 @@
name /leftDextra
period 60

remotePrefix /leftDextra

remotes (thumb index middle ring pinky)

[thumb]
device remote_controlboard
local /realToSimControlboard/thumb
remote /thumb
localSuffix /realToSimControlboard/thumb
remoteSuffix /thumb

[index]
device remote_controlboard
local /realToSimControlboard/index
remote /index
localSuffix /realToSimControlboard/index
remoteSuffix /index

[middle]
device remote_controlboard
local /realToSimControlboard/middle
remote /middle
localSuffix /realToSimControlboard/middle
remoteSuffix /middle

[ring]
device remote_controlboard
local /realToSimControlboard/ring
remote /ring
localSuffix /realToSimControlboard/ring
remoteSuffix /ring

[pinky]
device remote_controlboard
local /realToSimControlboard/pinky
remote /pinky
localSuffix /realToSimControlboard/pinky
remoteSuffix /pinky

[exposed_joint_0]
thumb (joint 0 transformation linear m 1 b 0)
Expand Down

0 comments on commit f006bb0

Please sign in to comment.