route_point.h
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2016, Southwest Research Institute® (SwRI®)
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of Southwest Research Institute® (SwRI®) nor the
14 // names of its contributors may be used to endorse or promote products
15 // derived from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //
28 // *****************************************************************************
29 #ifndef SWRI_ROUTE_UTIL_ROUTE_POINT_H_
30 #define SWRI_ROUTE_UTIL_ROUTE_POINT_H_
31 
32 #include <string>
33 #include <map>
34 
35 #include <tf/tf.h>
36 
37 #include <marti_nav_msgs/RoutePosition.h>
38 
39 namespace swri_route_util
40 {
41 // The RoutePoint class provides a more friendly interface for working
42 // with the marti_nav_msgs::Route and marti_nav_msgs::RoutePoint
43 // message types. See comments for swri_route_util::RoutePoint for
44 // more information. This class is used to represent both route
45 // points that are part of a Route, and independent points that were
46 // interpolated from a Route.
48 {
49  public:
50  RoutePoint();
51 
52  // Access to the route point's position as tf datatypes.
53  void setPosition(const tf::Vector3 &position);
54  const tf::Vector3& position() const;
56 
57  // Access to the route point's position as message datatypes.
58  void setPosition(const geometry_msgs::Point &position);
59  const geometry_msgs::Point positionMsg() const;
60 
61  // Access to the route point's orientation as tf datatypes.
63  const tf::Quaternion& orientation() const;
65 
66  // Access to the route point's orientation as message datatypes.
67  void setOrientation(const geometry_msgs::Quaternion &orientation);
68  const geometry_msgs::Quaternion orientationMsg() const;
69 
70  // Access to the route point's pose (position and orientation) as
71  // tf datatypes.
72  void setPose(const tf::Pose &pose);
73  tf::Pose pose() const;
74 
75  // Access to the route point's pose (position and orientation) as
76  // message datatypes.
77  void setPose(const geometry_msgs::Pose &pose);
78  geometry_msgs::Pose poseMsg() const;
79 
80  // Access to the route point's id. Ids should be unique when used,
81  // but are typically not set for interpolated points.
82  const std::string& id() const;
83  void setId(const std::string &id);
84 
85  // Native access to the route point "stop_point" property. This is
86  // a boolean property that defaults to false if it is not explicitly
87  // defined in the route.
88  bool stopPoint() const;
89  void setStopPoint(bool value);
90 
91  // Native access to the route point "stop_point_delay" property.
92  // This is a floating point value that specifies how long the
93  // vehicle should be paused at the specific point, in seconds. The
94  // delay defaults to 0.0 if it not defined in the route.
95  double stopPointDelay() const;
96  void setStopPointDelay(double delay);
97 
98  // Return a marti_nav_msgs::RoutePosition message that corresponds to this point.
99  marti_nav_msgs::RoutePosition routePosition() const;
100 
101  // The following methods provide general purpose access to route
102  // point properties. They will also correctly map to properties
103  // that are exposed natively. Native methods are generally faster
104  // and safer and should be preferred when available. Note: We have
105  // not yet added any native properties for the route point.
106 
107  // Get a list of all the properties defined for this route point,
108  // including native properties.
109  std::vector<std::string> getPropertyNames() const;
110 
111  // Get the value of a property. Returns an empty string if the
112  // property does not exist.
113  std::string getProperty(const std::string &name) const;
114 
115  // Get the value of a property, lexically cast to a known type.
116  // Returns the lexical cast of an empty string if the property does
117  // not exist..
118  template <typename T>
119  T getTypedProperty(const std::string &name) const;
120 
121  // Determine if the specified property is defined for the route
122  // point.
123  bool hasProperty(const std::string &name) const;
124 
125  // Set the value of a property. If the property doesn't exist, it
126  // is added.
127  void setProperty(const std::string &name, const std::string &value);
128 
129  // Delete a property. If the property doesn't exist or is not
130  // deletable (e.g. name, guid), this method does nothing.
131  void deleteProperty(const std::string &name);
132 
133  private:
136 
137  std::string id_;
138 
141 
142  std::map<std::string, std::string> properties_;
143 }; // class RoutePoint
144 } // namespace swri_route_util
145 
146 #include "route_point_inline.h"
147 
148 #endif // SWRI_ROUTE_UTIL_ROUTE_POINT_H_
void setPose(const tf::Pose &pose)
string name
void setStopPointDelay(double delay)
std::map< std::string, std::string > properties_
Definition: route_point.h:142
marti_nav_msgs::RoutePosition routePosition() const
T getTypedProperty(const std::string &name) const
void deleteProperty(const std::string &name)
Definition: route_point.cpp:87
void setPosition(const tf::Vector3 &position)
tf::Quaternion orientation_
Definition: route_point.h:135
const geometry_msgs::Quaternion orientationMsg() const
void setId(const std::string &id)
bool hasProperty(const std::string &name) const
Definition: route_point.cpp:69
const std::string & id() const
const geometry_msgs::Point positionMsg() const
void setOrientation(const tf::Quaternion &orientation)
const tf::Vector3 & position() const
void setProperty(const std::string &name, const std::string &value)
Definition: route_point.cpp:76
const tf::Quaternion & orientation() const
std::string getProperty(const std::string &name) const
Definition: route_point.cpp:52
geometry_msgs::Pose poseMsg() const
std::vector< std::string > getPropertyNames() const
Definition: route_point.cpp:39


swri_route_util
Author(s):
autogenerated on Fri Jun 7 2019 22:06:09