cob_lookat_action_server.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #include <string>
19 #include <algorithm>
20 #include <ros/ros.h>
21 #include <angles/angles.h>
23 #include <sensor_msgs/JointState.h>
24 
25 
27 {
29  if (!nh_.getParam("joint_names", joint_names_))
30  {
31  ROS_ERROR("Parameter 'joint_names' not set");
32  return false;
33  }
34 
35  if (!nh_.getParam("chain_base_link", chain_base_link_))
36  {
37  ROS_ERROR("Parameter 'chain_base_link' not set");
38  return false;
39  }
40 
41  if (!nh_.getParam("chain_tip_link", chain_tip_link_))
42  {
43  ROS_ERROR("Parameter 'chain_tip_link' not set");
44  return false;
45  }
46 
48  KDL::Tree tree;
49  if (!kdl_parser::treeFromParam("/robot_description", tree))
50  {
51  ROS_ERROR("Failed to construct kdl tree");
52  return false;
53  }
54 
56  if (chain_main_.getNrOfJoints() == 0)
57  {
58  ROS_ERROR("Failed to initialize kinematic chain");
59  return false;
60  }
61 
65 
68 
70  lookat_as_->start();
71 
72  return true;
73 }
74 
75 
76 void CobLookAtAction::goalCB(const cob_lookat_action::LookAtGoalConstPtr &goal)
77 {
78  bool success = true;
79  std::string message;
80  double roll, pitch, yaw;
81 
83  KDL::Frame offset;
84  geometry_msgs::TransformStamped offset_transform_msg;
85  try
86  {
87  offset_transform_msg = tf_buffer_->lookupTransform(chain_tip_link_, goal->pointing_frame, ros::Time(0));
88  }
89  catch (tf2::TransformException& ex)
90  {
91  success = false;
92  message = "Failed to lookupTransform pointing_frame: " + std::string(ex.what());
93  ROS_ERROR_STREAM(lookat_name_ << ": " << message);
94  lookat_res_.success = success;
95  lookat_res_.message = message;
97  return;
98  }
99 
101  {
102  success = false;
103  message = "Preempted after lookup 'pointing_frame'";
104  ROS_WARN_STREAM(lookat_name_ << ": " << message);
105  lookat_res_.success = success;
106  lookat_res_.message = message;
108  return;
109  }
110 
111  tf::transformMsgToKDL(offset_transform_msg.transform, offset);
112 
113  //ToDo: implement offset mechanism
114  //tf::transformMsgToKDL(goal->pointing_offset, offset);
115 
116  offset.M.GetRPY(roll, pitch, yaw);
117  ROS_DEBUG_STREAM("offset.p: " << offset.p.x() << ", " << offset.p.y() << ", " << offset.p.z());
118  ROS_DEBUG_STREAM("offset.rot: " << roll << ", " << pitch << ", " << yaw);
119 
121  KDL::Chain chain_base, chain_lookat, chain_full;
122  KDL::Joint::JointType lookat_lin_joint_type = KDL::Joint::None;
123  double mod_neg_factor = 1.0;
124  switch (goal->pointing_axis_type)
125  {
126  case cob_lookat_action::LookAtGoal::X_POSITIVE:
127  lookat_lin_joint_type = KDL::Joint::TransX;
128  break;
129  case cob_lookat_action::LookAtGoal::Y_POSITIVE:
130  lookat_lin_joint_type = KDL::Joint::TransY;
131  break;
132  case cob_lookat_action::LookAtGoal::Z_POSITIVE:
133  lookat_lin_joint_type = KDL::Joint::TransZ;
134  break;
135  case cob_lookat_action::LookAtGoal::X_NEGATIVE:
136  lookat_lin_joint_type = KDL::Joint::TransX;
137  mod_neg_factor = -1.0;
138  break;
139  case cob_lookat_action::LookAtGoal::Y_NEGATIVE:
140  lookat_lin_joint_type = KDL::Joint::TransY;
141  mod_neg_factor = -1.0;
142  break;
143  case cob_lookat_action::LookAtGoal::Z_NEGATIVE:
144  lookat_lin_joint_type = KDL::Joint::TransZ;
145  mod_neg_factor = -1.0;
146  break;
147  default:
148  ROS_ERROR("PointingAxisType %d not defined! Using default: 'X_POSITIVE'!", goal->pointing_axis_type);
149  lookat_lin_joint_type = KDL::Joint::TransX;
150  break;
151  }
152 
154  KDL::Joint offset_joint("offset_joint", KDL::Joint::None);
155  KDL::Segment offset_link("offset_link", offset_joint, offset);
156  chain_lookat.addSegment(offset_link);
157 
159  KDL::Joint lookat_lin_joint("lookat_lin_joint", lookat_lin_joint_type);
160  KDL::Segment lookat_rotx_link("lookat_rotx_link", lookat_lin_joint);
161  chain_lookat.addSegment(lookat_rotx_link);
162 
163  KDL::Joint lookat_rotx_joint("lookat_rotx_joint", KDL::Joint::RotX);
164  KDL::Segment lookat_roty_link("lookat_roty_link", lookat_rotx_joint);
165  chain_lookat.addSegment(lookat_roty_link);
166 
167  KDL::Joint lookat_roty_joint("lookat_roty_joint", KDL::Joint::RotY);
168  KDL::Segment lookat_rotz_link("lookat_rotz_link", lookat_roty_joint);
169  chain_lookat.addSegment(lookat_rotz_link);
170 
171  KDL::Joint lookat_rotz_joint("lookat_rotz_joint", KDL::Joint::RotZ);
172  KDL::Segment lookat_focus_frame("lookat_focus_frame", lookat_rotz_joint);
173  chain_lookat.addSegment(lookat_focus_frame);
174 
176  KDL::Joint base_rotz_joint("base_rotz_joint", KDL::Joint::RotZ);
177  KDL::Segment base_rotz_link("base_rotz_link", base_rotz_joint, KDL::Frame());
178  chain_base.addSegment(base_rotz_link);
179 
181  if (goal->base_active)
182  {
183  chain_full = chain_base;
184  chain_full.addChain(chain_main_);
185  }
186  else
187  {
188  chain_full = chain_main_;
189  }
190  chain_full.addChain(chain_lookat);
191 
194  fk_solver_pos_.reset(new KDL::ChainFkSolverPos_recursive(chain_full));
195  ik_solver_pos_.reset(new KDL::ChainIkSolverPos_LMA(chain_full));
196  //ToDo: test other solvers
197  //ChainIkSolverPos_NR_NL: no
198  //ChainIkSolverPos_NR w. KDL::ChainIkSolverVel_pinv: no
199  //ChainIkSolverPos_NR w. KDL::ChainIkSolverVel_pinv_givens: ?
200  //ChainIkSolverPos_NR w. KDL::ChainIkSolverVel_pinv_nso: ?
201  //ChainIkSolverPos_NR w. KDL::ChainIkSolverVel_wdls: ?
202 
204  KDL::Frame p_in;
205  geometry_msgs::TransformStamped transform_in_msg;
206  try
207  {
208  transform_in_msg = tf_buffer_->lookupTransform(chain_base_link_, goal->target_frame, ros::Time(0));
209  }
210  catch (tf2::TransformException& ex)
211  {
212  success = false;
213  message = "Failed to lookupTransform target_frame: " + std::string(ex.what());
214  ROS_ERROR_STREAM(lookat_name_ << ": " << message);
215  lookat_res_.success = success;
216  lookat_res_.message = message;
218  return;
219  }
220 
222  {
223  success = false;
224  message = "Preempted after lookup 'target_frame'";
225  ROS_WARN_STREAM(lookat_name_ << ": " << message);
226  lookat_res_.success = success;
227  lookat_res_.message = message;
229  return;
230  }
231 
232  //ToDo: "upright"-constraint
233 
234  tf::transformMsgToKDL(transform_in_msg.transform, p_in);
235  KDL::JntArray q_init(chain_full.getNrOfJoints());
236  KDL::JntArray q_out(chain_full.getNrOfJoints());
237 
238  p_in.M.GetRPY(roll, pitch, yaw);
239  ROS_DEBUG_STREAM("p_in.p: " << p_in.p.x() << ", " << p_in.p.y() << ", " << p_in.p.z());
240  ROS_DEBUG_STREAM("p_in.rot: " << roll << ", " << pitch << ", " << yaw);
241 
242  int result_ik = ik_solver_pos_->CartToJnt(q_init, p_in, q_out);
243 
244  ROS_DEBUG_STREAM("IK-Error: "<< ik_solver_pos_->getError() << " - " << ik_solver_pos_->strError(ik_solver_pos_->getError()));
245  ROS_DEBUG_STREAM("q_init: " << q_init.data);
246  ROS_DEBUG_STREAM("q_out: " << q_out.data);
247 
249  if (ik_solver_pos_->getError() != KDL::SolverI::E_NOERROR)
250  {
251  success = false;
252  message = "Failed to find IK solution: " + std::string(ik_solver_pos_->strError(ik_solver_pos_->getError()));
253  ROS_ERROR_STREAM(lookat_name_ << ": " << message);
254  lookat_res_.success = success;
255  lookat_res_.message = message;
257  return;
258  }
259 
260  //ToDo. check joint_limits
261 
263  KDL::Frame p_out;
264  int result_fk = fk_solver_pos_->JntToCart(q_out, p_out);
265 
266  ROS_DEBUG_STREAM("FK-Error: "<< fk_solver_pos_->getError() << " - " << fk_solver_pos_->strError(fk_solver_pos_->getError()));
267  p_out.M.GetRPY(roll, pitch, yaw);
268  ROS_DEBUG_STREAM("p_out.p: " << p_out.p.x() << ", " << p_out.p.y() << ", " << p_out.p.z());
269  ROS_DEBUG_STREAM("p_out.rot: " << roll << ", " << pitch << ", " << yaw);
270 
272  if (fk_solver_pos_->getError() != KDL::SolverI::E_NOERROR)
273  {
274  success = false;
275  message = "Failed to find FK solution: " + std::string(fk_solver_pos_->strError(fk_solver_pos_->getError()));
276  ROS_ERROR_STREAM(lookat_name_ << ": " << message);
277  lookat_res_.success = success;
278  lookat_res_.message = message;
280  return;
281  }
282 
283  KDL::Vector v_diff = KDL::diff(p_in.p, p_out.p);
284  ROS_DEBUG_STREAM("p_diff: " << v_diff.x() << ", " << v_diff.y() << ", " << v_diff.z());
285  ROS_DEBUG_STREAM("NORM v_diff: " << v_diff.Norm());
286 
287  if (!KDL::Equal(p_in, p_out, 1.0))
288  {
289  ROS_DEBUG_STREAM("P_IN !Equal P_OUT");
290  }
291 
293  unsigned int k = (goal->base_active) ? 1 : 0;
294 
296  KDL::Frame p_out_main;
298  for(unsigned int i = 0; i < chain_main_.getNrOfJoints(); i++)
299  {
300  q_out_main(i)=angles::normalize_angle(q_out(i+k));
301  }
302  int result_fk_main = fk_solver_pos_main_->JntToCart(q_out_main, p_out_main);
303  ROS_DEBUG_STREAM("FK-Error MAIN: "<< fk_solver_pos_main_->getError() << " - " << fk_solver_pos_main_->strError(fk_solver_pos_main_->getError()));
304 
306  if (fk_solver_pos_main_->getError() != KDL::SolverI::E_NOERROR)
307  {
308  success = false;
309  message = "Failed to find FK solution MAIN: " + std::string(fk_solver_pos_main_->strError(fk_solver_pos_main_->getError()));
310  ROS_ERROR_STREAM(lookat_name_ << ": " << message);
311  lookat_res_.success = success;
312  lookat_res_.message = message;
314  return;
315  }
316 
317 
318  KDL::Frame p_out_main_offset;
319  if (goal->base_active)
320  {
321  p_out_main_offset = KDL::Frame(KDL::Rotation::RPY(0.0, 0.0, angles::normalize_angle(q_out(0))))*p_out_main*offset;
322  }
323  else
324  {
325  p_out_main_offset = p_out_main*offset;
326  }
327  KDL::Frame tip2target = p_out_main_offset.Inverse()*p_in;
328 
329  ROS_DEBUG_STREAM("q_out_main: " << q_out_main.data);
330  p_out_main.M.GetRPY(roll, pitch, yaw);
331  ROS_DEBUG_STREAM("p_out_main.p: " << p_out_main.p.x() << ", " << p_out_main.p.y() << ", " << p_out_main.p.z());
332  ROS_DEBUG_STREAM("p_out_main.rot: " << roll << ", " << pitch << ", " << yaw);
333  offset.M.GetRPY(roll, pitch, yaw);
334  ROS_DEBUG_STREAM("offset.p: " << offset.p.x() << ", " << offset.p.y() << ", " << offset.p.z());
335  ROS_DEBUG_STREAM("offset.rot: " << roll << ", " << pitch << ", " << yaw);
336  p_out_main_offset.M.GetRPY(roll, pitch, yaw);
337  ROS_DEBUG_STREAM("p_out_main_offset.p: " << p_out_main_offset.p.x() << ", " << p_out_main_offset.p.y() << ", " << p_out_main_offset.p.z());
338  ROS_DEBUG_STREAM("p_out_main_offset.rot: " << roll << ", " << pitch << ", " << yaw);
339  tip2target.M.GetRPY(roll, pitch, yaw);
340  ROS_DEBUG_STREAM("tip2target.p: " << tip2target.p.x() << ", " << tip2target.p.y() << ", " << tip2target.p.z());
341  ROS_DEBUG_STREAM("tip2target.rot: " << roll << ", " << pitch << ", " << yaw);
342 
343  //ToDo: check lookat conformity
344  KDL::Frame tip2target_test(tip2target);
345  double q_lookat_lin = 0.0;
346  switch (goal->pointing_axis_type)
347  {
348  case cob_lookat_action::LookAtGoal::X_POSITIVE:
349  q_lookat_lin = tip2target.p.x();
350  tip2target_test.p.x(0.0);
351  break;
352  case cob_lookat_action::LookAtGoal::Y_POSITIVE:
353  q_lookat_lin = tip2target.p.y();
354  tip2target_test.p.y(0.0);
355  break;
356  case cob_lookat_action::LookAtGoal::Z_POSITIVE:
357  q_lookat_lin = tip2target.p.z();
358  tip2target_test.p.z(0.0);
359  break;
360  case cob_lookat_action::LookAtGoal::X_NEGATIVE:
361  q_lookat_lin = tip2target.p.x();
362  tip2target_test.p.x(0.0);
363  break;
364  case cob_lookat_action::LookAtGoal::Y_NEGATIVE:
365  q_lookat_lin = tip2target.p.y();
366  tip2target_test.p.y(0.0);
367  break;
368  case cob_lookat_action::LookAtGoal::Z_NEGATIVE:
369  q_lookat_lin = tip2target.p.z();
370  tip2target_test.p.z(0.0);
371  break;
372  default:
373  ROS_ERROR("PointingAxisType %d not defined! Using default: 'X_POSITIVE'!", goal->pointing_axis_type);
374  q_lookat_lin = tip2target.p.x();
375  tip2target_test.p.x(0.0);
376  break;
377  }
378 
380  ROS_DEBUG_STREAM("q_lookat_lin: " << q_lookat_lin);
381  if (mod_neg_factor*q_lookat_lin < 0.0)
382  {
383  success = false;
384  message = "q_lookat_lin is negative";
385  ROS_ERROR_STREAM(lookat_name_ << ": " << message);
386  lookat_res_.success = success;
387  lookat_res_.message = message;
389  return;
390  }
391 
393  ROS_DEBUG_STREAM("tip2target_test: " << tip2target_test.p.x() << ", " << tip2target_test.p.y() << ", " << tip2target_test.p.z());
394  ROS_DEBUG_STREAM("tip2target_test.p.Norm: " << tip2target_test.p.Norm());
395  if (tip2target_test.p.Norm() > 0.1)
396  {
397  success = false;
398  message = "Tip2Target is not lookat-conform";
399  ROS_ERROR_STREAM(lookat_name_ << ": " << message);
400  lookat_res_.success = success;
401  lookat_res_.message = message;
403  return;
404  }
405 
407  control_msgs::FollowJointTrajectoryGoal fjt_goal;
408  fjt_goal.trajectory.header.stamp = ros::Time::now();
409  fjt_goal.trajectory.header.frame_id = chain_base_link_;
410  fjt_goal.trajectory.joint_names = joint_names_;
411  trajectory_msgs::JointTrajectoryPoint traj_point;
412  for (unsigned int i = 0; i < chain_main_.getNrOfJoints(); i++)
413  {
414  traj_point.positions.push_back(angles::normalize_angle(q_out(i+k)));
415  traj_point.velocities.push_back(0.0);
416  traj_point.accelerations.push_back(0.0);
417  }
418 
420  double t = 3.0;
421  std::string component_name = nh_.getNamespace();
422  component_name.erase(std::remove(component_name.begin(), component_name.end(), '/'), component_name.end());
423  float default_vel, default_acc;
424  nh_.param<float>("/script_server/"+component_name+"/default_vel", default_vel, 0.1);
425  nh_.param<float>("/script_server/"+component_name+"/default_acc", default_acc, 1.0);
426 
427  sensor_msgs::JointStateConstPtr js = ros::topic::waitForMessage<sensor_msgs::JointState>("/"+component_name+"/joint_states", ros::Duration(1.0));
428  if (js != NULL)
429  {
430  std::vector<double> d_pos;
431  for (unsigned int i=0; i<std::min(js->position.size(), traj_point.positions.size()); i++)
432  {
433  d_pos.push_back(std::fabs(js->position[i]-traj_point.positions[i]));
434  }
435  double d_max = *std::max_element(d_pos.begin(), d_pos.end());
436  double t1 = default_vel / default_acc;
437  double s1 = default_acc / 2*std::pow(t1,2);
438  if (2*s1 < d_max)
439  {
440  double s2 = d_max - 2*s1;
441  double t2 = s2 / default_vel;
442  t = 2*t1 + t2;
443  }
444  else
445  {
446  t = std::sqrt(d_max / default_acc);
447  }
448  }
449  double time_from_start = std::max(t,0.4);
450  traj_point.time_from_start = ros::Duration(time_from_start);
451  fjt_goal.trajectory.points.push_back(traj_point);
452 
454  //There are two special values for tolerances:
455  // * 0 - The tolerance is unspecified and will remain at whatever the default is
456  // * -1 - The tolerance is "erased".
457  // If there was a default, the joint will be allowed to move without restriction.
458 
459  //DO NOT SET TOLERANCES
460  /*
461  for (unsigned int i = 0; i < chain_main_.getNrOfJoints(); i++)
462  {
463  control_msgs::JointTolerance joint_tolerance;
464  joint_tolerance.name = joint_names_[i];
465  joint_tolerance.position = -1;
466  joint_tolerance.velocity = -1;
467  joint_tolerance.acceleration = -1;
468  fjt_goal.path_tolerance.push_back(joint_tolerance);
469  fjt_goal.goal_tolerance.push_back(joint_tolerance);
470  }
471  fjt_goal.goal_time_tolerance = ros::Duration(1.0);
472  */
473  ROS_DEBUG_STREAM("FJT-Goal: " << fjt_goal);
474 
476  move_base_msgs::MoveBaseGoal mbl_goal;
477  if (goal->base_active)
478  {
479  ROS_DEBUG_STREAM(lookat_name_ << ": MOVE_BASE_REL: " << angles::normalize_angle(q_out(0)));
480 
481  KDL::Frame base_target;
482  geometry_msgs::TransformStamped base_transform_msg;
483  try
484  {
485  base_transform_msg = tf_buffer_->lookupTransform("odom_combined", "base_link", ros::Time(0));
486  }
487  catch (tf2::TransformException& ex)
488  {
489  success = false;
490  message = "Failed to lookupTransform base_link: " + std::string(ex.what());
491  ROS_ERROR_STREAM(lookat_name_ << ": " << message);
492  lookat_res_.success = success;
493  lookat_res_.message = message;
495  return;
496  }
497 
499  {
500  success = false;
501  message = "Preempted after lookup 'base_link'";
502  ROS_WARN_STREAM(lookat_name_ << ": " << message);
503  lookat_res_.success = success;
504  lookat_res_.message = message;
506  return;
507  }
508 
509  tf::transformMsgToKDL(base_transform_msg.transform, base_target);
510  base_target = base_target*KDL::Frame(KDL::Rotation::RPY(0.0, 0.0, angles::normalize_angle(q_out(0))));
511 
512  base_target.M.GetRPY(roll, pitch, yaw);
513  ROS_DEBUG_STREAM("base_target.p: " << base_target.p.x() << ", " << base_target.p.y() << ", " << base_target.p.z());
514  ROS_DEBUG_STREAM("base_target.rot: " << roll << ", " << pitch << ", " << yaw);
515 
516  mbl_goal.target_pose.header.frame_id = "odom_combined";
517  mbl_goal.target_pose.header.stamp = ros::Time(0);
518  mbl_goal.target_pose.pose.position.x = base_target.p.x();
519  mbl_goal.target_pose.pose.position.y = base_target.p.y();
520  mbl_goal.target_pose.pose.position.z = base_target.p.z();
521  base_target.M.GetQuaternion(mbl_goal.target_pose.pose.orientation.x,
522  mbl_goal.target_pose.pose.orientation.y,
523  mbl_goal.target_pose.pose.orientation.z,
524  mbl_goal.target_pose.pose.orientation.w);
525  ROS_DEBUG_STREAM("MBL-Goal: " << mbl_goal);
526  }
527 
528  if (!fjt_ac_->isServerConnected())
529  {
530  success = false;
531  message = "FJT server not connected";
532  ROS_ERROR_STREAM(lookat_name_ << ": " << message);
533  lookat_res_.success = success;
534  lookat_res_.message = message;
536  return;
537  }
538  if (goal->base_active && !mbl_ac_->isServerConnected())
539  {
540  success = false;
541  message = "MBL server not connected";
542  ROS_ERROR_STREAM(lookat_name_ << ": " << message);
543  lookat_res_.success = success;
544  lookat_res_.message = message;
546  return;
547  }
548 
550  fjt_ac_->sendGoal(fjt_goal);
551  if (goal->base_active) mbl_ac_->sendGoal(mbl_goal);
552 
554  bool fjt_finished = false;
556  bool mbl_finished = false;
558  while (!lookat_as_->isPreemptRequested())
559  {
560  if (!fjt_finished)
561  {
562  fjt_finished = fjt_ac_->waitForResult(ros::Duration(0.1));
563  fjt_state = fjt_ac_->getState();
564  message = "FJT State: " + fjt_state.toString();
565  ROS_DEBUG_STREAM(lookat_name_ << ": " << message);
566  }
567 
568  if (!mbl_finished && goal->base_active)
569  {
570  mbl_finished = mbl_ac_->waitForResult(ros::Duration(0.1));
571  mbl_state = mbl_ac_->getState();
572  message = "MBJ State: " + mbl_state.toString();
573  ROS_DEBUG_STREAM(lookat_name_ << ": " << message);
574  }
575 
577  if (fjt_finished &&
578  ((mbl_finished && goal->base_active) || !goal->base_active))
579  {
580  if (goal->base_active)
581  {
582  message = "Action finished:\n\tFJT-State: " + fjt_state.toString() + ", FJT-ErrorCode: " + std::to_string(fjt_ac_->getResult()->error_code) + "\n\tMBL-State: " + mbl_state.toString();
583  }
584  else
585  {
586  message = "Action finished:\n\tFJT-State: " + fjt_state.toString() + ", FJT-ErrorCode: " + std::to_string(fjt_ac_->getResult()->error_code);
587  }
588 
590  ((mbl_state == actionlib::SimpleClientGoalState::SUCCEEDED && goal->base_active) || !goal->base_active))
591  {
592  success = true;
593  ROS_WARN_STREAM(lookat_name_ << ": " << message);
594  break;
595  }
596  else
597  {
598  fjt_ac_->cancelGoal();
599  if (goal->base_active) mbl_ac_->cancelGoal();
600 
601  success = false;
602  ROS_ERROR_STREAM(lookat_name_ << ": " << message);
603  lookat_res_.success = success;
604  lookat_res_.message = message;
606  return;
607  }
608  }
609  }
611  {
612  fjt_ac_->cancelGoal();
613  if (goal->base_active) mbl_ac_->cancelGoal();
614 
615  success = false;
616  message = "Preempted during execution";
617  ROS_ERROR_STREAM(lookat_name_ << ": " << message);
618  lookat_res_.success = success;
619  lookat_res_.message = message;
621  return;
622  }
623 
624  success = true;
625  message = "Lookat finished successful.";
626  ROS_WARN_STREAM(lookat_name_ << ": " << message);
627  lookat_res_.success = success;
628  lookat_res_.message = message;
630  return;
631 }
IMETHOD doubleVel diff(const doubleVel &a, const doubleVel &b, double dt=1.0)
std::shared_ptr< KDL::ChainFkSolverPos_recursive > fk_solver_pos_
bool waitForResult(const ros::Duration &timeout=ros::Duration(0, 0))
void addSegment(const Segment &segment)
std::shared_ptr< tf2_ros::Buffer > tf_buffer_
std::shared_ptr< KDL::ChainIkSolverPos_LMA > ik_solver_pos_
actionlib::SimpleActionClient< control_msgs::FollowJointTrajectoryAction > * fjt_ac_
std::shared_ptr< tf2_ros::TransformListener > tf_listener_
void setSucceeded(const Result &result=Result(), const std::string &text=std::string(""))
double z() const
std::vector< std::string > joint_names_
ros::Duration buffer_duration_
Rotation M
void GetQuaternion(double &x, double &y, double &z, double &w) const
double Norm(double eps=epsilon) const
std::string toString() const
IMETHOD bool Equal(const FrameAcc &r1, const FrameAcc &r2, double eps=epsilon)
void setPreempted(const Result &result=Result(), const std::string &text=std::string(""))
static Rotation RPY(double roll, double pitch, double yaw)
double y() const
bool param(const std::string &param_name, T &param_val, const T &default_val) const
double x() const
cob_lookat_action::LookAtResult lookat_res_
void transformMsgToKDL(const geometry_msgs::Transform &m, KDL::Frame &k)
const std::string & getNamespace() const
void addChain(const Chain &chain)
void goalCB(const cob_lookat_action::LookAtGoalConstPtr &goal)
unsigned int getNrOfJoints() const
def normalize_angle(angle)
Frame Inverse() const
#define ROS_WARN_STREAM(args)
#define ROS_DEBUG_STREAM(args)
void GetRPY(double &roll, double &pitch, double &yaw) const
actionlib::SimpleActionClient< move_base_msgs::MoveBaseAction > * mbl_ac_
std::shared_ptr< KDL::ChainFkSolverPos_recursive > fk_solver_pos_main_
void setAborted(const Result &result=Result(), const std::string &text=std::string(""))
bool getChain(const std::string &chain_root, const std::string &chain_tip, Chain &chain) const
void sendGoal(const Goal &goal, SimpleDoneCallback done_cb=SimpleDoneCallback(), SimpleActiveCallback active_cb=SimpleActiveCallback(), SimpleFeedbackCallback feedback_cb=SimpleFeedbackCallback())
KDL_PARSER_PUBLIC bool treeFromParam(const std::string &param, KDL::Tree &tree)
bool getParam(const std::string &key, std::string &s) const
static Time now()
SimpleClientGoalState getState() const
#define ROS_ERROR_STREAM(args)
ResultConstPtr getResult() const
#define ROS_ERROR(...)
actionlib::SimpleActionServer< cob_lookat_action::LookAtAction > * lookat_as_


cob_lookat_action
Author(s): Felix Messmer
autogenerated on Sun Dec 6 2020 03:25:48