You could just do 
```
const StateSpacePtr &so2 = si->getStateSpace()->as<CompoundStateSpace>()->getSubspace(1);
samplerSO2 = si->getStateSpace()->allocSubspaceStateSampler(so2);
```