Skip to content

Commit 1ebd2f3

Browse files
committedFeb 27, 2024
ControlBoardCouplingHandler: configure buffers
1 parent f692af4 commit 1ebd2f3

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed
 

‎src/devices/controlBoardCouplingHandler/ControlBoardCouplingHandler.cpp

+23-4
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ bool ControlBoardCouplingHandler::open(Searchable& config)
4747
return false;
4848
}
4949

50-
this->setNrOfControlledAxes(m_axesNames.size());
50+
configureBuffers();
5151

5252
Property prop;
5353
prop.fromString(config.toString());
@@ -85,6 +85,28 @@ struct axisLocation
8585
int indexInSubDevice;
8686
};
8787

88+
void ControlBoardCouplingHandler::configureBuffers() {
89+
if (!iJntCoupling) {
90+
yCError(CONTROLBOARDCOUPLINGHANDLER) << "IJointCoupling interface not available";
91+
return;
92+
}
93+
size_t nrOfPhysicalJoints;
94+
size_t nrOfActuatedAxes;
95+
auto ok = iJntCoupling->getNrOfPhysicalJoints(nrOfPhysicalJoints);
96+
ok = ok && iJntCoupling->getNrOfActuatedAxes(nrOfActuatedAxes);
97+
if(!ok)
98+
{
99+
yCError(CONTROLBOARDCOUPLINGHANDLER) << "Error in getting the number of physical joints or actuated axes";
100+
return;
101+
}
102+
physJointsPos.resize(nrOfPhysicalJoints);
103+
physJointsVel.resize(nrOfPhysicalJoints);
104+
physJointsAcc.resize(nrOfPhysicalJoints);
105+
actAxesPos.resize(nrOfActuatedAxes);
106+
actAxesVel.resize(nrOfActuatedAxes);
107+
actAxesAcc.resize(nrOfActuatedAxes);
108+
return;
109+
}
88110

89111
bool ControlBoardCouplingHandler::attachAllUsingAxesNames(const PolyDriverList& polylist)
90112
{
@@ -198,9 +220,6 @@ bool ControlBoardCouplingHandler::detachAll()
198220
return true;
199221
}
200222

201-
void ControlBoardCouplingHandler::configureBuffers()
202-
{
203-
}
204223

205224
//////////////////////////////////////////////////////////////////////////////
206225
/// ControlBoard methods

‎src/devices/controlBoardCouplingHandler/ControlBoardCouplingHandler.h

+6-9
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,19 @@ class ControlBoardCouplingHandler :
4040
yarp::dev::IAxisInfo *info;
4141
yarp::dev::IJointCoupling *iJntCoupling;
4242

43-
std::vector<std::string> axesNames;
43+
yarp::sig::Vector physJointsPos;
44+
yarp::sig::Vector physJointsVel;
45+
yarp::sig::Vector physJointsAcc;
46+
yarp::sig::Vector actAxesPos;
47+
yarp::sig::Vector actAxesVel;
48+
yarp::sig::Vector actAxesAcc;
4449

4550
/** Verbosity of the class */
4651
bool _verb{false};
4752

4853
// to open ports and print more detailed debug messages
4954
std::string partName;
5055

51-
/**
52-
* Set the number of controlled axes, resizing appropriately
53-
* all the necessary buffers.
54-
*/
55-
void setNrOfControlledAxes(const size_t nrOfControlledAxes);
56-
57-
// TODO I am keeping it just for compiling, but it should be removed
58-
5956
/**
6057
* Configure buffers used by the device
6158
*/

0 commit comments

Comments
 (0)