32 if ((*it)->getClassId() == class_id) class_list.push_back(*it);
42 if ((*it)->getObjectId() == object_id)
return *it;
49 std_msgs::Header temp;
50 temp.frame_id =
header.frame_id;
53 if ((*it)->getStamp() > temp.stamp) temp.stamp = (*it)->getStamp();
59 header.frame_id = frame_id;
66 model.objects.clear();
67 model.objects.reserve(
objects.size());
68 for(ObjectList::const_iterator it =
objects.begin(); it !=
objects.end(); ++it) {
69 model.objects.push_back((*it)->getMessage());
74 hector_worldmodel_msgs::ObjectModelPtr model(
new hector_worldmodel_msgs::ObjectModel());
96 for(ObjectList::iterator it =
objects.begin(); it !=
objects.end(); ++it) {
118 for(hector_worldmodel_msgs::ObjectModel::_objects_type::const_iterator it = other.objects.begin();
119 it != other.objects.end();
124 object.reset(
new Object(*it));
137 markers.markers.clear();
138 for(ObjectList::const_iterator it =
objects.begin(); it !=
objects.end(); ++it) {
139 (*it)->getVisualization(markers);
146 float min_distance = max_distance;
147 if (min_distance <= 0.0) min_distance = FLT_MAX;
153 if (!class_id.empty() && class_id != x->getClassId())
continue;
154 if (!name.empty() && !x->getName().empty() && name != x->getName())
continue;
156 tf::Quaternion other_orientation(x->getOrientation().x(), x->getOrientation().y(), x->getOrientation().z(), x->getOrientation().w());
158 static const double MAXIMUM_ORIENTATION_DIFFERENCE = 110.0 * M_PI/180.0;
161 if (orientation_difference > MAXIMUM_ORIENTATION_DIFFERENCE) {
165 Eigen::Vector3f diff = x->getPosition() - position;
166 float distance = (diff.transpose() * (x->getCovariance() + covariance).
inverse() * diff)[0];
167 if (distance < min_distance) {
169 min_distance = distance;
178 merge(*other, tf, prefix);
189 ROS_WARN(
"Could not transform from frame %s into %s during object merge: %s", object->getHeader().frame_id.c_str(),
header.frame_id.c_str(), ex.what());
196 transformed->getPose(pose);
198 if (distance < 1.0) {
200 ROS_DEBUG(
"Merging %s and %s", mine->getObjectId().c_str(),
object->getObjectId().c_str());
201 mine->setObjectId(mine->getObjectId() +
"," + prefix +
object->getObjectId());
202 mine->update(pose, transformed->getCovariance(),
object->getSupport());
206 ROS_DEBUG(
"Adding %s", transformed->getObjectId().c_str());
207 transformed->setObjectId(prefix + object->getObjectId());
void getVisualization(visualization_msgs::MarkerArray &markers) const
void remove(ObjectPtr object)
ObjectModel(const std::string &frame_id=std::string())
std_msgs::Header getHeader() const
TFSIMD_FORCE_INLINE tfScalar distance(const Vector3 &v) const
std::map< std::string, bool > _with_orientation
TFSIMD_FORCE_INLINE tfScalar angleShortestPath(const Quaternion &q1, const Quaternion &q2)
void merge(const ObjectPtr &other, tf::TransformListener &tf, const std::string &prefix=std::string())
hector_worldmodel_msgs::ObjectModelPtr getMessage() const
ObjectList getObjects() const
ObjectList::iterator iterator
std::list< ObjectPtr > ObjectList
TFSIMD_FORCE_INLINE const tfScalar & x() const
TFSIMD_FORCE_INLINE const tfScalar & z() const
boost::recursive_mutex objectsMutex
ObjectList::const_iterator const_iterator
TFSIMD_FORCE_INLINE Quaternion inverse(const Quaternion &q)
boost::shared_ptr< Object > ObjectPtr
TFSIMD_FORCE_INLINE const tfScalar & y() const
void setFrameId(const std::string &frame_id)
TFSIMD_FORCE_INLINE const tfScalar & x() const
float getBestCorrespondence(ObjectPtr &object, const tf::Pose &pose, const Eigen::Matrix3f &covariance, const std::string &class_id, const std::string &name, float max_distance=0.0) const
static T & parameter(std::map< std::string, T > &p, const std::string &class_id=std::string())
ObjectModel & operator=(const ObjectModel &other)
ObjectPtr getObject(const std::string &object_id) const
ObjectPtr add(const std::string &class_id="", const std::string &object_id="")
void mergeWith(const ObjectModel &other, tf::TransformListener &tf, const std::string &prefix=std::string())