39 const vector<wire_msgs::Property>& props,
40 vector<visualization_msgs::Marker>& markers_out,
41 const std::string& frame_id =
"" ) {
50 string marker_text =
"", class_label =
"", color =
"";
58 bool pos_found =
false;
64 if (it_prop->attribute ==
"position") {
80 ROS_WARN(
"World evidence: position attribute has %d dimensions, Visualizer cannot deal with this.",
86 else if (it_prop->attribute ==
"orientation") {
94 ROS_WARN(
"Orientation attribute has %d dimensions, must be 4 (X Y Z W).", pdf->
dimensions());
98 else if (it_prop->attribute ==
"class_label") {
102 else if (it_prop->attribute ==
"color") {
108 if (it_prop->attribute == it->first && it->second) {
114 if (marker_text !=
"") {
136 string map_key =
"default";
137 visualization_msgs::Marker marker;
138 visualization_msgs::Marker text_marker;
140 map_key = class_label;
158 marker.header.frame_id = frame_id;
159 text_marker.header.frame_id = frame_id;
162 ev_pose_TRANSFORMED = ev_pose;
163 marker.header.frame_id = header.frame_id;
164 text_marker.header.frame_id = header.frame_id;
167 ev_pose_TRANSFORMED = ev_pose;
168 marker.header.frame_id = header.frame_id;
169 text_marker.header.frame_id = header.frame_id;
173 marker.pose.position.x = ev_pose_TRANSFORMED.getOrigin().getX();
174 marker.pose.position.y = ev_pose_TRANSFORMED.getOrigin().getY();
175 marker.pose.position.z = ev_pose_TRANSFORMED.getOrigin().getZ();
176 marker.header.stamp = header.stamp;
178 markers_out.push_back(marker);
183 text_marker.pose.position.x += ev_pose_TRANSFORMED.getOrigin().getX();
184 text_marker.pose.position.y += ev_pose_TRANSFORMED.getOrigin().getY();
185 text_marker.pose.position.z += ev_pose_TRANSFORMED.getOrigin().getZ();
186 text_marker.header.stamp = header.stamp;
187 text_marker.id = 3 * ID + 1;
193 string id_text =
" (" + ss.str() +
")";
194 marker_text += id_text;
198 text_marker.text = marker_text;
199 markers_out.push_back(text_marker);
204 visualization_msgs::Marker cov_marker = marker;
205 cov_marker.color.a *= 0.5;
206 cov_marker.scale.x *= (1 +
sqrt(cov_xx) * 3);
207 cov_marker.scale.y *= (1 +
sqrt(cov_yy) * 3);
208 cov_marker.scale.z *= (1 +
sqrt(cov_zz) * 3);
209 cov_marker.id = 3 * ID + 2;
210 markers_out.push_back(cov_marker);
235 double w_best = min_weight;
240 if (G && w > w_best) {
302 str = (std::string)v;
312 bool param =
false, att =
false;
316 return (param && att);
328 if (!n.
getParam(ns, marker_params)) {
340 for(
int i = 0; i < marker_params.
size(); ++i) {
349 string class_name =
"";
353 if (class_name ==
"") {
354 ROS_WARN(
"No class defined, skipping parameters");
357 else if (i==0 && class_name !=
"default") {
358 ROS_ERROR(
"Make sure to first specify default in YAML file");
362 else if (i==0 && class_name ==
"default") {
366 m.
shape_marker.action = visualization_msgs::Marker::ADD;
393 ROS_DEBUG(
"Added marker with class default to %s", ns.c_str());
400 m.
shape_marker.action = visualization_msgs::Marker::ADD;
426 ROS_DEBUG(
"Added marker with class %s to %s", class_name.c_str(), ns.c_str());
430 ROS_WARN(
"Parameter specification not a list (parameter ignored)!");
436 ROS_ERROR(
"Marker with class text must be defined!");
443 it->second.text_marker = default_text_marker;
444 it->second.text_marker.type = visualization_msgs::Marker::TEXT_VIEW_FACING;
458 m.
shape_marker.type = visualization_msgs::Marker::MESH_RESOURCE;
469 std::transform(marker_type.begin(), marker_type.end(), marker_type.begin(), ::tolower);
472 if (marker_type ==
"cube") {
474 }
else if (marker_type ==
"cylinder") {
475 m.
shape_marker.type = visualization_msgs::Marker::CYLINDER;
476 }
else if (marker_type ==
"arrow") {
477 m.
shape_marker.type = visualization_msgs::Marker::ARROW;
478 }
else if (marker_type ==
"sphere") {
479 m.
shape_marker.type = visualization_msgs::Marker::SPHERE;
481 ROS_WARN(
"Defined marker type %s, which is unknown. Using sphere instead.", marker_type.c_str());
482 m.
shape_marker.type = visualization_msgs::Marker::SPHERE;
496 string param_name = ns +
"_attributes";
500 if (!n.
getParam(param_name, attribute_params)) {
501 ROS_ERROR(
"No global \"%s\" parameters given. (namespace: %s)", param_name.c_str(), n.
getNamespace().c_str());
507 ROS_ERROR(
"Malformed \"attributes\" parameter specification. (namespace: %s)", n.
getNamespace().c_str());
512 for(
int i = 0; i < attribute_params.
size(); ++i) {
518 ROS_DEBUG(
"Attributes for %s:", ns.c_str());
520 string att_name =
static_cast<string>(it->first);
521 bool att_bool =
static_cast<int>(it->second);
523 ROS_DEBUG(
" %s will %s shown", att_name.c_str(), att_bool?
"be":
"not be");
double DEFAULT_OFFSET_X_ROT
tf::TransformListener * tf_listener_
PDF * msgToPDF(const problib::PDF &msg)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val)
std::map< std::string, bool > attribute_map_
double DEFAULT_OFFSET_Y_ROT
ValueStruct::iterator iterator
arma_inline const eOp< T1, eop_sqrt > sqrt(const Base< typename T1::elem_type, T1 > &A)
visualization_msgs::Marker shape_marker
bool getAttributeSettings(ros::NodeHandle &n, const std::string &ns)
virtual bool getExpectedValue(std::string &v) const
bool getMarkerParameters(ros::NodeHandle &n, const std::string &ns)
void setTFListener(tf::TransformListener *tf_listener)
std::map< std::string, MarkerInfo > object_class_to_marker_map_
arma_inline const Op< T1, op_mean > mean(const Base< typename T1::elem_type, T1 > &X, const uword dim=0)
Type const & getType() const
iterator(field< oT > &in_M, const bool at_end=false)
const arma::mat & getCovariance() const
visualization_msgs::Marker text_marker
bool setParameters(ros::NodeHandle &n, const std::string &ns)
double DEFAULT_OFFSET_Z_ROT
const pbl::Gaussian * getBestGaussian(const pbl::PDF &pdf, double min_weight=0)
const PDF & getComponent(int i) const
const_iterator(const field< oT > &in_M, const bool at_end=false)
const arma::vec & getMean() const
const std::string & getNamespace() const
double DEFAULT_OFFSET_Y_POS
double DEFAULT_OFFSET_Z_POS
void getStructValue(XmlRpc::XmlRpcValue &s, const std::string &name, float &f, float default_value)
bool createMarkers(const std_msgs::Header &header, long ID, const std::vector< wire_msgs::Property > &props, std::vector< visualization_msgs::Marker > &markers_out, const std::string &frame_id)
std::map< std::string, Color > color_mapping_
double DEFAULT_OFFSET_W_ROT
TFSIMD_FORCE_INLINE const tfScalar & w() const
double getWeight(int i) const
double DEFAULT_OFFSET_X_POS
const Mixture * PDFtoMixture(const PDF &pdf)
bool getParam(const std::string &key, std::string &s) const
double DEFAULT_COLOR_ALPHA
void setMarkerType(XmlRpc::XmlRpcValue &v, MarkerInfo &m)
const Gaussian * PDFtoGaussian(const PDF &pdf)
double DEFAULT_MARKER_LIFETIME