route_plugin.h
Go to the documentation of this file.
00001 // *****************************************************************************
00002 //
00003 // Copyright (c) 2014, Southwest Research Institute® (SwRI®)
00004 // All rights reserved.
00005 //
00006 // Redistribution and use in source and binary forms, with or without
00007 // modification, are permitted provided that the following conditions are met:
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 Southwest Research Institute® (SwRI®) nor the
00014 //       names of its contributors may be used to endorse or promote products
00015 //       derived from 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 <COPYRIGHT HOLDER> BE LIABLE FOR ANY
00021 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00022 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00023 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00024 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00026 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027 //
00028 // *****************************************************************************
00029 
00030 #ifndef MAPVIZ_PLUGINS_ROUTE_PLUGIN_H_
00031 #define MAPVIZ_PLUGINS_ROUTE_PLUGIN_H_
00032 
00033 // C++ standard libraries
00034 #include <list>
00035 #include <string>
00036 #include <vector>
00037 
00038 #include <mapviz/mapviz_plugin.h>
00039 
00040 // QT libraries
00041 #include <QGLWidget>
00042 #include <QObject>
00043 #include <QWidget>
00044 
00045 // ROS libraries
00046 #include <ros/ros.h>
00047 #include <tf/transform_datatypes.h>
00048 #include <marti_nav_msgs/RoutePosition.h>
00049 #include <mapviz/map_canvas.h>
00050 #include <swri_route_util/route.h>
00051 
00052 // QT autogenerated files
00053 #include "ui_route_config.h"
00054 
00055 namespace mapviz_plugins
00056 {
00057   class RoutePlugin : public mapviz::MapvizPlugin
00058   {
00059     Q_OBJECT
00060 
00061    public:
00062     enum DrawStyle
00063     {
00064       LINES = 0,
00065       POINTS = 1
00066     };
00067 
00068     RoutePlugin();
00069     virtual ~RoutePlugin();
00070 
00071     bool Initialize(QGLWidget* canvas);
00072     void Shutdown()
00073     {
00074     }
00075 
00076     void Draw(double x, double y, double scale);
00077 
00078     void Transform() {};
00079 
00080     void LoadConfig(const YAML::Node& node, const std::string& path);
00081     void SaveConfig(YAML::Emitter& emitter, const std::string& path);
00082     void DrawStopWaypoint(double x, double y);
00083     void DrawRoute(const swri_route_util::Route &route);
00084     void DrawRoutePoint(const swri_route_util::RoutePoint &point);
00085 
00086     QWidget* GetConfigWidget(QWidget* parent);
00087 
00088    protected:
00089     void PrintError(const std::string& message);
00090     void PrintInfo(const std::string& message);
00091     void PrintWarning(const std::string& message);
00092 
00093    protected Q_SLOTS:
00094     void SelectTopic();
00095     void SelectPositionTopic();
00096     void TopicEdited();
00097     void PositionTopicEdited();
00098     void SetDrawStyle(QString style);
00099     void DrawIcon();
00100 
00101    private:
00102     Ui::route_config ui_;
00103     QWidget* config_widget_;
00104 
00105     DrawStyle draw_style_;
00106 
00107     std::string topic_;
00108     std::string position_topic_;
00109 
00110     ros::Subscriber route_sub_;
00111     ros::Subscriber position_sub_;
00112 
00113     swri_route_util::Route src_route_;
00114     marti_nav_msgs::RoutePositionConstPtr src_route_position_;
00115     
00116     void RouteCallback(const marti_nav_msgs::RouteConstPtr &msg);
00117     void PositionCallback(const marti_nav_msgs::RoutePositionConstPtr &msg);
00118   };
00119 }
00120 
00121 #endif  // MAPVIZ_PLUGINS_ROUTE_PLUGIN_H_


mapviz_plugins
Author(s): Marc Alban
autogenerated on Thu Aug 24 2017 02:46:09