dubins_state_space.hpp
Go to the documentation of this file.
1 /*********************************************************************
2 * Copyright (c) 2017 - for information on the respective copyright
3 * owner see the NOTICE file and/or the repository
4 *
5 * https://github.com/hbanzhaf/steering_functions.git
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16 * implied. See the License for the specific language governing
17 * permissions and limitations under the License.
18 
19 * This source code is derived from the Open Motion Planning Library
20 * (OMPL) V 1.3.1 (https://github.com/ompl/ompl).
21 * Copyright (c) 2010, Rice University, licensed under the BSD license,
22 * cf. 3rd-party-licenses.txt file in the root directory of this source
23 * tree.
24 **********************************************************************/
25 
26 /*********************************************************************
27 * Software License Agreement (BSD License)
28 *
29 * Copyright (c) 2010, Rice University
30 * All rights reserved.
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
34 * are met:
35 *
36 * * Redistributions of source code must retain the above copyright
37 * notice, this list of conditions and the following disclaimer.
38 * * Redistributions in binary form must reproduce the above
39 * copyright notice, this list of conditions and the following
40 * disclaimer in the documentation and/or other materials provided
41 * with the distribution.
42 * * Neither the name of the Rice University nor the names of its
43 * contributors may be used to endorse or promote products derived
44 * from this software without specific prior written permission.
45 *
46 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
47 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
48 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
49 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
50 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
51 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
52 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
53 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
56 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
57 * POSSIBILITY OF SUCH DAMAGE.
58 *********************************************************************/
59 
60 #ifndef __DUBINS_STATE_SPACE_HPP_
61 #define __DUBINS_STATE_SPACE_HPP_
62 
63 #include <cassert>
64 #include <limits>
65 #include <vector>
66 
69 
70 namespace steering
71 {
72 
87 {
88 public:
91  {
92  DUBINS_LEFT = 0,
93  DUBINS_STRAIGHT = 1,
94  DUBINS_RIGHT = 2
95  };
96 
98  static const Dubins_Path_Segment_Type dubins_path_type[6][3];
99 
101  class Dubins_Path
102  {
103  public:
105  Dubins_Path(const Dubins_Path_Segment_Type *type = dubins_path_type[0], double t = 0.,
106  double p = std::numeric_limits<double>::max(), double q = 0.)
107  : type_(type)
108  {
109  length_[0] = t;
110  length_[1] = p;
111  length_[2] = q;
112  assert(t >= 0.);
113  assert(p >= 0.);
114  assert(q >= 0.);
115  }
116 
117  double length() const
118  {
119  return length_[0] + length_[1] + length_[2];
120  }
121 
122  private:
125 
127  double length_[3];
128 
129  friend class Dubins_State_Space;
130  };
131 
133  Dubins_State_Space(double kappa, double discretization = 0.1, bool forwards = true)
134  : kappa_(kappa), discretization_(discretization), forwards_(forwards)
135  {
136  assert(kappa > 0.0 && discretization > 0.0);
137  kappa_inv_ = 1 / kappa;
138  }
139 
141  void set_filter_parameters(const Motion_Noise &motion_noise, const Measurement_Noise &measurement_noise,
142  const Controller &controller);
143 
145  Dubins_Path dubins(const State &state1, const State &state2) const;
146 
148  double get_distance(const State &state1, const State &state2) const;
149 
151  std::vector<Control> get_controls(const State &state1, const State &state2) const;
152 
154  std::vector<State> get_path(const State &state1, const State &state2) const;
155 
157  std::vector<State_With_Covariance> get_path_with_covariance(const State_With_Covariance &state1,
158  const State &state2) const;
159 
161  std::vector<State> integrate(const State &state, const std::vector<Control> &controls) const;
162 
164  std::vector<State_With_Covariance> integrate_with_covariance(const State_With_Covariance &state,
165  const std::vector<Control> &controls) const;
166 
168  State interpolate(const State &state, const std::vector<Control> &controls, double t) const;
169 
171  inline State integrate_ODE(const State &state, const Control &control, double integration_step) const;
172 
173 private:
175  double kappa_;
176 
178  double kappa_inv_;
179 
181  double discretization_;
182 
184  bool forwards_;
185 
187  EKF ekf_;
188 };
189 
190 } // namespace steering
191 
192 #endif
steering::Dubins_State_Space::Dubins_State_Space
Dubins_State_Space(double kappa, double discretization=0.1, bool forwards=true)
Constructor of the Dubins_State_Space.
Definition: dubins_state_space.hpp:243
steering::Dubins_State_Space::ekf_
EKF ekf_
Extended Kalman Filter for uncertainty propagation.
Definition: dubins_state_space.hpp:297
steering::Dubins_State_Space::get_path
std::vector< State > get_path(const State &state1, const State &state2) const
Returns shortest path from state1 to state2 with curvature = kappa_.
Definition: dubins_state_space.cpp:291
steering::State
Description of a kinematic car's state.
Definition: steering_functions.hpp:44
steering::Dubins_State_Space::dubins_path_type
static const Dubins_Path_Segment_Type dubins_path_type[6][3]
Dubins path types.
Definition: dubins_state_space.hpp:208
steering::Dubins_State_Space
An SE(2) state space where distance is measured by the length of Dubins curves. Note that this Dubins...
Definition: dubins_state_space.hpp:141
steering::Dubins_State_Space::dubins
Dubins_Path dubins(const State &state1, const State &state2) const
Returns type and length of segments of path from state1 to state2 with curvature = 1....
Definition: dubins_state_space.cpp:228
steering::Dubins_State_Space::Dubins_Path::type_
const Dubins_Path_Segment_Type * type_
Definition: dubins_state_space.hpp:234
steering::Dubins_State_Space::interpolate
State interpolate(const State &state, const std::vector< Control > &controls, double t) const
Returns interpolated state at distance t in [0,1] (percent of total path length with curvature = kapp...
Definition: dubins_state_space.cpp:421
steering::Dubins_State_Space::set_filter_parameters
void set_filter_parameters(const Motion_Noise &motion_noise, const Measurement_Noise &measurement_noise, const Controller &controller)
Sets the parameters required by the filter.
Definition: dubins_state_space.cpp:235
steering::Dubins_State_Space::get_controls
std::vector< Control > get_controls(const State &state1, const State &state2) const
Returns controls of the shortest path from state1 to state2 with curvature = kappa_.
Definition: dubins_state_space.cpp:249
steering::Dubins_State_Space::Dubins_Path::Dubins_Path
Dubins_Path(const Dubins_Path_Segment_Type *type=dubins_path_type[0], double t=0., double p=std::numeric_limits< double >::max(), double q=0.)
Constructor of the Dubins_Path.
Definition: dubins_state_space.hpp:215
ekf.hpp
steering::Dubins_State_Space::Dubins_Path::length_
double length_[3]
Definition: dubins_state_space.hpp:237
steering::Dubins_State_Space::kappa_inv_
double kappa_inv_
Inverse of curvature.
Definition: dubins_state_space.hpp:288
steering::Control
Description of a path segment with its corresponding control inputs.
Definition: steering_functions.hpp:82
steering::Dubins_State_Space::integrate_ODE
State integrate_ODE(const State &state, const Control &control, double integration_step) const
Returns integrated state given a start state, a control, and an integration step.
Definition: dubins_state_space.cpp:484
steering::Dubins_State_Space::Dubins_Path
Complete description of a Dubins path.
Definition: dubins_state_space.hpp:211
steering::Dubins_State_Space::DUBINS_RIGHT
@ DUBINS_RIGHT
Definition: dubins_state_space.hpp:259
steering::Dubins_State_Space::Dubins_Path::length
double length() const
Definition: dubins_state_space.hpp:227
steering::Motion_Noise
Parameters of the motion noise model according to the book: Probabilistic Robotics,...
Definition: steering_functions.hpp:96
steering::Dubins_State_Space::integrate_with_covariance
std::vector< State_With_Covariance > integrate_with_covariance(const State_With_Covariance &state, const std::vector< Control > &controls) const
Returns integrated states including covariance given a start state and controls with curvature = kapp...
Definition: dubins_state_space.cpp:353
steering::Dubins_State_Space::forwards_
bool forwards_
Driving direction.
Definition: dubins_state_space.hpp:294
steering::Dubins_State_Space::get_path_with_covariance
std::vector< State_With_Covariance > get_path_with_covariance(const State_With_Covariance &state1, const State &state2) const
Returns shortest path including covariances from state1 to state2 with curvature = kappa_.
Definition: dubins_state_space.cpp:297
steering::EKF
Definition: ekf.hpp:48
steering::Dubins_State_Space::kappa_
double kappa_
Curvature.
Definition: dubins_state_space.hpp:285
steering::Dubins_State_Space::discretization_
double discretization_
Discretization of path.
Definition: dubins_state_space.hpp:291
steering_functions.hpp
plot_states.kappa
kappa
Definition: plot_states.py:106
steering::State_With_Covariance
Description of a kinematic car's state with covariance.
Definition: steering_functions.hpp:63
steering::Controller
Parameters of the feedback controller.
Definition: steering_functions.hpp:121
steering::Dubins_State_Space::integrate
std::vector< State > integrate(const State &state, const std::vector< Control > &controls) const
Returns integrated states given a start state and controls with curvature = kappa_.
Definition: dubins_state_space.cpp:304
steering
Definition: dubins_state_space.hpp:70
steering::Dubins_State_Space::DUBINS_LEFT
@ DUBINS_LEFT
Definition: dubins_state_space.hpp:257
steering::Dubins_State_Space::DUBINS_STRAIGHT
@ DUBINS_STRAIGHT
Definition: dubins_state_space.hpp:258
t
geometry_msgs::TransformStamped t
steering::Measurement_Noise
Parameters of the measurement noise.
Definition: steering_functions.hpp:108
steering::Dubins_State_Space::get_distance
double get_distance(const State &state1, const State &state2) const
Returns shortest path length from state1 to state2 with curvature = kappa_.
Definition: dubins_state_space.cpp:241
steering::Dubins_State_Space::Dubins_Path_Segment_Type
Dubins_Path_Segment_Type
The Dubins path segment type.
Definition: dubins_state_space.hpp:200


steering_functions
Author(s): Holger Banzhaf
autogenerated on Mon Dec 11 2023 03:27:43