12 std::string scans_topic;
17 private_nh.
getParam(
"scans_topic", scans_topic);
21 _rviz->enableBatchPublishing();
24 _srv = std::make_shared<Cfg>(private_nh);
40 _rviz->enableBatchPublishing();
43 _rviz->waitForSubscriber(marker_pub, 3);
64 ROS_INFO(
"Update skipped: Parameter not recognized");
68 if (cfg.lifetime == 0)
78 _rviz->setGlobalScale(cfg.scale);
80 ROS_INFO(
"Marker settings initialized");
94 std_msgs::ColorRGBA color;
104 color =
_rviz->getColor(rviz_visual_tools::colors::RED);
108 for (
auto it = msg->points.begin(); it != msg->points.end(); ++it)
111 toposens_msgs::TsPoint pt = *it;
114 geometry_msgs::PointStamped ps;
115 ps.point.x = pt.location.x;
116 ps.point.y = pt.location.y;
117 ps.point.z = pt.location.z;
118 ps.header.frame_id = msg->header.frame_id;
128 ROS_ERROR(
"TsPoint transformation failed: %s", ex.what());
132 pt.location.x = ps.point.x;
133 pt.location.y = ps.point.y;
134 pt.location.z = ps.point.z;
139 color =
_rviz->getColorScale(pt.location.x / std::max(
_color_range, pt.location.x));
146 color =
_rviz->getColorScale(0);
158 color =
_rviz->getColorScale(0);
166 Eigen::Vector3d location =
_rviz->convertPoint32(pt.location);
167 geometry_msgs::Vector3 scale =
_rviz->getScale(
_baseScale, pt.intensity);
168 if (scale.x > 0)
_rviz->publishSphere(location, color, scale,
kMarkersNs);
183 float color_scale = tf->transforms.size() - 1;
184 if (color_scale == 0)
188 for (
int i = 0; i < tf->transforms.size(); i++)
190 if (!strncmp(tf->transforms[i].header.frame_id.c_str(),
_target_frame.c_str(),
193 geometry_msgs::Pose pose;
194 pose.position.x = tf->transforms[i].transform.translation.x;
195 pose.position.y = tf->transforms[i].transform.translation.y;
196 pose.position.z = tf->transforms[i].transform.translation.z;
197 pose.orientation.x = tf->transforms[i].transform.rotation.x;
198 pose.orientation.y = tf->transforms[i].transform.rotation.y;
199 pose.orientation.z = tf->transforms[i].transform.rotation.z;
200 pose.orientation.w = tf->transforms[i].transform.rotation.w;
201 _pose_map[tf->transforms[i].child_frame_id] = pose;
203 _color_map[tf->transforms[i].child_frame_id] =
206 <<
", \tR: " <<
_color_map[tf->transforms[i].child_frame_id].r
207 <<
", G: " <<
_color_map[tf->transforms[i].child_frame_id].g
208 <<
", B: " <<
_color_map[tf->transforms[i].child_frame_id].b
209 <<
", A: " <<
_color_map[tf->transforms[i].child_frame_id].a
210 <<
" \t\t Position - X: " << pose.position.x <<
" \t Y: " << pose.position.y
211 <<
" \t Z: " << pose.position.z);
218 std::map<std::string, geometry_msgs::Pose>::iterator pose_it;
223 _rviz->setLifetime(0);
226 geometry_msgs::Pose label_pose;
227 label_pose.position.x = pose_it->second.position.x - .1;
228 label_pose.position.y = pose_it->second.position.y;
229 label_pose.position.z = pose_it->second.position.z;
230 label_pose.orientation.x = pose_it->second.orientation.x;
231 label_pose.orientation.y = pose_it->second.orientation.y;
232 label_pose.orientation.z = pose_it->second.orientation.z;
234 _rviz->publishAxis(pose_it->second, axis_scale);
237 _rviz->publishText(label_pose, pose_it->first, text_color, text_scale,
false);
245 _rviz->setLifetime(0);
246 geometry_msgs::Pose pose;
250 pose.orientation.x = 0;
251 pose.orientation.y = 0;
252 pose.orientation.z = 0;
253 pose.orientation.w = 0;
Plot(ros::NodeHandle nh, ros::NodeHandle private_nh)
void _plot(const toposens_msgs::TsScan::ConstPtr &msg)
void _reconfig(TsMarkersConfig &cfg, uint32_t level)
T & transform(const T &in, T &out, const std::string &target_frame, ros::Duration timeout=ros::Duration(0.0)) const
std::string _target_frame
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
tf2_ros::MessageFilter< toposens_msgs::TsScan > * _tf2_filter
void _staticTFCallback(const tf2_msgs::TFMessage::ConstPtr &tf)
std::map< std::string, rviz_visual_tools::colors > _mesh_color_map
ros::Subscriber _scans_sub
void publishDefaultSensorMesh()
static const std::string kMarkersTopic
tf2_ros::Buffer _tf2_buffer
bool getParam(const std::string &key, std::string &s) const
std::shared_ptr< Cfg > _srv
std::map< std::string, std_msgs::ColorRGBA > _color_map
Visualizes published TsScans as native Rviz markers. Subscribes to a topic publishing TsScans and con...
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
static const auto _baseScale
static const std::string kMarkersNs
rviz_visual_tools::RvizVisualToolsPtr _rviz
message_filters::Subscriber< toposens_msgs::TsScan > _tf2_scans_sub
std::map< std::string, geometry_msgs::Pose > _pose_map
#define ROS_INFO_STREAM(args)
void subscribe(ros::NodeHandle &nh, const std::string &topic, uint32_t queue_size, const ros::TransportHints &transport_hints=ros::TransportHints(), ros::CallbackQueueInterface *callback_queue=0)
void publishSensorMeshes()
tf2_ros::TransformListener * _tf2_listener
static const std::string kMeshNs
ros::Subscriber _static_tf_sub