CaddyKML.hpp
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2010, LABUST, UNIZG-FER
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the LABUST nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  *  Author: Dula Nad
00035  *  Created: 01.02.2013.
00036  *********************************************************************/
00037 #ifndef CADDYKML_HPP_
00038 #define CADDYKML_HPP_
00039 
00040 #include <fstream>
00041 #include <deque>
00042 #include <labust/gearth/GoogleEarthLib.hpp>
00043 #include <labust/gearth/CustomLineString.hpp>
00044 #include <labust/gearth/VehiclePolygon.hpp>
00045 
00046 #include <ros/ros.h>
00047 #include <auv_msgs/NavSts.h>
00048 
00049 #include <boost/thread/mutex.hpp>
00050 #include <boost/thread.hpp>
00051 
00052 namespace labust
00053 {
00054   namespace gearth
00055   {
00069     class CaddyKML
00070     {
00071     public:
00075       CaddyKML();
00079       ~CaddyKML();
00080 
00086       void addVehiclePosition(const auv_msgs::NavSts::ConstPtr& nav)
00087       {
00088         kmlbase::Vec3 position(nav->global_position.longitude,
00089                         nav->global_position.latitude,
00090                         -nav->position.depth);
00091 
00092         boost::mutex::scoped_lock l(kml_mux);
00093         path.addPoint(position);
00094         vehicle.updatePosition(position,nav->orientation.yaw);
00095         diver= *nav;
00096         //this->write();
00097       }
00103       void addShipPosition(const auv_msgs::NavSts::ConstPtr& nav)
00104       {
00105         kmlbase::Vec3 position(nav->global_position.longitude,
00106                                 nav->global_position.latitude,
00107                                 -nav->position.depth);
00108         boost::mutex::scoped_lock l(kml_mux);
00109         ship.updatePosition(position,nav->orientation.yaw);
00110         platformPath.addPoint(position);
00111         platform = *nav;
00112         //this->write();
00113       }
00117       void setDiverOrigin(const geometry_msgs::Point::ConstPtr& point);
00121       void write();
00125       void run();
00126 
00127     private:
00131       void addOpRegionToDocument(kmldom::DocumentPtr document);
00135       void addVarianceRegion(const auv_msgs::NavSts& nav, kmldom::DocumentPtr document);
00139       CustomLineString<TransparentSegments> path, platformPath;
00143       VehiclePolygon vehicle;
00147       VehiclePolygon ship;
00151       kmldom::CoordinatesPtr opRegion;
00155       kmlbase::Vec3 diverOrigin;
00159       kmldom::KmlFactory* factory;
00163       kmldom::DocumentPtr folder;
00167       std::string filename;
00171       std::ofstream kmlFile;
00175       boost::mutex kml_mux;
00179       auv_msgs::NavSts diver, platform;
00183       boost::thread worker;
00187       bool runFlag;
00188     };
00189   }
00190 }
00191 /* CADDYKML_HPP_ */
00192 #endif


caddy_ui
Author(s): Gyula NagyJane Doe
autogenerated on Fri Feb 7 2014 11:36:10