trajectory.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2008, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
35 
36 namespace base_local_planner {
38  : xv_(0.0), yv_(0.0), thetav_(0.0), cost_(-1.0)
39  {
40  }
41 
42  Trajectory::Trajectory(double xv, double yv, double thetav, double time_delta, unsigned int num_pts)
43  : xv_(xv), yv_(yv), thetav_(thetav), cost_(-1.0), time_delta_(time_delta), x_pts_(num_pts), y_pts_(num_pts), th_pts_(num_pts)
44  {
45  }
46 
47  void Trajectory::getPoint(unsigned int index, double& x, double& y, double& th) const {
48  x = x_pts_[index];
49  y = y_pts_[index];
50  th = th_pts_[index];
51  }
52 
53  void Trajectory::setPoint(unsigned int index, double x, double y, double th){
54  x_pts_[index] = x;
55  y_pts_[index] = y;
56  th_pts_[index] = th;
57  }
58 
59  void Trajectory::addPoint(double x, double y, double th){
60  x_pts_.push_back(x);
61  y_pts_.push_back(y);
62  th_pts_.push_back(th);
63  }
64 
66  x_pts_.clear();
67  y_pts_.clear();
68  th_pts_.clear();
69  }
70 
71  void Trajectory::getEndpoint(double& x, double& y, double& th) const {
72  x = x_pts_.back();
73  y = y_pts_.back();
74  th = th_pts_.back();
75  }
76 
77  unsigned int Trajectory::getPointsSize() const {
78  return x_pts_.size();
79  }
80 };
std::vector< double > x_pts_
The x points in the trajectory.
Definition: trajectory.h:112
double time_delta_
The time gap between points.
Definition: trajectory.h:64
void getPoint(unsigned int index, double &x, double &y, double &th) const
Get a point within the trajectory.
Definition: trajectory.cpp:47
double cost_
The cost/score of the trajectory.
Definition: trajectory.h:62
void resetPoints()
Clear the trajectory&#39;s points.
Definition: trajectory.cpp:65
std::vector< double > y_pts_
The y points in the trajectory.
Definition: trajectory.h:113
void setPoint(unsigned int index, double x, double y, double th)
Set a point within the trajectory.
Definition: trajectory.cpp:53
double thetav_
The x, y, and theta velocities of the trajectory.
Definition: trajectory.h:60
Trajectory()
Default constructor.
Definition: trajectory.cpp:37
unsigned int getPointsSize() const
Return the number of points in the trajectory.
Definition: trajectory.cpp:77
void addPoint(double x, double y, double th)
Add a point to the end of a trajectory.
Definition: trajectory.cpp:59
void getEndpoint(double &x, double &y, double &th) const
Get the last point of the trajectory.
Definition: trajectory.cpp:71
std::vector< double > th_pts_
The theta points in the trajectory.
Definition: trajectory.h:114


base_local_planner
Author(s): Eitan Marder-Eppstein, Eric Perko, contradict@gmail.com
autogenerated on Thu Jan 21 2021 04:05:49