11 ROS_INFO(
"Waiting for action server to start.");
13 goal.target_joint.header.seq = 0;
14 goal.target_joint.name.push_back(
"pan");
15 goal.target_joint.name.push_back(
"tilt");
16 goal.target_joint.velocity.push_back(0);
17 goal.target_joint.velocity.push_back(0);
21 goal.target_joint.position.clear();
22 goal.target_joint.position.push_back(pan);
23 goal.target_joint.position.push_back(tilt);
27 if (finished_before_timeout)
33 ROS_INFO(
"Action did not finish before the time out.");
39 double greaterMaxPan = maxPan + epsilon;
40 double smallerMinPan = minPan - epsilon;
41 double greaterMaxTilt = maxTilt + epsilon;
42 double smallerMinTilt = minTilt - epsilon;
44 double pans[3] = {0.0, greaterMaxPan, smallerMinPan};
45 double tilts[3] = {0.0, greaterMaxTilt, smallerMinTilt};
47 for (
int i = 0; i < 3; i++) {
48 for (
int j = 0; j < 3; j++) {
56 goal.target_joint.position.clear();
57 goal.target_joint.position.push_back(pan);
58 goal.target_joint.position.push_back(tilt);
61 if (finished_before_timeout)
71 int main (
int argc,
char **argv)
73 ros::init(argc, argv,
"ptu_controller_client");
77 std::string actionServerName;
79 n.
getParam(
"actionServerName", actionServerName);
82 n.
getParam(
"checkValidation", checkValidation);
87 std::ofstream testfile;
89 n.
getParam(
"testlog_filepath", filepath);
90 testfile.open(filepath.c_str(), std::ios::trunc);
91 ROS_DEBUG(
"Test Nr. 00: Test initialization\n");
92 testfile <<
"Test Nr. 00:\nIt is tried to bring the PTU in starting position with pan = 0 and tilt = 0\n";
93 testfile <<
"It is expected that the Actionserver accepts the goal\n";
94 testfile <<
"Expected return state: SUCCEEDED\n";
95 testfile <<
"Recieved return state: ";
97 testfile << state.
toString() <<
"\n";
99 ROS_DEBUG(
"Correct state returned, for pan/tilt check look into the testlog\n");
100 testfile <<
"Expected pan: 0\n";
101 testfile <<
"Recieved pan: " << ptu_controller->
actionClient.
getResult()->end_joint.position[0] <<
"\n";
102 testfile <<
"Expected tilt: 0\n";
103 testfile <<
"Recieved tilt: " << ptu_controller->
actionClient.
getResult()->end_joint.position[1] <<
"\n";
111 testfile <<
"Test Nr. 01:\nIt is tried if the Actionserver works with a command that moves the PTU to the same position where it is located at the moment\n";
112 testfile <<
"It is expected that the Actionserver takes the goal and executes it\n";
113 testfile <<
"Expected return state: SUCCEEDED\n";
114 testfile <<
"Recieved return state: ";
116 testfile << state.
toString() <<
"\n";
118 ROS_DEBUG(
"Correct state returned, for pan/tilt check look into the testlog\n");
119 testfile <<
"Expected pan: 0\n";
120 testfile <<
"Recieved pan: " << ptu_controller->
actionClient.
getResult()->end_joint.position[0] <<
"\n";
121 testfile <<
"Expected tilt: 0\n";
122 testfile <<
"Recieved tilt: " << ptu_controller->
actionClient.
getResult()->end_joint.position[1] <<
"\n";
129 ROS_DEBUG(
"Test Nr. 02: Pan Movement\n");
130 testfile <<
"Test Nr. 02:\nIt is tried to move the pan-unit of the PTU from 0 to 5 degree\n";
131 testfile <<
"It is expected that the Actionserver accepts the goal and executes it\n";
132 testfile <<
"Expected return state: SUCCEEDED\n";
133 testfile <<
"Recieved return state: ";
135 testfile << state.
toString() <<
"\n";
137 ROS_DEBUG(
"Correct state returned, for pan/tilt check look into the testlog\n");
138 testfile <<
"Expected pan: ~5\n";
139 testfile <<
"Recieved pan: " << ptu_controller->
actionClient.
getResult()->end_joint.position[0] <<
"\n";
140 testfile <<
"Expected tilt: 0\n";
141 testfile <<
"Recieved tilt: " << ptu_controller->
actionClient.
getResult()->end_joint.position[1] <<
"\n";
148 ROS_DEBUG(
"Test Nr. 03: Tilt Movement\n");
149 testfile <<
"Test Nr 03:\nIt is tried to move the tilt-unit of the PTU from 0 to 5 degree\n";
150 testfile <<
"It is expected that the Actionserver accepts the goal and executes it\n";
151 testfile <<
"Expected return state: SUCCEEDED\n";
152 testfile <<
"Recieved return state: ";
154 testfile << state.
toString() <<
"\n";
156 ROS_DEBUG(
"Correct state returned, for pan/tilt check look into the testlog\n");
157 testfile <<
"Expected pan: ~5\n";
158 testfile <<
"Recieved pan: " << ptu_controller->
actionClient.
getResult()->end_joint.position[0] <<
"\n";
159 testfile <<
"Expected tilt: ~5\n";
160 testfile <<
"Recieved tilt: " << ptu_controller->
actionClient.
getResult()->end_joint.position[1] <<
"\n";
167 ROS_DEBUG(
"Test Nr. 04: Pan + Tilt Movement\n");
168 testfile <<
"Test Nr. 04:\nIt is tried to move the pan and the tilt unit within the same command from 5 to 10\n";
169 testfile <<
"It is expected that the Actionserver takes the command and executes it\n";
170 testfile <<
"Expected return state: SUCCEEDED\n";
171 testfile <<
"Recieved return state: ";
173 testfile << state.
toString() <<
"\n";
175 ROS_DEBUG(
"Correct state returned, for pan/tilt check look into the testlog\n");
176 testfile <<
"Expected pan: ~10\n";
177 testfile <<
"Recieved pan: " << ptu_controller->
actionClient.
getResult()->end_joint.position[0] <<
"\n";
178 testfile <<
"Expected tilt: ~10\n";
179 testfile <<
"Recieved tilt: " << ptu_controller->
actionClient.
getResult()->end_joint.position[1] <<
"\n";
186 ROS_DEBUG(
"Test Nr. 05: Pan out of bounds \n");
187 testfile <<
"Test Nr. 05:\nIt is tested if it is possible to pass a pan position to the Actionserver which is out of the working area of the PTU (pan 178)\n";
188 testfile <<
"It is expected that the server rejects (at the moment instant abort) the request and that no movement happens\n";
189 testfile <<
"Expected return state: ABORTED\n";
190 testfile <<
"Recieved return state: ";
192 testfile << state.
toString() <<
"\n";
194 ROS_DEBUG(
"Correct state returned, for pan/tilt check look into the testlog\n");
195 testfile <<
"Expected pan: ~10\n";
196 testfile <<
"Recieved pan: " << ptu_controller->
actionClient.
getResult()->end_joint.position[0] <<
"\n";
197 testfile <<
"Expected tilt: ~10\n";
198 testfile <<
"Recieved tilt: " << ptu_controller->
actionClient.
getResult()->end_joint.position[1] <<
"\n";
205 ROS_DEBUG(
"Test Nr. 06: Tilt out of bounds \n");
206 testfile <<
"Test Nr. 06:\nIt is tested if it is possible to pass a pan position to the Actionserver which is out of the working area of the PTU (tilt 178)\n";
207 testfile <<
"It is expected that the server rejects (at the moment instant abort) the request and that no movement happens\n";
208 testfile <<
"Expected return state: ABORTED\n";
209 testfile <<
"Recieved return state: ";
211 testfile << state.
toString() <<
"\n";
213 ROS_DEBUG(
"Correct state returned, for pan/tilt check look into the testlog\n");
214 testfile <<
"Expected pan: ~10\n";
215 testfile <<
"Recieved pan: " << ptu_controller->
actionClient.
getResult()->end_joint.position[0] <<
"\n";
216 testfile <<
"Expected tilt: ~10\n";
217 testfile <<
"Recieved tilt: " << ptu_controller->
actionClient.
getResult()->end_joint.position[1] <<
"\n";
224 ROS_DEBUG(
"Test Nr. 07: In forbidden area \n");
225 testfile <<
"Test Nr. 07\nIt is tested if it is possible to pass a position within a forbidden area but within the working area of the PTU to the Actionserver (pan -55, tilt - 30)";
226 testfile <<
"It is expected that the server rejects (at the moment instant abort) the request and that no movement happens\n";
227 testfile <<
"Expected return state: ABORTED\n";
228 testfile <<
"Recieved return state: ";
230 testfile << state.
toString() <<
"\n";
232 ROS_DEBUG(
"Correct state returned, for pan/tilt check look into the testlog\n");
233 testfile <<
"Expected pan: ~10\n";
234 testfile <<
"Recieved pan: " << ptu_controller->
actionClient.
getResult()->end_joint.position[0] <<
"\n";
235 testfile <<
"Expected tilt: ~10\n";
236 testfile <<
"Recieved tilt: " << ptu_controller->
actionClient.
getResult()->end_joint.position[1] <<
"\n";
249 if (checkValidation) {
263 std::vector<double> pans;
264 std::vector<double> tilts;
265 std::vector<bool> waits;
270 if (pans.size() != tilts.size() || pans.size() != waits.size())
272 for(
unsigned int i = 0; i < waits.size(); i++) {
273 ptu_controller->
sendJoint(pans[i], tilts[i], waits[0]);
void checkValidation(double maxPan, double minPan, double maxTilt, double minTilt)
int main(int argc, char **argv)
asr_flir_ptu_controller::PTUMovementGoal goal
bool waitForServer(const ros::Duration &timeout=ros::Duration(0, 0)) const
bool waitForResult(const ros::Duration &timeout=ros::Duration(0, 0))
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void sendJoint(double pan, double tilt, bool wait)
std::string toString() const
actionlib::SimpleClientGoalState testFunction(double pan, double tilt)
void sendGoal(const Goal &goal, SimpleDoneCallback done_cb=SimpleDoneCallback(), SimpleActiveCallback active_cb=SimpleActiveCallback(), SimpleFeedbackCallback feedback_cb=SimpleFeedbackCallback())
actionlib::SimpleActionClient< asr_flir_ptu_controller::PTUMovementAction > actionClient
bool getParam(const std::string &key, std::string &s) const
ROSCPP_DECL void shutdown()
SimpleClientGoalState getState() const
ResultConstPtr getResult() const
PTUControllerClient(std::string name)