00001 /********************************************************************* 00002 * 00003 * Software License Agreement (BSD License) 00004 * 00005 * Copyright (c) 2011, Willow Garage, Inc. 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * * Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * * Redistributions in binary form must reproduce the above 00015 * copyright notice, this list of conditions and the following 00016 * disclaimer in the documentation and/or other materials provided 00017 * with the distribution. 00018 * * Neither the name of Willow Garage, Inc. nor the names of its 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00026 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00029 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00030 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00032 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00033 * POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 * Author: Sebastian Klose 00036 *********************************************************************/ 00037 00038 #ifndef IMU_FILTER_MARKER_VISUALIZATION_H 00039 #define IMU_FILTER_MARKER_VISUALIZATION_H 00040 00041 #include <ros/ros.h> 00042 #include <visualization_msgs/Marker.h> 00043 #include <Eigen/Geometry> 00044 00045 #include <imu_filter/imu_state.h> 00046 00047 namespace imu_filter 00048 { 00049 //* helper class for publishin visualization markers related to IMU 00053 class MarkerVisualization 00054 { 00055 public: 00056 ~MarkerVisualization(); 00057 00061 static MarkerVisualization & instance() 00062 { 00063 static MarkerVisualization instance; 00064 return instance; 00065 } 00066 00072 void addImuMarker( const ImuState & state, const Eigen::Vector3d & acceleration = Eigen::Vector3d::Zero() ); 00073 00078 void setAcceleration( const Eigen::Vector3d & acc ); 00079 00084 void setMeasuredAcc( const Eigen::Vector3d & acc ); 00085 00089 void publish() const; 00090 00091 private: 00092 MarkerVisualization( size_t bufferSize = 10, const std::string & imuFrameId = "/map" ); 00093 00094 // declare but not define! 00095 MarkerVisualization( const MarkerVisualization & ); 00096 MarkerVisualization & operator=( const MarkerVisualization & ); 00097 00098 size_t maxMarkers_; 00099 std::string imuFrameId_; 00100 size_t nextId_; 00101 00102 // list of markers 00103 typedef std::list<visualization_msgs::Marker> Container; 00104 Container marker_; 00105 00106 visualization_msgs::Marker gravityArrow_; 00107 visualization_msgs::Marker velocityArrow_; 00108 visualization_msgs::Marker accArrow_; 00109 visualization_msgs::Marker measAcc_; 00110 00111 // publisher 00112 ros::Publisher publisher_; 00113 00114 void updateMarkerPose( visualization_msgs::Marker & marker, 00115 const ImuState & state ); 00116 00117 void dump( visualization_msgs::Marker & m ); 00118 00119 int nextId(); 00120 }; 00121 } 00122 #endif