callback_data_mediator.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 <limits>
19 #include <ros/ros.h>
20 
22 
24 
27 {
28  boost::mutex::scoped_lock lock(distances_to_obstacles_lock_);
29  return this->obstacle_distances_.size();
30 }
31 
34 {
35  boost::mutex::scoped_lock lock(distances_to_obstacles_lock_);
36  bool success = false;
37  double last_min_distance = std::numeric_limits<double>::max();
38  params_ca.current_distances_.clear();
39  for (ObstacleDistancesIter_t it = this->obstacle_distances_.begin(); it != this->obstacle_distances_.end(); it++)
40  {
41  if (it->first == params_ca.id_) // select the appropriate distances for frame id of interest
42  {
43  params_ca.current_distances_ = it->second; // copy all distances for frame to current distances of param struct
44  success = true;
45  }
46  }
47 
48  return success;
49 }
50 
53 {
54  return true;
55 }
56 
58 void CallbackDataMediator::distancesToObstaclesCallback(const cob_control_msgs::ObstacleDistances::ConstPtr& msg)
59 {
60  boost::mutex::scoped_lock lock(distances_to_obstacles_lock_);
61  this->obstacle_distances_.clear();
62  for (cob_control_msgs::ObstacleDistances::_distances_type::const_iterator it = msg->distances.begin(); it != msg->distances.end(); it++)
63  {
65  d.min_distance = it->distance;
66  tf::vectorMsgToEigen(it->frame_vector, d.frame_vector);
67  tf::vectorMsgToEigen(it->nearest_point_frame_vector, d.nearest_point_frame_vector);
68  tf::vectorMsgToEigen(it->nearest_point_obstacle_vector, d.nearest_point_obstacle_vector);
69  this->obstacle_distances_[it->link_of_interest].push_back(d);
70  }
71 }
uint32_t obstacleDistancesCnt()
Counts all currently available distances to obstacles.
d
void distancesToObstaclesCallback(const cob_control_msgs::ObstacleDistances::ConstPtr &msg)
Producer: Fills obstacle distances but only when they are empty.
Class that represents the parameters for the Collision Avoidance constraint.
void vectorMsgToEigen(const geometry_msgs::Vector3 &m, Eigen::Vector3d &e)
Class that represents the parameters for the Collision Avoidance constraint.
ObstacleDistancesInfo_t obstacle_distances_
boost::mutex distances_to_obstacles_lock_
const std::string id_
bool fill(ConstraintParamsCA &params_ca)
Consumer: Consumes elements from distances container.
ObstacleDistancesInfo_t::const_iterator ObstacleDistancesIter_t
std::vector< ObstacleDistanceData > current_distances_


cob_twist_controller
Author(s): Felix Messmer , Marco Bezzon , Christoph Mark , Francisco Moreno
autogenerated on Thu Apr 8 2021 02:40:00