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 };
base_local_planner::Trajectory::resetPoints
void resetPoints()
Clear the trajectory's points.
Definition: trajectory.cpp:97
trajectory.h
base_local_planner::Trajectory::addPoint
void addPoint(double x, double y, double th)
Add a point to the end of a trajectory.
Definition: trajectory.cpp:91
base_local_planner::Trajectory::setPoint
void setPoint(unsigned int index, double x, double y, double th)
Set a point within the trajectory.
Definition: trajectory.cpp:85
base_local_planner::Trajectory::x_pts_
std::vector< double > x_pts_
The x points in the trajectory.
Definition: trajectory.h:144
base_local_planner::Trajectory::getEndpoint
void getEndpoint(double &x, double &y, double &th) const
Get the last point of the trajectory.
Definition: trajectory.cpp:103
base_local_planner::Trajectory::getPoint
void getPoint(unsigned int index, double &x, double &y, double &th) const
Get a point within the trajectory.
Definition: trajectory.cpp:79
base_local_planner::Trajectory::getPointsSize
unsigned int getPointsSize() const
Return the number of points in the trajectory.
Definition: trajectory.cpp:109
base_local_planner
Definition: costmap_model.h:44
base_local_planner::Trajectory::th_pts_
std::vector< double > th_pts_
The theta points in the trajectory.
Definition: trajectory.h:146
base_local_planner::Trajectory::Trajectory
Trajectory()
Default constructor.
Definition: trajectory.cpp:69
base_local_planner::Trajectory::y_pts_
std::vector< double > y_pts_
The y points in the trajectory.
Definition: trajectory.h:145


base_local_planner
Author(s): Eitan Marder-Eppstein, Eric Perko, contradict@gmail.com
autogenerated on Mon Mar 6 2023 03:50:24