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

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

#include <DemoRedBallTest.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
context string - demoRedBall No context containing the demoRedBall conf file -
from string - config-test.ini No demoRedBall configuration file -

You can watch a video of how this test will be performing.

Definition at line 50 of file DemoRedBallTest.h.

Constructor & Destructor Documentation

◆ DemoRedBallTest()

DemoRedBallTest::DemoRedBallTest ( )

Definition at line 50 of file DemoRedBallTest.cpp.

50 : yarp::robottestingframework::TestCase("DemoRedBallTest")
51{
52}

◆ ~DemoRedBallTest()

DemoRedBallTest::~DemoRedBallTest ( )
virtual

Definition at line 56 of file DemoRedBallTest.cpp.

57{
58}

Member Function Documentation

◆ run()

void DemoRedBallTest::run ( )
virtual

Definition at line 356 of file DemoRedBallTest.cpp.

357{
358 if (params.use_torso || params.use_left)
359 {
360 Vector dpos(3,0.0);
361 dpos[1]=-0.06;
362 dpos[2]=-0.3;
363 drvJointArmL.view(arm_under_test.ienc);
364 drvCartArmL.view(arm_under_test.iarm);
365 ROBOTTESTINGFRAMEWORK_TEST_REPORT("Reaching with the left hand");
366 testBallPosition(dpos);
367 }
368
369 if (params.use_torso || params.use_right)
370 {
371 Vector dpos(3,0.0);
372 dpos[1]=+0.06;
373 dpos[2]=-0.3;
374 drvJointArmR.view(arm_under_test.ienc);
375 drvCartArmR.view(arm_under_test.iarm);
376 ROBOTTESTINGFRAMEWORK_TEST_REPORT("Reaching with the right hand");
377 testBallPosition(dpos);
378 }
379}

◆ setup()

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

Definition at line 62 of file DemoRedBallTest.cpp.

63{
64 Time::useNetworkClock("/clock");
65
66 string context=property.check("context",Value("demoRedBall")).asString();
67 string from=property.check("from",Value("config-test.ini")).asString();
68
69 // retrieve demoRedBall parameters
70 ResourceFinder rf;
71 rf.setDefaultContext(context.c_str());
72 rf.setDefaultConfigFile(from.c_str());
73 rf.configure(0,NULL);
74
75 // fallback values
76 params.robot="icubSim";
77 params.eye="left";
78 params.reach_tol=0.01;
79 params.use_torso=true;
80 params.use_left=true;
81 params.use_right=true;
82 params.home_arm.resize(7,0.0);
83
84 Bottle &general=rf.findGroup("general");
85 if (!general.isNull())
86 {
87 params.robot=general.check("robot",Value(params.robot)).asString();
88 params.eye=general.check("eye",Value(params.eye)).asString();
89 params.reach_tol=general.check("reach_tol",Value(params.reach_tol)).asFloat64();
90 params.use_torso=(general.check("torso",Value(params.use_torso?"on":"off")).asString()=="on");
91 params.use_left=(general.check("left_arm",Value(params.use_left?"on":"off")).asString()=="on");
92 params.use_right=(general.check("right_arm",Value(params.use_right?"on":"off")).asString()=="on");
93 }
94
95 Bottle &home_arm=rf.findGroup("home_arm");
96 if (!home_arm.isNull())
97 {
98 if (home_arm.check("poss"))
99 {
100 Bottle &poss=home_arm.findGroup("poss");
101 for (size_t i=0; i<std::min(params.home_arm.length(),(size_t)poss.size()-1); i++)
102 params.home_arm[i]=poss.get(1+i).asFloat64();
103 }
104 }
105
106 ROBOTTESTINGFRAMEWORK_TEST_REPORT("Opening Clients");
107 if (params.use_left)
108 {
109 Property optJoint;
110 optJoint.put("device","remote_controlboard");
111 optJoint.put("remote",("/"+params.robot+"/"+"left_arm"));
112 optJoint.put("local",("/"+getName()+"/joint/left_arm"));
113
114 Property optCart;
115 optCart.put("device","cartesiancontrollerclient");
116 optCart.put("remote",("/"+params.robot+"/"+"cartesianController/left_arm"));
117 optCart.put("local",("/"+getName()+"/cartesian/left_arm"));
118
119 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(drvJointArmL.open(optJoint)&&drvCartArmL.open(optCart),
120 "Unable to open clients for left_arm!");
121 }
122
123 if (params.use_right)
124 {
125 Property optJoint;
126 optJoint.put("device","remote_controlboard");
127 optJoint.put("remote",("/"+params.robot+"/"+"right_arm"));
128 optJoint.put("local",("/"+getName()+"/joint/right_arm"));
129
130 Property optCart;
131 optCart.put("device","cartesiancontrollerclient");
132 optCart.put("remote",("/"+params.robot+"/"+"cartesianController/right_arm"));
133 optCart.put("local",("/"+getName()+"/cartesian/right_arm"));
134
135 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(drvJointArmR.open(optJoint)&&drvCartArmR.open(optCart),
136 "Unable to open clients for right_arm!");
137 }
138
139 {
140 Property optJoint;
141 optJoint.put("device","remote_controlboard");
142 optJoint.put("remote",("/"+params.robot+"/"+"head"));
143 optJoint.put("local",("/"+getName()+"/joint/head"));
144
145 Property optGaze;
146 optGaze.put("device","gazecontrollerclient");
147 optGaze.put("remote","/iKinGazeCtrl");
148 optGaze.put("local",("/"+getName()+"/gaze"));
149
150 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(drvJointHead.open(optJoint)&&drvGaze.open(optGaze),
151 "Unable to open clients for head!");
152 }
153
154 if (params.use_torso)
155 {
156 Property optJoint;
157 optJoint.put("device","remote_controlboard");
158 optJoint.put("remote",("/"+params.robot+"/"+"torso"));
159 optJoint.put("local",("/"+getName()+"/joint/torso"));
160
161 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(drvJointTorso.open(optJoint),
162 "Unable to open clients for torso!");
163 }
164
165 rpcPort.open("/"+getName()+"/rpc");
166 string dest="/demoRedBall/rpc";
167 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(Network::connect(rpcPort.getName(),dest),
168 Asserter::format("Unable to connect to %s!",dest.c_str()));
169
170 guiPort.open("/"+getName()+"/gui:i");
171 string src="/demoRedBall/gui:o";
172 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(Network::connect(src,guiPort.getName()),
173 Asserter::format("Unable to connect to %s!",src.c_str()));
174
175 return true;
176}

◆ tearDown()

void DemoRedBallTest::tearDown ( )
virtual

Definition at line 180 of file DemoRedBallTest.cpp.

181{
182 ROBOTTESTINGFRAMEWORK_TEST_REPORT("Closing Clients");
183 rpcPort.close();
184 guiPort.close();
185 if (params.use_left)
186 {
187 ROBOTTESTINGFRAMEWORK_ASSERT_FAIL_IF_FALSE(drvJointArmL.close()&&drvCartArmL.close(),
188 "Unable to close client for left_arm!");
189 }
190 if (params.use_right)
191 {
192 ROBOTTESTINGFRAMEWORK_ASSERT_FAIL_IF_FALSE(drvJointArmR.close()&&drvCartArmR.close(),
193 "Unable to close client for right_arm!");
194 }
195 ROBOTTESTINGFRAMEWORK_ASSERT_FAIL_IF_FALSE(drvJointHead.close()&&drvGaze.close(),
196 "Unable to close client for head!");
197 if (params.use_torso)
198 {
199 ROBOTTESTINGFRAMEWORK_ASSERT_FAIL_IF_FALSE(drvJointTorso.close(),"Unable to close client for left_arm!");
200 }
201}

Field Documentation

◆ eye

std::string DemoRedBallTest::eye

Definition at line 54 of file DemoRedBallTest.h.

◆ home_arm

yarp::sig::Vector DemoRedBallTest::home_arm

Definition at line 59 of file DemoRedBallTest.h.

◆ iarm

yarp::dev::ICartesianControl* DemoRedBallTest::iarm

Definition at line 71 of file DemoRedBallTest.h.

◆ ienc

yarp::dev::IEncoders* DemoRedBallTest::ienc

Definition at line 72 of file DemoRedBallTest.h.

◆ reach_tol

double DemoRedBallTest::reach_tol

Definition at line 55 of file DemoRedBallTest.h.

◆ robot

std::string DemoRedBallTest::robot

Definition at line 53 of file DemoRedBallTest.h.

◆ use_left

bool DemoRedBallTest::use_left

Definition at line 57 of file DemoRedBallTest.h.

◆ use_right

bool DemoRedBallTest::use_right

Definition at line 58 of file DemoRedBallTest.h.

◆ use_torso

bool DemoRedBallTest::use_torso

Definition at line 56 of file DemoRedBallTest.h.


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