icub-test
Loading...
Searching...
No Matches
Public Member Functions
CartesianControlReachingToleranceTest Class Reference

This test verifies the point-to-point cartesian movement. More...

#include <CartesianControlReachingToleranceTest.h>

Inherits yarp::robottestingframework::TestCase.

Public Member Functions

virtual bool setup (yarp::os::Property &property)
 
virtual void tearDown ()
 
virtual void run ()
 

Detailed Description

This test verifies the point-to-point cartesian movement.

Accepts the following parameters:

Parameter name Type Units Default Value Required Description Notes
robot string - icubSim No robot name -
arm-type string - left No left or right -

Definition at line 40 of file CartesianControlReachingToleranceTest.h.

Constructor & Destructor Documentation

◆ CartesianControlReachingToleranceTest()

CartesianControlReachingToleranceTest::CartesianControlReachingToleranceTest ( )

Definition at line 44 of file CartesianControlReachingToleranceTest.cpp.

44 :
45 yarp::robottestingframework::TestCase("CartesianControlReachingToleranceTest")
46{
47}

◆ ~CartesianControlReachingToleranceTest()

CartesianControlReachingToleranceTest::~CartesianControlReachingToleranceTest ( )
virtual

Definition at line 51 of file CartesianControlReachingToleranceTest.cpp.

52{
53}

Member Function Documentation

◆ run()

void CartesianControlReachingToleranceTest::run ( )
virtual

Definition at line 116 of file CartesianControlReachingToleranceTest.cpp.

117{
118 ICartesianControl *iarm;
119 ROBOTTESTINGFRAMEWORK_TEST_CHECK(drvCart.view(iarm),"Opening the view on the Cartesian device!");
120
121 IEncoders *ienc;
122 ROBOTTESTINGFRAMEWORK_TEST_CHECK(drvJoint.view(ienc),"Opening the view on the Joint device!");
123
124 bool done;
125
126 Vector x,o;
127 double t0=Time::now();
128 while (Time::now()-t0<5.0)
129 {
130 done=iarm->getPose(x,o);
131 if (done)
132 break;
133 Time::delay(0.1);
134 }
135 ROBOTTESTINGFRAMEWORK_TEST_CHECK(done,"Initial pose retrieved!");
136
137 ROBOTTESTINGFRAMEWORK_TEST_REPORT("Setting up the context");
138 int context;
139 iarm->storeContext(&context);
140
141 Vector dof;
142 iarm->getDOF(dof); dof=1.0;
143 dof[0]=dof[1]=dof[2]=0.0;
144 iarm->setDOF(dof,dof);
145 iarm->setTrajTime(1.0);
146 iarm->setInTargetTol(0.02);
147
148 double tol;
149 iarm->getInTargetTol(&tol);
150
151 Vector pos2reach(3,0.0);
152 pos2reach[0]=-0.35;
153 pos2reach[1]=0.0;
154 pos2reach[2]=0.15;
155
156 Matrix dcm2reach=zeros(3,3);
157 dcm2reach(0,0)=dcm2reach(2,1)=dcm2reach(1,2)=-1.0;
158 Vector ori2reach=dcm2axis(dcm2reach);
159
160 ROBOTTESTINGFRAMEWORK_TEST_REPORT(Asserter::format("Reaching for the target: (%s, %s)",
161 pos2reach.toString(3,3).c_str(),ori2reach.toString(3,3).c_str()));
162 Vector xh,oh,qh;
163 iarm->goToPoseSync(pos2reach,ori2reach);
164 iarm->getDesired(xh,oh,qh);
165
166 ROBOTTESTINGFRAMEWORK_TEST_REPORT("Waiting");
167 done=iarm->waitMotionDone(0.1,10.0);
168 iarm->stopControl();
169
170 Vector xf,of;
171 iarm->getPose(xf,of);
172
173 int nJoints;
174 ienc->getAxes(&nJoints);
175 Vector qf(nJoints);
176 ienc->getEncoders(qf.data());
177
178 ROBOTTESTINGFRAMEWORK_TEST_CHECK(done,"Target reached!");
179 ROBOTTESTINGFRAMEWORK_TEST_REPORT(Asserter::format("Reaching tolerance: %g",tol));
180 ROBOTTESTINGFRAMEWORK_TEST_REPORT(Asserter::format("Solved pose: (%s, %s)",
181 xh.toString(3,3).c_str(),oh.toString(3,3).c_str()));
182 ROBOTTESTINGFRAMEWORK_TEST_REPORT(Asserter::format("Reached pose: (%s, %s)",
183 xf.toString(3,3).c_str(),of.toString(3,3).c_str()));
184 ROBOTTESTINGFRAMEWORK_TEST_REPORT(Asserter::format("Solved joints qh: (%s)",
185 qh.subVector(3,dof.length()-1).toString(3,3).c_str()));
186 ROBOTTESTINGFRAMEWORK_TEST_REPORT(Asserter::format("Reached joints qf: (%s)",
187 qf.subVector(0,6).toString(3,3).c_str()));
188 ROBOTTESTINGFRAMEWORK_TEST_REPORT(Asserter::format("Error: %g",compute_error(xh,oh,xf,of)));
189
190 ROBOTTESTINGFRAMEWORK_TEST_REPORT("Going back to starting pose");
191 iarm->goToPoseSync(x,o);
192
193 ROBOTTESTINGFRAMEWORK_TEST_REPORT("Waiting");
194 done=iarm->waitMotionDone(1.0,5.0);
195 ROBOTTESTINGFRAMEWORK_TEST_CHECK(done,"Starting pose reached!");
196
197 ROBOTTESTINGFRAMEWORK_TEST_REPORT("Cleaning up the context");
198 iarm->restoreContext(context);
199 iarm->deleteContext(context);
200}

◆ setup()

bool CartesianControlReachingToleranceTest::setup ( yarp::os::Property &  property)
virtual

Definition at line 57 of file CartesianControlReachingToleranceTest.cpp.

58{
59 string robot=property.check("robot",Value("icubSim")).asString();
60 string arm=property.check("arm-type",Value("left")).asString();
61
62 Property optCart;
63 optCart.put("device","cartesiancontrollerclient");
64 optCart.put("remote",("/"+robot+"/"+"cartesianController/"+arm+"_arm"));
65 optCart.put("local",("/"+getName()+"/cartesian/"+arm+"_arm"));
66
67 Property optJoint;
68 optJoint.put("device","remote_controlboard");
69 optJoint.put("remote",("/"+robot+"/"+arm+"_arm"));
70 optJoint.put("local",("/"+getName()+"/joint/"+arm+"_arm"));
71
72 ROBOTTESTINGFRAMEWORK_TEST_REPORT(Asserter::format("Opening Cartesian Controller Client for %s_arm",arm.c_str()));
73 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(drvCart.open(optCart),"Unable to open the client!");
74
75 ROBOTTESTINGFRAMEWORK_TEST_REPORT(Asserter::format("Opening Joint Controller Client for %s_arm",arm.c_str()));
76 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(drvJoint.open(optJoint),"Unable to open the client!");
77 return true;
78}

◆ tearDown()

void CartesianControlReachingToleranceTest::tearDown ( )
virtual

Definition at line 82 of file CartesianControlReachingToleranceTest.cpp.

83{
84 ROBOTTESTINGFRAMEWORK_TEST_REPORT("Closing Cartesian Controller Client");
85 ROBOTTESTINGFRAMEWORK_ASSERT_FAIL_IF_FALSE(drvCart.close(),"Unable to close the client!");
86
87 ROBOTTESTINGFRAMEWORK_TEST_REPORT("Closing Joint Controller Client");
88 ROBOTTESTINGFRAMEWORK_ASSERT_FAIL_IF_FALSE(drvJoint.close(),"Unable to close the client!");
89}

The documentation for this class was generated from the following files: