16 #include <robottestingframework/TestAssert.h>
58 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(
dd->
isValid(),
"Unable to open device driver");
59 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(
dd->
view(
ienc),
"Unable to open encoders interface");
60 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(
dd->
view(
ipos),
"Unable to open position interface");
61 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(
dd->
view(
icmd),
"Unable to open control mode interface");
62 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(
dd->
view(
iimd),
"Unable to open interaction mode interface");
63 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(
dd->
view(
ilim),
"Unable to open limits interface");
69 for(
size_t i = 0; i < n_joints; i++) {
70 if(jointsList[i] == j) {
74 return jointsList.size()+1;
80 max_lims.resize(n_joints);
81 min_lims.resize(n_joints);
82 for (
size_t i = 0; i < n_joints; i++) {
83 ilim->getLimits((
int)jointsList[i], &min_lims[i], &max_lims[i]);
93 mPriv->
init(polydriver);
103 for (
size_t i = 0; i < mPriv->
n_joints; i++) {
119 mPriv->tolerance = tolerance;
125 for (
size_t i = 0; i < mPriv->jointsList.size(); i++) {
127 mPriv->iimd->setInteractionMode((
int)mPriv->jointsList[i],
VOCAB_IM_STIFF);
137 for (
size_t i = 0; i < mPriv->n_joints; i++) {
138 mPriv->icmd->getControlMode ((
int)mPriv->jointsList[i], &cmode);
139 mPriv->iimd->getInteractionMode((
int)mPriv->jointsList[i], &imode);
144 if (ok == mPriv->n_joints) {
148 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR(
"Unable to set control mode/interaction mode");
161 mPriv->timeout = timeout;
168 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE((speedlist.
size() != mPriv->jointsList.size()),
"Speed list has a different size of joint list");
169 mPriv->speed = speedlist;
170 for (
size_t i = 0; i < mPriv->n_joints; i++) {
171 mPriv->ipos->setRefSpeed((
int)mPriv->jointsList[i], mPriv->speed[i]);
178 size_t i = mPriv->getIndexOfJoint(j);
179 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(i < mPriv->n_joints,
"Cannot move a joint not in list.");
181 mPriv->ipos->positionMove((
int)mPriv->jointsList[i], pos);
187 mPriv->ienc->getEncoder((
int)mPriv->jointsList[i], &tmp);
188 if (fabs(tmp-pos)<mPriv->tolerance) {
200 if(reached_pos !=
nullptr) {
209 for (
unsigned int i=0; i<mPriv->n_joints; i++) {
210 mPriv->ipos->positionMove((
int)mPriv->jointsList[i], positions[i]);
218 size_t in_position = 0;
219 for (
size_t i = 0; i < mPriv->n_joints; i++) {
220 mPriv->ienc->getEncoder((
int)mPriv->jointsList[i], &tmp[i]);
221 if (fabs(tmp[i]-positions[i])<mPriv->tolerance)
224 if (in_position == mPriv->n_joints)
234 if(reached_pos !=
nullptr) {
235 reached_pos->
resize(mPriv->n_joints);
245 size_t i = mPriv->getIndexOfJoint(j);
247 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(i < mPriv->n_joints,
"Cannot move a joint not in list.");
250 mPriv->ienc->getEncoder((
int)mPriv->jointsList[i], &enc);
251 if (fabs(enc-mPriv->max_lims[i]) < mPriv->tolerance ||
252 fabs(enc-mPriv->min_lims[i]) < mPriv->tolerance ) {