trajectory_sim_grade.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Software License Agreement (BSD License) *
3  * Copyright (C) 2016 by Horatiu George Todoran <todorangrg@gmail.com> *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions *
7  * are met: *
8  * *
9  * 1. Redistributions of source code must retain the above copyright *
10  * notice, this list of conditions and the following disclaimer. *
11  * 2. Redistributions in binary form must reproduce the above copyright *
12  * notice, this list of conditions and the following disclaimer in *
13  * the documentation and/or other materials provided with the *
14  * distribution. *
15  * 3. Neither the name of the copyright holder nor the names of its *
16  * contributors may be used to endorse or promote products derived *
17  * from this software without specific prior written permission. *
18  * *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
23  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, *
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, *
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER *
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY *
29  * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
30  * POSSIBILITY OF SUCH DAMAGE. *
31  ***************************************************************************/
32 
34 #include <tuw_control/utils.h>
35 
36 #include <algorithm>
37 
38 #include <iostream>
39 
40 using namespace std;
41 using namespace tuw;
42 
43 TrajectorySimGrade::TrajectorySimGrade(StateSimPtr& _stateSim)
44  : stateSim_(_stateSim), simMode_(TrajectorySimulator::SimMode::ONLINE)
45 {
46  trajSim_ = shared_ptr<TrajectorySimulatorOnline>(new TrajectorySimulatorOnline(stateSim_));
47 }
48 
50  unique_ptr<TrajectorySimulator::CostsEvaluatorClass> _costsEvaluator)
52 {
53  trajSim_ = shared_ptr<TrajectorySimulatorOnline>(new TrajectorySimulatorOnline(stateSim_, std::move(_costsEvaluator)));
54 }
55 
57 {
58  double dt = -1, ds = -1;
59  std::vector<TrajectorySimulator::LatticePointType> simulationLattice;
61  bool copy = false;
62  if (trajSim_ != nullptr)
63  {
64  copy = true;
65  dt = trajSim_->dtBase();
66  ds = trajSim_->dsBase();
67  simulationLattice = trajSim_->simLattice();
68  partLattices = trajSim_->partLattices_;
69  userPartLattices_ = trajSim_->userDefPartLattices_;
70  }
72  {
73  trajSim_ = shared_ptr<TrajectorySimulatorOnline>(new TrajectorySimulatorOnline(trajSim_->stateSim(), std::move(trajSim_->costsEvaluator_)));
74  }
76  {
77  trajSim_ = shared_ptr<TrajectorySimulatorPrecalc>(new TrajectorySimulatorPrecalc(trajSim_->stateSim(), std::move(trajSim_->costsEvaluator_)));
78  }
79  if (copy)
80  {
81  trajSim_->dtBase() = dt;
82  trajSim_->dsBase() = ds;
83  trajSim_->simLattice() = simulationLattice;
84  trajSim_->partLattices_ = partLattices;
85  trajSim_->userDefPartLattices_ = userPartLattices_;
86  if (trajSim_->costsEvaluator_)
87  {
88  trajSim_->updateUserDefLattice();
90  }
91  }
92 }
93 
95 {
96  trajSim_->costsEvaluator_->init(trajSim_->partLattices_);
97 }
98 
100 {
101  if (simMode_ != _simMode)
102  {
103  simMode_ = _simMode;
105  }
106 }
107 
109 {
110  return simMode_;
111 }
112 
114 {
115  return trajSim_;
116 }
117 
118 void TrajectorySimGrade::evaluateTrajectory(const double& _arcBegin)
119 {
120  trajSim_->stateSim()->paramFuncs()->precompute();
121  trajSim_->simulateTrajectory(_arcBegin);
122 }
void setSimMode(const TrajectorySimulator::SimMode &_simMode)
void evaluateTrajectory(const double &_arcBegin=0)
TrajectorySimGrade(StateSimPtr &_stateSim)
const TrajectorySimulator::SimMode & simMode() const
Helper function needed to upgrade c++ 2011.
Definition: utils.h:193
TrajectorySimulatorSPtr & trajSim()
SimMode
Mode of the simulation.
std::shared_ptr< TrajectorySimulator > TrajectorySimulatorSPtr
std::vector< std::shared_ptr< std::vector< LatticePoint > > > LatticeVecSPtrVec
std::shared_ptr< StateSim > StateSimPtr
std::vector< std::vector< double * > > userPartLattices_
TrajectorySimulatorSPtr trajSim_
TrajectorySimulator::SimMode simMode_
StateSimSPtr stateSim_
State simulator object.


tuw_control
Author(s): George Todoran
autogenerated on Mon Jun 10 2019 15:27:22