10#include <yarp/os/LogStream.h>
16YARP_LOG_COMPONENT(COUPLINGICUBHANDMK2,
"yarp.device.couplingICubHandMk2")
20 yarp::sig::VectorOf<size_t> coupled_physical_joints, coupled_actuated_axes;
21 coupled_physical_joints.resize(m_jointNames.size());
22 coupled_actuated_axes.resize(m_COUPLING_actuatedAxesNames.size());
23 std::iota(coupled_physical_joints.begin(), coupled_physical_joints.end(), 0);
24 std::iota(coupled_actuated_axes.begin(), coupled_actuated_axes.end(), 0);
25 std::vector<std::pair<double, double>> physical_joint_limits;
27 physical_joint_limits.resize(m_jointNames.size());
28 for (
int i = 0; i< m_jointNames.size(); i++)
30 physical_joint_limits[i] = std::make_pair(m_LIMITS_jntPosMin[i], m_LIMITS_jntPosMax[i]);
32 initialise(coupled_physical_joints, coupled_actuated_axes, m_jointNames, m_COUPLING_actuatedAxesNames, physical_joint_limits);
39 yCError(COUPLINGICUBHANDMK2) <<
"Error parsing parameters";
43 if(!populateCouplingParameters()) {
44 yCError(COUPLINGICUBHANDMK2) <<
"Error populating coupling parameters";
48 yCDebug(COUPLINGICUBHANDMK2) <<
"Opening CouplingICubHandMk2"<<config.toString();
53 size_t nrOfPhysicalJoints;
54 size_t nrOfActuatedAxes;
55 auto ok = getNrOfPhysicalJoints(nrOfPhysicalJoints);
56 ok =
ok && getNrOfActuatedAxes(nrOfActuatedAxes);
57 if (!
ok || physJointsPos.size() != nrOfPhysicalJoints || actAxesPos.size() != nrOfActuatedAxes) {
58 yCError(COUPLINGICUBHANDMK2) <<
"convertFromPhysicalJointsToActuatedAxesPos: input or output vectors have wrong size";
63 actAxesPos[0] = (20.0 - physJointsPos[12])*3;
65 actAxesPos[1] = physJointsPos[0];
67 actAxesPos[2] = physJointsPos[1];
69 actAxesPos[3] = physJointsPos[2] + physJointsPos[3];
71 actAxesPos[4] = physJointsPos[5];
73 actAxesPos[5] = physJointsPos[6] + physJointsPos[7];
75 actAxesPos[6] = physJointsPos[9];
77 actAxesPos[7] = physJointsPos[10] + physJointsPos[11];
79 actAxesPos[8] = physJointsPos[13] + physJointsPos[14] + physJointsPos[15];
84 size_t nrOfPhysicalJoints;
85 size_t nrOfActuatedAxes;
86 auto ok = getNrOfPhysicalJoints(nrOfPhysicalJoints);
87 ok =
ok && getNrOfActuatedAxes(nrOfActuatedAxes);
88 if (!
ok || physJointsVel.size() != nrOfPhysicalJoints || actAxesVel.size() != nrOfActuatedAxes) {
89 yCError(COUPLINGICUBHANDMK2) <<
"convertFromPhysicalJointsToActuatedAxesVel: input or output vectors have wrong size";
93 actAxesVel[0] = -physJointsVel[12]*3;
95 actAxesVel[1] = physJointsVel[0];
97 actAxesVel[2] = physJointsVel[1];
99 actAxesVel[3] = physJointsVel[2] + physJointsVel[3];
101 actAxesVel[4] = physJointsVel[5];
103 actAxesVel[5] = physJointsVel[6] + physJointsVel[7];
105 actAxesVel[6] = physJointsVel[9];
107 actAxesVel[7] = physJointsVel[10] + physJointsVel[11];
109 actAxesVel[8] = physJointsVel[13] + physJointsVel[14] + physJointsVel[15];
115 size_t nrOfPhysicalJoints;
116 size_t nrOfActuatedAxes;
117 auto ok = getNrOfPhysicalJoints(nrOfPhysicalJoints);
118 ok =
ok && getNrOfActuatedAxes(nrOfActuatedAxes);
119 if (!
ok || physJointsAcc.size() != nrOfPhysicalJoints || actAxesAcc.size() != nrOfActuatedAxes) {
120 yCError(COUPLINGICUBHANDMK2) <<
"convertFromPhysicalJointsToActuatedAxesAcc: input or output vectors have wrong size";
124 actAxesAcc[0] = -physJointsAcc[12]*3;
126 actAxesAcc[1] = physJointsAcc[0];
128 actAxesAcc[2] = physJointsAcc[1];
130 actAxesAcc[3] = physJointsAcc[2] + physJointsAcc[3];
132 actAxesAcc[4] = physJointsAcc[5];
134 actAxesAcc[5] = physJointsAcc[6] + physJointsAcc[7];
136 actAxesAcc[6] = physJointsAcc[9];
138 actAxesAcc[7] = physJointsAcc[10] + physJointsAcc[11];
140 actAxesAcc[8] = physJointsAcc[13] + physJointsAcc[14] + physJointsAcc[15];
150 size_t nrOfPhysicalJoints;
151 size_t nrOfActuatedAxes;
152 auto ok = getNrOfPhysicalJoints(nrOfPhysicalJoints);
153 ok =
ok && getNrOfActuatedAxes(nrOfActuatedAxes);
154 if (!
ok || physJointsPos.size() != nrOfPhysicalJoints || actAxesPos.size() != nrOfActuatedAxes) {
155 yCError(COUPLINGICUBHANDMK2) <<
"convertFromActuatedAxesToPhysicalJointsPos: input or output vectors have wrong size";
160 physJointsPos[0] = actAxesPos[1];
162 physJointsPos[1] = actAxesPos[2];
164 physJointsPos[2] = actAxesPos[3]/2;
166 physJointsPos[3] = actAxesPos[3]/2;
168 physJointsPos[4] = -(20.0 - actAxesPos[0]/3);
170 physJointsPos[5] = actAxesPos[4];
172 physJointsPos[6] = actAxesPos[5]/2;
174 physJointsPos[7] = actAxesPos[5]/2;
176 physJointsPos[8] = 0.0;
178 physJointsPos[9] = actAxesPos[6];
180 physJointsPos[10] = actAxesPos[7]/2;
182 physJointsPos[11] = actAxesPos[7]/2;
184 physJointsPos[12] = 20.0 - actAxesPos[0]/3;
186 physJointsPos[13] = actAxesPos[8]/3;
188 physJointsPos[14] = actAxesPos[8]/3;
190 physJointsPos[15] = actAxesPos[8]/3;
192 physJointsPos[16] = 20.0 - actAxesPos[0]/3;
194 physJointsPos[17] = actAxesPos[8]/3;
196 physJointsPos[18] = actAxesPos[8]/3;
198 physJointsPos[19] = actAxesPos[8]/3;
205 size_t nrOfPhysicalJoints;
206 size_t nrOfActuatedAxes;
207 auto ok = getNrOfPhysicalJoints(nrOfPhysicalJoints);
208 ok =
ok && getNrOfActuatedAxes(nrOfActuatedAxes);
209 if (!
ok || actAxesPos.size() != nrOfActuatedAxes || physJointsVel.size() != nrOfPhysicalJoints || actAxesVel.size() != nrOfActuatedAxes) {
210 yCError(COUPLINGICUBHANDMK2) <<
"convertFromPhysicalJointsToActuatedAxesVel: input or output vectors have wrong size";
215 physJointsVel[0] = actAxesVel[1];
217 physJointsVel[1] = actAxesVel[2];
219 physJointsVel[2] = actAxesVel[3]/2;
221 physJointsVel[3] = actAxesVel[3]/2;
223 physJointsVel[4] = actAxesVel[0]/3;
225 physJointsVel[5] = actAxesVel[4];
227 physJointsVel[6] = actAxesVel[5]/2;
229 physJointsVel[7] = actAxesVel[5]/2;
231 physJointsVel[8] = 0.0;
233 physJointsVel[9] = actAxesVel[6];
235 physJointsVel[10] = actAxesVel[7]/2;
237 physJointsVel[11] = actAxesVel[7]/2;
239 physJointsVel[12] = -actAxesVel[0]/3;
241 physJointsVel[13] = actAxesVel[8]/3;
243 physJointsVel[14] = actAxesVel[8]/3;
245 physJointsVel[15] = actAxesVel[8]/3;
247 physJointsVel[16] = - actAxesVel[0]/3;
249 physJointsVel[17] = actAxesVel[8]/3;
251 physJointsVel[18] = actAxesVel[8]/3;
253 physJointsVel[19] = actAxesVel[8]/3;
259 size_t nrOfPhysicalJoints;
260 size_t nrOfActuatedAxes;
261 auto ok = getNrOfPhysicalJoints(nrOfPhysicalJoints);
262 ok =
ok && getNrOfActuatedAxes(nrOfActuatedAxes);
263 if (!
ok || actAxesPos.size() != nrOfActuatedAxes || physJointsAcc.size() != nrOfPhysicalJoints || actAxesAcc.size() != nrOfActuatedAxes) {
264 yCError(COUPLINGICUBHANDMK2) <<
"convertFromPhysicalJointsToActuatedAxesAcc: input or output vectors have wrong size";
269 physJointsAcc[0] = actAxesAcc[1];
271 physJointsAcc[1] = actAxesAcc[2];
273 physJointsAcc[2] = actAxesAcc[3]/2;
275 physJointsAcc[3] = actAxesAcc[3]/2;
277 physJointsAcc[4] = actAxesAcc[0]/3;
279 physJointsAcc[5] = actAxesAcc[4];
281 physJointsAcc[6] = actAxesAcc[5]/2;
283 physJointsAcc[7] = actAxesAcc[5]/2;
285 physJointsAcc[8] = 0.0;
287 physJointsAcc[9] = actAxesAcc[6];
289 physJointsAcc[10] = actAxesAcc[7]/2;
291 physJointsAcc[11] = actAxesAcc[7]/2;
293 physJointsAcc[12] = - actAxesAcc[0]/3;
295 physJointsAcc[13] = actAxesAcc[8]/3;
297 physJointsAcc[14] = actAxesAcc[8]/3;
299 physJointsAcc[15] = actAxesAcc[8]/3;
301 physJointsAcc[16] = - actAxesAcc[0]/3;
303 physJointsAcc[17] = actAxesAcc[8]/3;
305 physJointsAcc[18] = actAxesAcc[8]/3;
307 physJointsAcc[19] = actAxesAcc[8]/3;
bool parseParams(const yarp::os::Searchable &config) override
bool convertFromActuatedAxesToPhysicalJointsPos(const yarp::sig::Vector &actAxesPos, yarp::sig::Vector &physJointsPos) override
bool convertFromActuatedAxesToPhysicalJointsAcc(const yarp::sig::Vector &actAxesPos, const yarp::sig::Vector &actAxesVel, const yarp::sig::Vector &actAxesAcc, yarp::sig::Vector &physJointsAcc) override
bool convertFromPhysicalJointsToActuatedAxesPos(const yarp::sig::Vector &physJointsPos, yarp::sig::Vector &actAxesPos) override
bool convertFromActuatedAxesToPhysicalJointsTrq(const yarp::sig::Vector &actAxesPos, const yarp::sig::Vector &actAxesTrq, yarp::sig::Vector &physJointsTrq) override
bool convertFromPhysicalJointsToActuatedAxesVel(const yarp::sig::Vector &physJointsPos, const yarp::sig::Vector &physJointsVel, yarp::sig::Vector &actAxesVel) override
bool convertFromPhysicalJointsToActuatedAxesAcc(const yarp::sig::Vector &physJointsPos, const yarp::sig::Vector &physJointsVel, const yarp::sig::Vector &physJointsAcc, yarp::sig::Vector &actAxesAcc) override
bool open(yarp::os::Searchable &config) override
Configure with a set of options.
bool convertFromActuatedAxesToPhysicalJointsVel(const yarp::sig::Vector &actAxesPos, const yarp::sig::Vector &actAxesVel, yarp::sig::Vector &physJointsVel) override
bool convertFromPhysicalJointsToActuatedAxesTrq(const yarp::sig::Vector &physJointsPos, const yarp::sig::Vector &physJointsTrq, yarp::sig::Vector &actAxesTrq) override