58 std::replace(ns.begin(), ns.end(),
'/',
'_');
74 catch (
const std::exception& ex)
76 ROS_FATAL(
"Exception during destruction of Visualization: %s", ex.what());
80 ROS_FATAL(
"Exception during destruction of Visualization");
88 i.action = visualization_msgs::Marker::DELETE;
97 for (
const auto&
t : tags)
107 visualization_msgs::Marker marker;
108 marker.header.stamp = tag.header.stamp;
109 marker.header.frame_id =
tf_prefix_ + tag.tag.id +
'_' + tag.instance_id;
110 marker.id =
static_cast<int32_t
>(std::stol(tag.instance_id) % std::numeric_limits<int32_t>::max());
112 marker.type = visualization_msgs::Marker::CUBE;
114 marker.scale.x = tag.tag.size;
115 marker.scale.y = tag.tag.size;
116 marker.scale.z = 0.001;
117 marker.pose.orientation.w = 1;
118 marker.pose.position.x = tag.tag.size / 2;
119 marker.pose.position.y = tag.tag.size / 2;
120 marker.pose.position.z = 0.001 / 2;
121 marker.color.a = 0.5;
122 marker.color.r = 0.0;
123 marker.color.g = 1.0;
124 marker.color.b = 0.0;
130 geometry_msgs::TransformStamped
tf;
131 tf.header.frame_id =
tf_prefix_ + tag.header.frame_id;
132 tf.child_frame_id =
tf_prefix_ + tag.tag.id +
'_' + tag.instance_id;
133 tf.header.stamp = tag.header.stamp;
134 tf.transform.translation.x = tag.pose.pose.position.x;
135 tf.transform.translation.y = tag.pose.pose.position.y;
136 tf.transform.translation.z = tag.pose.pose.position.z;
137 tf.transform.rotation.x = tag.pose.pose.orientation.x;
138 tf.transform.rotation.y = tag.pose.pose.orientation.y;
139 tf.transform.rotation.z = tag.pose.pose.orientation.z;
140 tf.transform.rotation.w = tag.pose.pose.orientation.w;
ros::Publisher tag_marker_pub_
void publishTags(const std::vector< rc_tagdetect_client::DetectedTag > &tags)
static std::string make_tf_prefix(const ros::NodeHandle &nh)
void publish(const boost::shared_ptr< M > &message) const
geometry_msgs::TransformStamped createTf(const rc_tagdetect_client::DetectedTag &tag) const
geometry_msgs::TransformStamped t
visualization_msgs::MarkerArray markers_
ROSCPP_DECL const std::string & getNamespace()
Visualization(const ros::NodeHandle &nh)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
visualization_msgs::Marker createMarker(const rc_tagdetect_client::DetectedTag &tag) const
tf2_ros::TransformBroadcaster transform_broadcaster_