36 #include <boost/make_shared.hpp>
38 #define DBG_MSG( ... ) ROS_DEBUG( __VA_ARGS__ );
48 const typename MsgT::ConstPtr& _msg,
49 bool enable_autocomplete_transparency)
52 , enable_autocomplete_transparency_(enable_autocomplete_transparency)
55 msg = boost::make_shared<MsgT>( *_msg );
75 if (
header.frame_id != target_frame_ )
78 geometry_msgs::TransformStamped transform;
79 transform = tf_.lookupTransform( target_frame_,
header.frame_id,
header.stamp );
80 DBG_MSG(
"Transform %s -> %s at time %f is ready.",
header.frame_id.c_str(), target_frame_.c_str(),
header.stamp.toSec() );
87 header.frame_id = target_frame_;
94 std::string error_string;
96 tf_._getLatestCommonTime( tf_._lookupFrameNumber(target_frame_),
97 tf_._lookupFrameNumber(
header.frame_id),
98 latest_time, &error_string );
104 std::ostringstream
s;
105 s <<
"The init message contains an old timestamp and cannot be transformed ";
106 s <<
"('" <<
header.frame_id <<
"' to '" << target_frame_
107 <<
"' at time " <<
header.stamp <<
").";
119 std::list<size_t>::iterator idx_it;
120 for ( idx_it = indices.begin(); idx_it != indices.end(); )
122 visualization_msgs::InteractiveMarker& im_msg = msg_vec[ *idx_it ];
124 bool success = getTransform( im_msg.header, im_msg.pose );
126 for (
unsigned c = 0; c<im_msg.controls.size(); c++ )
128 visualization_msgs::InteractiveMarkerControl& ctrl_msg = im_msg.controls[c];
129 for (
unsigned m = 0; m<ctrl_msg.markers.size(); m++ )
131 visualization_msgs::Marker& marker_msg = ctrl_msg.markers[m];
132 if ( !marker_msg.header.frame_id.empty() ) {
133 success = success && getTransform( marker_msg.header, marker_msg.pose );
140 idx_it = indices.erase(idx_it);
144 DBG_MSG(
"Transform %s -> %s at time %f is not ready.", im_msg.header.frame_id.c_str(), target_frame_.c_str(), im_msg.header.stamp.toSec() );
153 std::list<size_t>::iterator idx_it;
154 for ( idx_it = indices.begin(); idx_it != indices.end(); )
156 visualization_msgs::InteractiveMarkerPose& msg = msg_vec[ *idx_it ];
157 if ( getTransform( msg.header, msg.pose ) )
159 idx_it = indices.erase(idx_it);
163 DBG_MSG(
"Transform %s -> %s at time %f is not ready.", msg.header.frame_id.c_str(), target_frame_.c_str(), msg.header.stamp.toSec() );
172 return open_marker_idx_.empty() && open_pose_idx_.empty();
179 for (
size_t i=0; i<msg->markers.size(); i++ )
181 open_marker_idx_.push_back( i );
183 for (
size_t i=0; i<msg->poses.size(); i++ )
185 open_pose_idx_.push_back( i );
187 for(
unsigned i=0; i<msg->markers.size(); i++ )
189 autoComplete( msg->markers[i], enable_autocomplete_transparency_ );
191 for(
unsigned i=0; i<msg->poses.size(); i++ )
194 if ( msg->poses[i].pose.orientation.w == 0 && msg->poses[i].pose.orientation.x == 0 &&
195 msg->poses[i].pose.orientation.y == 0 && msg->poses[i].pose.orientation.z == 0 )
197 msg->poses[i].pose.orientation.w = 1;
206 for (
size_t i=0; i<msg->markers.size(); i++ )
208 open_marker_idx_.push_back( i );
210 for(
unsigned i=0; i<msg->markers.size(); i++ )
212 autoComplete( msg->markers[i], enable_autocomplete_transparency_ );
219 getTfTransforms( msg->markers, open_marker_idx_ );
220 getTfTransforms( msg->poses, open_pose_idx_ );
223 DBG_MSG(
"Update message with seq_num=%lu is ready.", msg->seq_num );
230 getTfTransforms( msg->markers, open_marker_idx_ );
233 DBG_MSG(
"Init message with seq_num=%lu is ready.", msg->seq_num );