vertex_pose.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2016,
6  * TU Dortmund - Institute of Control Theory and Systems Engineering.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of the institute nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  * Notes:
37  * The following class is derived from a class defined by the
38  * g2o-framework. g2o is licensed under the terms of the BSD License.
39  * Refer to the base class source for detailed licensing information.
40  *
41  * Author: Christoph Rösmann
42  *********************************************************************/
43 
44 #ifndef VERTEX_POSE_H_
45 #define VERTEX_POSE_H_
46 
47 #include <g2o/config.h>
48 #include <g2o/core/base_vertex.h>
49 #include <g2o/core/hyper_graph_action.h>
50 #include <g2o/stuff/misc.h>
51 
53 
54 namespace teb_local_planner
55 {
56 
63 class VertexPose : public g2o::BaseVertex<3, PoseSE2 >
64 {
65 public:
66 
71  VertexPose(bool fixed = false)
72  {
74  setFixed(fixed);
75  }
76 
82  VertexPose(const PoseSE2& pose, bool fixed = false)
83  {
84  _estimate = pose;
85  setFixed(fixed);
86  }
87 
94  VertexPose(const Eigen::Ref<const Eigen::Vector2d>& position, double theta, bool fixed = false)
95  {
96  _estimate.position() = position;
97  _estimate.theta() = theta;
98  setFixed(fixed);
99  }
100 
108  VertexPose(double x, double y, double theta, bool fixed = false)
109  {
110  _estimate.x() = x;
111  _estimate.y() = y;
112  _estimate.theta() = theta;
113  setFixed(fixed);
114  }
115 
121  inline PoseSE2& pose() {return _estimate;}
122 
128  inline const PoseSE2& pose() const {return _estimate;}
129 
130 
136  inline Eigen::Vector2d& position() {return _estimate.position();}
137 
143  inline const Eigen::Vector2d& position() const {return _estimate.position();}
144 
149  inline double& x() {return _estimate.x();}
150 
155  inline const double& x() const {return _estimate.x();}
156 
161  inline double& y() {return _estimate.y();}
162 
167  inline const double& y() const {return _estimate.y();}
168 
173  inline double& theta() {return _estimate.theta();}
174 
179  inline const double& theta() const {return _estimate.theta();}
180 
184  virtual void setToOriginImpl() override
185  {
186  _estimate.setZero();
187  }
188 
195  virtual void oplusImpl(const double* update) override
196  {
197  _estimate.plus(update);
198  }
199 
206  virtual bool read(std::istream& is) override
207  {
208  is >> _estimate.x() >> _estimate.y() >> _estimate.theta();
209  return true;
210  }
211 
218  virtual bool write(std::ostream& os) const override
219  {
220  os << _estimate.x() << " " << _estimate.y() << " " << _estimate.theta();
221  return os.good();
222  }
223 
224  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
225 };
226 
227 }
228 
229 #endif // VERTEX_POSE_H_
teb_local_planner::VertexPose::theta
double & theta()
Access the orientation part (yaw angle) of the pose.
Definition: vertex_pose.h:214
teb_local_planner::VertexPose::read
virtual bool read(std::istream &is) override
Read an estimate from an input stream. First the x-coordinate followed by y and the yaw angle.
Definition: vertex_pose.h:247
teb_local_planner::VertexPose::pose
PoseSE2 & pose()
Access the pose.
Definition: vertex_pose.h:162
teb_local_planner::VertexPose::setToOriginImpl
virtual void setToOriginImpl() override
Set the underlying estimate (2D vector) to zero.
Definition: vertex_pose.h:225
teb_local_planner::VertexPose::x
double & x()
Access the x-coordinate the pose.
Definition: vertex_pose.h:190
teb_local_planner::VertexPose::oplusImpl
virtual void oplusImpl(const double *update) override
Define the update increment . A simple addition for the position. The angle is first added to the pre...
Definition: vertex_pose.h:236
teb_local_planner::VertexPose::write
virtual bool write(std::ostream &os) const override
Write the estimate to an output stream First the x-coordinate followed by y and the yaw angle.
Definition: vertex_pose.h:259
update
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
teb_local_planner::VertexPose::y
double & y()
Access the y-coordinate the pose.
Definition: vertex_pose.h:202
teb_local_planner::PoseSE2
This class implements a pose in the domain SE2: The pose consist of the position x and y and an orie...
Definition: pose_se2.h:93
teb_local_planner::VertexPose::position
Eigen::Vector2d & position()
Access the 2D position part.
Definition: vertex_pose.h:177
teb_local_planner::VertexPose::VertexPose
VertexPose(bool fixed=false)
Default constructor.
Definition: vertex_pose.h:112
pose_se2.h
teb_local_planner
Definition: distance_calculations.h:46


teb_local_planner
Author(s): Christoph Rösmann
autogenerated on Sun Jan 7 2024 03:45:15