message_context.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  * 
00029  * Author: David Gossow
00030  *//*
00031  * message_context.h
00032  *
00033  *  Created on: Jul 17, 2012
00034  *      Author: gossow
00035  */
00036 
00037 #ifndef MESSAGE_CONTEXT_H_
00038 #define MESSAGE_CONTEXT_H_
00039 
00040 #include <tf/tf.h>
00041 
00042 #include <visualization_msgs/InteractiveMarkerInit.h>
00043 #include <visualization_msgs/InteractiveMarkerUpdate.h>
00044 
00045 namespace interactive_markers
00046 {
00047 
00048 template<class MsgT>
00049 class MessageContext
00050 {
00051 public:
00052   MessageContext( tf::Transformer& tf,
00053       const std::string& target_frame,
00054       const typename MsgT::ConstPtr& msg,
00055       bool enable_autocomplete_transparency = true);
00056 
00057   MessageContext<MsgT>& operator=( const MessageContext<MsgT>& other );
00058 
00059   // transform all messages with timestamp into target frame
00060   void getTfTransforms();
00061 
00062   typename MsgT::Ptr msg;
00063 
00064   // return true if tf info is complete
00065   bool isReady();
00066 
00067 private:
00068 
00069   void init();
00070 
00071   bool getTransform( std_msgs::Header& header, geometry_msgs::Pose& pose_msg );
00072 
00073   void getTfTransforms( std::vector<visualization_msgs::InteractiveMarker>& msg_vec, std::list<size_t>& indices );
00074   void getTfTransforms( std::vector<visualization_msgs::InteractiveMarkerPose>& msg_vec, std::list<size_t>& indices );
00075 
00076   // array indices of marker/pose updates with missing tf info
00077   std::list<size_t> open_marker_idx_;
00078   std::list<size_t> open_pose_idx_;
00079   tf::Transformer& tf_;
00080   std::string target_frame_;
00081   bool enable_autocomplete_transparency_;
00082 };
00083 
00084 class InitFailException: public tf::TransformException
00085 {
00086 public:
00087   InitFailException(const std::string errorDescription) : tf::TransformException(errorDescription) { ; }
00088 };
00089 
00090 
00091 }
00092 
00093 #endif /* MESSAGE_CONTEXT_H_ */


interactive_markers
Author(s): David Gossow
autogenerated on Mon Oct 6 2014 00:57:29