3 #include <boost/lexical_cast.hpp> 5 #include <Eigen/Geometry> 15 if (!class_id.empty()) {
16 this->
info.class_id = class_id;
18 this->
info.class_id =
"object";
21 if (!object_id.empty()) {
22 this->
info.object_id = object_id;
24 this->
info.object_id = this->
info.class_id +
"_" + boost::lexical_cast<std::string>(
object_count[this->
info.class_id]++);
42 object.header = this->
header;
44 object.info = this->
info;
45 object.state = this->
state;
49 hector_worldmodel_msgs::Object object;
66 pose.position.x = this->
position.x();
67 pose.position.y = this->
position.y();
68 pose.position.z = this->
position.z();
104 this->position << position.x, position.y, position.z;
109 this->position << position.
x(), position.
y(), position.
z();
119 this->orientation.coeffs() << orientation.x, orientation.y, orientation.z, orientation.w;
124 this->orientation.coeffs() << orientation.x(), orientation.y(), orientation.z(), orientation.w();
148 this->
covariance << tf[0][0], tf[0][1], tf[0][2],
149 tf[1][0], tf[1][1], tf[1][2],
150 tf[2][0], tf[2][1], tf[2][2];
154 this->covariance << covariance[0], covariance[1], covariance[2],
155 covariance[6], covariance[7], covariance[8],
156 covariance[12], covariance[13], covariance[14];
160 if (this->state.state == state)
return;
162 this->state.state =
state;
171 Eigen::Matrix3f A(
covariance.inverse() * omega);
172 Eigen::Matrix3f B(covarianceB.inverse() * (1.0f - omega));
174 double infB = 1./covarianceB.trace();
177 position =
covariance * (A * position + B * positionB);
191 Eigen::Matrix3f B(covarianceB.inverse());
193 double infB = 1./covarianceB.trace();
196 position =
covariance * (A * position + B * positionB);
208 q.
slerp(orientationB, slerp_factor);
218 visualization_msgs::Marker marker;
224 switch(this->
state.state) {
225 case hector_worldmodel_msgs::ObjectState::CONFIRMED:
226 marker.color.r = 0.0;
227 marker.color.g = 0.8;
228 marker.color.b = 0.0;
229 postfix =
" (CONFIRMED)";
231 case hector_worldmodel_msgs::ObjectState::DISCARDED:
232 marker.color.a = 0.5;
233 postfix =
" (DISCARDED)";
235 case hector_worldmodel_msgs::ObjectState::INACTIVE:
236 marker.color.a = 0.5;
237 postfix =
" (INACTIVE)";
239 case hector_worldmodel_msgs::ObjectState::UNKNOWN:
240 marker.color.a = 0.5;
242 case hector_worldmodel_msgs::ObjectState::PENDING:
243 marker.color.a = 0.5;
244 postfix =
" (PENDING)";
250 marker.header = this->
header;
251 marker.action = visualization_msgs::Marker::ADD;
253 marker.ns = this->
info.class_id;
255 marker.type = visualization_msgs::Marker::ARROW;
256 marker.scale.x = 1.0;
257 marker.scale.y = 1.0;
258 marker.scale.z = 1.0;
261 marker.type = visualization_msgs::Marker::SPHERE;
262 marker.scale.x = 0.1;
263 marker.scale.y = 0.1;
264 marker.scale.z = 0.1;
265 markers.markers.push_back(marker);
267 marker.type = visualization_msgs::Marker::TEXT_VIEW_FACING;
268 marker.text = (!this->
info.name.empty() ? this->
info.name : this->
info.object_id) + postfix;
269 marker.scale.x = 0.0;
270 marker.scale.y = 0.0;
271 marker.scale.z = 0.1;
272 marker.pose.position.z += 1.5 * marker.scale.z;
273 markers.markers.push_back(marker);
304 pose = transform * pose;
305 result->setPose(pose);
312 result->setCovariance(rotation * cov * rotation.transpose());
315 result->header.frame_id = target_frame;
void getPose(geometry_msgs::Pose &pose) const
Eigen::Matrix3f covariance
void setPosition(const Eigen::Vector3f &position)
void update(const tf::Pose &poseB, const Eigen::Matrix3f &covarianceB, float support)
ObjectPtr transform(tf::Transformer &tf, const std::string &target_frame) const
void intersect(const tf::Pose &poseB, const Eigen::Matrix3f &covarianceB, float support)
const Eigen::Matrix3f & getCovariance() const
const Eigen::Quaternionf & getOrientation() const
std::map< std::string, std_msgs::ColorRGBA > _marker_color
Object(const std::string class_id="", const std::string object_id="")
std::map< std::string, bool > _with_orientation
static void setNamespace(const std::string &ns)
Quaternion slerp(const Quaternion &q, const tfScalar &t) const
TFSIMD_FORCE_INLINE void setValue(const tfScalar &x, const tfScalar &y, const tfScalar &z)
void getRotation(Quaternion &q) const
void setRotation(const Quaternion &q)
const std::string & getClassId() const
void setOrientation(const geometry_msgs::Quaternion &orientation)
TFSIMD_FORCE_INLINE const tfScalar & x() const
void setState(const StateType &state)
hector_worldmodel_msgs::ObjectState::_state_type StateType
TFSIMD_FORCE_INLINE const tfScalar & z() const
const Eigen::Vector3f & getPosition() const
TFSIMD_FORCE_INLINE Quaternion inverse(const Quaternion &q)
TFSIMD_FORCE_INLINE const tfScalar & y() const
hector_worldmodel_msgs::Object getMessage() const
static const char * getObjectStateString(const ObjectState::_state_type &state)
Object & operator=(const hector_worldmodel_msgs::Object &other)
Eigen::Quaternionf orientation
static std::map< std::string, unsigned int > object_count
void updateOrientation(const tf::Quaternion &orientationB, double slerp_factor)
static T & parameter(std::map< std::string, T > &p, const std::string &class_id=std::string())
const std::string & getObjectId() const
void getPoseWithCovariance(geometry_msgs::PoseWithCovariance &pose) const
void getVisualization(visualization_msgs::MarkerArray &markers) const
double getDistance(const Object &other)
static std::string object_namespace
void setPose(const geometry_msgs::PoseWithCovariance &pose)
void addSupport(float support)
void setCovariance(const Eigen::Matrix3f &covariance)