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;
55  tf::Vector3& position();
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:
134  tf::Vector3 position_;
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_
swri_route_util::RoutePoint::orientation
const tf::Quaternion & orientation() const
Definition: route_point_inline.h:75
swri_route_util::RoutePoint::orientationMsg
const geometry_msgs::Quaternion orientationMsg() const
Definition: route_point_inline.h:93
route_point_inline.h
swri_route_util::RoutePoint::position
const tf::Vector3 & position() const
Definition: route_point_inline.h:43
swri_route_util::RoutePoint::positionMsg
const geometry_msgs::Point positionMsg() const
Definition: route_point_inline.h:61
swri_route_util
Definition: path_util.h:35
swri_route_util::RoutePoint::setId
void setId(const std::string &id)
Definition: route_point_inline.h:139
swri_route_util::RoutePoint::id
const std::string & id() const
Definition: route_point_inline.h:133
swri_route_util::RoutePoint::setStopPointDelay
void setStopPointDelay(double delay)
Definition: route_point_inline.h:172
swri_route_util::RoutePoint::stop_point_delay_
double stop_point_delay_
Definition: route_point.h:140
swri_route_util::RoutePoint::poseMsg
geometry_msgs::Pose poseMsg() const
Definition: route_point_inline.h:124
swri_route_util::RoutePoint::stopPoint
bool stopPoint() const
Definition: route_point_inline.h:154
swri_route_util::RoutePoint::setPose
void setPose(const tf::Pose &pose)
Definition: route_point_inline.h:101
swri_route_util::RoutePoint::id_
std::string id_
Definition: route_point.h:137
tf::Transform
swri_route_util::RoutePoint::getPropertyNames
std::vector< std::string > getPropertyNames() const
Definition: route_point.cpp:39
swri_route_util::RoutePoint::getTypedProperty
T getTypedProperty(const std::string &name) const
Definition: route_point_inline.h:179
swri_route_util::RoutePoint::pose
tf::Pose pose() const
Definition: route_point_inline.h:108
swri_route_util::RoutePoint::deleteProperty
void deleteProperty(const std::string &name)
Definition: route_point.cpp:87
tf.h
swri_route_util::RoutePoint::position_
tf::Vector3 position_
Definition: route_point.h:134
swri_route_util::RoutePoint::setOrientation
void setOrientation(const tf::Quaternion &orientation)
Definition: route_point_inline.h:69
swri_route_util::RoutePoint
Definition: route_point.h:47
swri_route_util::RoutePoint::RoutePoint
RoutePoint()
Definition: route_point.cpp:33
swri_route_util::RoutePoint::setProperty
void setProperty(const std::string &name, const std::string &value)
Definition: route_point.cpp:76
swri_route_util::RoutePoint::hasProperty
bool hasProperty(const std::string &name) const
Definition: route_point.cpp:69
swri_route_util::RoutePoint::getProperty
std::string getProperty(const std::string &name) const
Definition: route_point.cpp:52
swri_route_util::RoutePoint::orientation_
tf::Quaternion orientation_
Definition: route_point.h:135
swri_route_util::RoutePoint::stopPointDelay
double stopPointDelay() const
Definition: route_point_inline.h:166
swri_route_util::RoutePoint::setStopPoint
void setStopPoint(bool value)
Definition: route_point_inline.h:160
swri_route_util::RoutePoint::setPosition
void setPosition(const tf::Vector3 &position)
Definition: route_point_inline.h:37
swri_route_util::RoutePoint::routePosition
marti_nav_msgs::RoutePosition routePosition() const
Definition: route_point_inline.h:145
swri_route_util::RoutePoint::properties_
std::map< std::string, std::string > properties_
Definition: route_point.h:142
tf::Quaternion
name
string name
swri_route_util::RoutePoint::stop_point_
bool stop_point_
Definition: route_point.h:139


swri_route_util
Author(s):
autogenerated on Fri Aug 2 2024 08:39:28