system.cpp
Go to the documentation of this file.
1 //=================================================================================================
2 // Copyright (c) 2011, Johannes Meyer, TU Darmstadt
3 // All rights reserved.
4 
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 // * Neither the name of the Flight Systems and Automatic Control group,
13 // TU Darmstadt, nor the names of its contributors may be used to
14 // endorse or promote products derived from this software without
15 // specific prior written permission.
16 
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //=================================================================================================
28 
31 
32 namespace hector_pose_estimation {
33 
34 System::System(const std::string &name)
35  : name_(name)
36  , status_flags_(0)
37 {
38 }
39 
41 }
42 
43 void System::getPrior(State &state) const
44 {
45  getModel()->getPrior(state);
46 }
47 
48 bool System::init(PoseEstimation& estimator, State& state)
49 {
50  if (!getModel() || !getModel()->init(estimator, *this, state)) return false;
51  return true;
52 }
53 
55 {
56  if (getModel()) getModel()->cleanup();
57 }
58 
59 void System::reset(State& state)
60 {
61  if (getModel()) getModel()->reset(state);
62  status_flags_ = 0;
63 }
64 
65 bool System::active(const State& state) {
66  bool active = (!getModel() || getModel()->active(state));
67  if (!active) status_flags_ = 0;
68  return active;
69 }
70 
71 bool System::update(double dt) {
72  if (!filter() || !active(filter()->state())) return false;
73 
74  if (getModel()) status_flags_ = getModel()->getStatusFlags(filter()->state());
75  if (!this->updateImpl(dt)) return false;
76  filter()->state().updated();
77 
78  updated();
79  return true;
80 }
81 
83 }
84 
85 bool System::limitState(State &state) {
86  return getModel()->limitState(state);
87 }
88 
89 } // namespace hector_pose_estimation
System(const std::string &name)
Definition: system.cpp:34
virtual void updated()
Definition: state.cpp:110
virtual bool active(const State &state)
Definition: system_model.h:48
virtual bool update(double dt)
Definition: system.cpp:71
virtual void getPrior(State &state)
Definition: system_model.h:50
virtual void reset(State &state)
Definition: system.cpp:59
virtual void cleanup()
Definition: model.h:44
virtual SystemStatus getStatusFlags(const State &state)
Definition: system_model.h:47
virtual bool limitState(State &state)
Definition: system_model.h:55
virtual const State & state() const
Definition: filter.h:50
virtual Filter * filter() const =0
virtual void getPrior(State &state) const
Definition: system.cpp:43
virtual bool init(PoseEstimation &estimator, State &state)
Definition: system.cpp:48
virtual bool active(const State &state)
Definition: system.cpp:65
virtual void reset(State &state)
Definition: model.h:45
virtual SystemModel * getModel() const
Definition: system.h:55
SystemStatus status_flags_
Definition: system.h:86
virtual bool limitState(State &state)
Definition: system.cpp:85
virtual bool updateImpl(double dt)=0


hector_pose_estimation_core
Author(s): Johannes Meyer
autogenerated on Thu Feb 18 2021 03:29:31