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
70 ResourceFinder rf;
71 rf.setDefaultContext(context.c_str());
72 rf.setDefaultConfigFile(from.c_str());
73 rf.configure(0,NULL);
74
75
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}