route_point.h
Go to the documentation of this file.
00001 // *****************************************************************************
00002 //
00003 // Copyright (c) 2016, 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 #ifndef SWRI_ROUTE_UTIL_ROUTE_POINT_H_
00030 #define SWRI_ROUTE_UTIL_ROUTE_POINT_H_
00031 
00032 #include <string>
00033 #include <map>
00034 
00035 #include <tf/tf.h>
00036 
00037 #include <marti_nav_msgs/RoutePosition.h>
00038 
00039 namespace swri_route_util
00040 {
00041 // The RoutePoint class provides a more friendly interface for working
00042 // with the marti_nav_msgs::Route and marti_nav_msgs::RoutePoint
00043 // message types.  See comments for swri_route_util::RoutePoint for
00044 // more information.  This class is used to represent both route
00045 // points that are part of a Route, and independent points that were
00046 // interpolated from a Route.
00047 class RoutePoint
00048 {
00049  public:
00050   RoutePoint();
00051 
00052   // Access to the route point's position as tf datatypes.
00053   void setPosition(const tf::Vector3 &position);
00054   const tf::Vector3& position() const;
00055   tf::Vector3& position();
00056 
00057   // Access to the route point's position as message datatypes.
00058   void setPosition(const geometry_msgs::Point &position);
00059   const geometry_msgs::Point positionMsg() const;
00060 
00061   // Access to the route point's orientation as tf datatypes.
00062   void setOrientation(const tf::Quaternion &orientation);
00063   const tf::Quaternion& orientation() const;
00064   tf::Quaternion& orientation();
00065 
00066   // Access to the route point's orientation as message datatypes.
00067   void setOrientation(const geometry_msgs::Quaternion &orientation);
00068   const geometry_msgs::Quaternion orientationMsg() const;
00069 
00070   // Access to the route point's pose (position and orientation) as
00071   // tf datatypes.
00072   void setPose(const tf::Pose &pose);
00073   tf::Pose pose() const;
00074 
00075   // Access to the route point's pose (position and orientation) as
00076   // message datatypes.
00077   void setPose(const geometry_msgs::Pose &pose);
00078   geometry_msgs::Pose poseMsg() const;
00079 
00080   // Access to the route point's id.  Ids should be unique when used,
00081   // but are typically not set for interpolated points.
00082   const std::string& id() const;
00083   void setId(const std::string &id);
00084 
00085   // Native access to the route point "stop_point" property.  This is
00086   // a boolean property that defaults to false if it is not explicitly
00087   // defined in the route.
00088   bool stopPoint() const;
00089   void setStopPoint(bool value);
00090 
00091   // Native access to the route point "stop_point_delay" property.
00092   // This is a floating point value that specifies how long the
00093   // vehicle should be paused at the specific point, in seconds.  The
00094   // delay defaults to 0.0 if it not defined in the route.
00095   double stopPointDelay() const;
00096   void setStopPointDelay(double delay);
00097 
00098   // Return a marti_nav_msgs::RoutePosition message that corresponds to this point.
00099   marti_nav_msgs::RoutePosition routePosition() const;
00100 
00101   // The following methods provide general purpose access to route
00102   // point properties.  They will also correctly map to properties
00103   // that are exposed natively.  Native methods are generally faster
00104   // and safer and should be preferred when available.  Note: We have
00105   // not yet added any native properties for the route point.
00106 
00107   // Get a list of all the properties defined for this route point,
00108   // including native properties.
00109   std::vector<std::string> getPropertyNames() const;
00110   
00111   // Get the value of a property.  Returns an empty string if the
00112   // property does not exist.
00113   std::string getProperty(const std::string &name) const;
00114 
00115   // Get the value of a property, lexically cast to a known type.
00116   // Returns the lexical cast of an empty string if the property does
00117   // not exist..
00118   template <typename T>
00119   T getTypedProperty(const std::string &name) const;
00120 
00121   // Determine if the specified property is defined for the route
00122   // point.
00123   bool hasProperty(const std::string &name) const;
00124 
00125   // Set the value of a property.  If the property doesn't exist, it
00126   // is added.
00127   void setProperty(const std::string &name, const std::string &value);
00128 
00129   // Delete a property.  If the property doesn't exist or is not
00130   // deletable (e.g. name, guid), this method does nothing.
00131   void deleteProperty(const std::string &name);
00132   
00133  private:
00134   tf::Vector3 position_;
00135   tf::Quaternion orientation_;
00136 
00137   std::string id_;
00138 
00139   bool stop_point_;
00140   double stop_point_delay_;
00141 
00142   std::map<std::string, std::string> properties_;
00143 };  // class RoutePoint
00144 } // namespace swri_route_util
00145 
00146 #include "route_point_inline.h"
00147 
00148 #endif  // SWRI_ROUTE_UTIL_ROUTE_POINT_H_


swri_route_util
Author(s):
autogenerated on Thu Jun 6 2019 20:35:04