22 #include <robottestingframework/TestAssert.h>
23 #include <robottestingframework/dll/Plugin.h>
24 #include <yarp/os/Time.h>
25 #include <yarp/dev/CartesianControl.h>
26 #include <yarp/sig/Vector.h>
28 #include "CartesianControlSimpleP2pMovementTest.h"
31 using namespace robottestingframework;
32 using namespace yarp::os;
33 using namespace yarp::dev;
34 using namespace yarp::sig;
41 CartesianControlSimpleP2pMovementTest::CartesianControlSimpleP2pMovementTest() :
42 yarp::robottestingframework::TestCase(
"CartesianControlSimpleP2pMovementTest")
48 CartesianControlSimpleP2pMovementTest::~CartesianControlSimpleP2pMovementTest()
54 bool CartesianControlSimpleP2pMovementTest::setup(Property &property)
56 string robot=
property.check(
"robot",Value(
"icubSim")).asString();
57 string arm=
property.check(
"arm-type",Value(
"left")).asString();
60 option.put(
"device",
"cartesiancontrollerclient");
61 option.put(
"remote",(
"/"+robot+
"/"+
"cartesianController/"+arm+
"_arm"));
62 option.put(
"local",(
"/"+getName()+
"/"+arm+
"_arm"));
64 ROBOTTESTINGFRAMEWORK_TEST_REPORT(Asserter::format(
"Opening Cartesian Controller Client for %s_arm",arm.c_str()));
65 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(driver.open(option),
"Unable to open the client!");
71 void CartesianControlSimpleP2pMovementTest::tearDown()
73 ROBOTTESTINGFRAMEWORK_TEST_REPORT(
"Closing Cartesian Controller Client");
74 ROBOTTESTINGFRAMEWORK_ASSERT_FAIL_IF_FALSE(driver.close(),
"Unable to close the client!");
79 void CartesianControlSimpleP2pMovementTest::run()
81 ICartesianControl *iarm;
82 ROBOTTESTINGFRAMEWORK_TEST_CHECK(driver.view(iarm),
"Opening the view on the device!");
87 double t0=Time::now();
88 while (Time::now()-t0<5.0)
90 done=iarm->getPose(x,o);
95 ROBOTTESTINGFRAMEWORK_TEST_CHECK(done,
"Initial pose retrieved!");
97 ROBOTTESTINGFRAMEWORK_TEST_REPORT(
"Setting up the context");
99 iarm->storeContext(&context);
102 iarm->getDOF(dof); dof=1.0;
103 iarm->setDOF(dof,dof);
104 iarm->setTrajTime(1.0);
106 ROBOTTESTINGFRAMEWORK_TEST_REPORT(
"Reaching for the target");
107 Vector xd(3,0.0); xd[0]=-0.4;
108 iarm->goToPositionSync(xd);
110 ROBOTTESTINGFRAMEWORK_TEST_REPORT(
"Waiting");
111 done=iarm->waitMotionDone(1.0,5.0);
112 ROBOTTESTINGFRAMEWORK_TEST_CHECK(done,
"Target reached!");
114 ROBOTTESTINGFRAMEWORK_TEST_REPORT(
"Going back to starting pose");
115 iarm->setLimits(0,0.0,0.0);
116 iarm->setLimits(1,0.0,0.0);
117 iarm->setLimits(2,0.0,0.0);
118 iarm->goToPoseSync(x,o);
120 ROBOTTESTINGFRAMEWORK_TEST_REPORT(
"Waiting");
121 done=iarm->waitMotionDone(1.0,5.0);
122 ROBOTTESTINGFRAMEWORK_TEST_CHECK(done,
"Starting pose reached!");
124 ROBOTTESTINGFRAMEWORK_TEST_REPORT(
"Cleaning up the context");
125 iarm->restoreContext(context);
126 iarm->deleteContext(context);
This test verifies the point-to-point cartesian movement.