forked from microsoft/AirSim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
147 changed files
with
23,961 additions
and
23,520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,92 @@ | ||
#ifndef common_utils_DelayLine_hpp | ||
#define common_utils_DelayLine_hpp | ||
|
||
#include "common/Common.hpp" | ||
#include "UpdatableObject.hpp" | ||
#include <list> | ||
|
||
namespace msr { namespace airlib { | ||
|
||
template<typename T> | ||
class DelayLine : UpdatableObject { | ||
public: | ||
DelayLine() | ||
{} | ||
DelayLine(double delay) //in seconds | ||
{ | ||
initialize(delay); | ||
} | ||
void initialize(double delay) //in seconds | ||
{ | ||
setDelay(delay); | ||
DelayLine::reset(); | ||
} | ||
void setDelay(double delay) | ||
{ | ||
delay_ = delay; | ||
} | ||
double getDelay() const | ||
{ | ||
return delay_; | ||
} | ||
|
||
//*** Start: UpdatableState implementation ***// | ||
virtual void reset() override | ||
{ | ||
values_.clear(); | ||
times_.clear(); | ||
time_now = 0; | ||
last_time_ = -1; | ||
last_value_ = T(); | ||
} | ||
|
||
virtual void update(real_T dt) override | ||
{ | ||
time_now += dt; | ||
|
||
if (!times_.empty() && | ||
time_now - times_.front() >= delay_) { | ||
|
||
last_value_ = values_.front(); | ||
last_time_ = times_.front(); | ||
|
||
times_.pop_front(); | ||
values_.pop_front(); | ||
} | ||
} | ||
//*** End: UpdatableState implementation ***// | ||
|
||
|
||
T getOutput() const | ||
{ | ||
return last_value_; | ||
} | ||
double getOutputTime() const | ||
{ | ||
return last_time_; | ||
} | ||
|
||
void push_back(const T& val, double time_offset = 0) | ||
{ | ||
values_.push_back(val); | ||
times_.push_back(time_now + time_offset); | ||
} | ||
|
||
private: | ||
template<typename TItem> | ||
using list = std::list<TItem>; | ||
|
||
list<T> values_; | ||
list<double> times_; | ||
double delay_; | ||
|
||
T last_value_; | ||
double last_time_ = -1; | ||
double time_now = 0; | ||
}; | ||
|
||
}} //namespace | ||
#endif | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#ifndef common_utils_DelayLine_hpp | ||
#define common_utils_DelayLine_hpp | ||
|
||
#include "common/Common.hpp" | ||
#include "UpdatableObject.hpp" | ||
#include <list> | ||
|
||
namespace msr { namespace airlib { | ||
|
||
template<typename T> | ||
class DelayLine : UpdatableObject { | ||
public: | ||
DelayLine() | ||
{} | ||
DelayLine(double delay) //in seconds | ||
{ | ||
initialize(delay); | ||
} | ||
void initialize(double delay) //in seconds | ||
{ | ||
setDelay(delay); | ||
DelayLine::reset(); | ||
} | ||
void setDelay(double delay) | ||
{ | ||
delay_ = delay; | ||
} | ||
double getDelay() const | ||
{ | ||
return delay_; | ||
} | ||
|
||
//*** Start: UpdatableState implementation ***// | ||
virtual void reset() override | ||
{ | ||
values_.clear(); | ||
times_.clear(); | ||
time_now = 0; | ||
last_time_ = -1; | ||
last_value_ = T(); | ||
} | ||
|
||
virtual void update(real_T dt) override | ||
{ | ||
time_now += dt; | ||
|
||
if (!times_.empty() && | ||
time_now - times_.front() >= delay_) { | ||
|
||
last_value_ = values_.front(); | ||
last_time_ = times_.front(); | ||
|
||
times_.pop_front(); | ||
values_.pop_front(); | ||
} | ||
} | ||
//*** End: UpdatableState implementation ***// | ||
|
||
|
||
T getOutput() const | ||
{ | ||
return last_value_; | ||
} | ||
double getOutputTime() const | ||
{ | ||
return last_time_; | ||
} | ||
|
||
void push_back(const T& val, double time_offset = 0) | ||
{ | ||
values_.push_back(val); | ||
times_.push_back(time_now + time_offset); | ||
} | ||
|
||
private: | ||
template<typename TItem> | ||
using list = std::list<TItem>; | ||
|
||
list<T> values_; | ||
list<double> times_; | ||
double delay_; | ||
|
||
T last_value_; | ||
double last_time_ = -1; | ||
double time_now = 0; | ||
}; | ||
|
||
}} //namespace | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,77 @@ | ||
#ifndef common_utils_GaussianMarkov_hpp | ||
#define common_utils_GaussianMarkov_hpp | ||
|
||
#include "common/Common.hpp" | ||
#include "UpdatableObject.hpp" | ||
#include <list> | ||
#include "common_utils/RandomGenerator.hpp" | ||
|
||
namespace msr { namespace airlib { | ||
|
||
class GaussianMarkov : UpdatableObject { | ||
public: | ||
GaussianMarkov() | ||
{} | ||
GaussianMarkov(real_T tau, real_T sigma, real_T initial_output) //in seconds | ||
{ | ||
initialize(tau, sigma, initial_output); | ||
} | ||
void initialize(real_T tau, real_T sigma, real_T initial_output) //in seconds | ||
{ | ||
tau_ = tau; | ||
sigma_ = sigma; | ||
rand_ = RandomGeneratorGausianR(0.0f, 1.0f); | ||
|
||
if (std::isnan(initial_output)) | ||
initial_output_ = getNextRandom() * sigma_; | ||
else | ||
initial_output_ = initial_output; | ||
|
||
GaussianMarkov::reset(); | ||
} | ||
|
||
//*** Start: UpdatableState implementation ***// | ||
virtual void reset() override | ||
{ | ||
output_ = initial_output_; | ||
rand_.reset(); | ||
} | ||
|
||
virtual void update(real_T dt) override | ||
{ | ||
/* | ||
Ref: | ||
A Comparison between Different Error Modeling of MEMS Applied to GPS/INS Integrated Systems | ||
Quinchia, sec 3.2, https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3812568/ | ||
A Study of the Effects of Stochastic Inertial Sensor Errors in Dead-Reckoning Navigation | ||
John H Wall, 2007, eq 2.5, pg 13, http://etd.auburn.edu/handle/10415/945 | ||
*/ | ||
real_T alpha = exp(-dt / tau_); | ||
output_ = alpha * output_ + (1 - alpha) * getNextRandom() * sigma_; | ||
} | ||
//*** End: UpdatableState implementation ***// | ||
|
||
|
||
real_T getNextRandom() | ||
{ | ||
return rand_.next(); | ||
} | ||
|
||
real_T getOutput() const | ||
{ | ||
return output_; | ||
} | ||
|
||
private: | ||
RandomGeneratorGausianR rand_; | ||
real_T tau_, sigma_; | ||
real_T output_, initial_output_; | ||
}; | ||
|
||
|
||
}} //namespace | ||
#endif | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#ifndef common_utils_GaussianMarkov_hpp | ||
#define common_utils_GaussianMarkov_hpp | ||
|
||
#include "common/Common.hpp" | ||
#include "UpdatableObject.hpp" | ||
#include <list> | ||
#include "common_utils/RandomGenerator.hpp" | ||
|
||
namespace msr { namespace airlib { | ||
|
||
class GaussianMarkov : UpdatableObject { | ||
public: | ||
GaussianMarkov() | ||
{} | ||
GaussianMarkov(real_T tau, real_T sigma, real_T initial_output) //in seconds | ||
{ | ||
initialize(tau, sigma, initial_output); | ||
} | ||
void initialize(real_T tau, real_T sigma, real_T initial_output) //in seconds | ||
{ | ||
tau_ = tau; | ||
sigma_ = sigma; | ||
rand_ = RandomGeneratorGausianR(0.0f, 1.0f); | ||
|
||
if (std::isnan(initial_output)) | ||
initial_output_ = getNextRandom() * sigma_; | ||
else | ||
initial_output_ = initial_output; | ||
|
||
GaussianMarkov::reset(); | ||
} | ||
|
||
//*** Start: UpdatableState implementation ***// | ||
virtual void reset() override | ||
{ | ||
output_ = initial_output_; | ||
rand_.reset(); | ||
} | ||
|
||
virtual void update(real_T dt) override | ||
{ | ||
/* | ||
Ref: | ||
A Comparison between Different Error Modeling of MEMS Applied to GPS/INS Integrated Systems | ||
Quinchia, sec 3.2, https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3812568/ | ||
A Study of the Effects of Stochastic Inertial Sensor Errors in Dead-Reckoning Navigation | ||
John H Wall, 2007, eq 2.5, pg 13, http://etd.auburn.edu/handle/10415/945 | ||
*/ | ||
real_T alpha = exp(-dt / tau_); | ||
output_ = alpha * output_ + (1 - alpha) * getNextRandom() * sigma_; | ||
} | ||
//*** End: UpdatableState implementation ***// | ||
|
||
|
||
real_T getNextRandom() | ||
{ | ||
return rand_.next(); | ||
} | ||
|
||
real_T getOutput() const | ||
{ | ||
return output_; | ||
} | ||
|
||
private: | ||
RandomGeneratorGausianR rand_; | ||
real_T tau_, sigma_; | ||
real_T output_, initial_output_; | ||
}; | ||
|
||
|
||
}} //namespace | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.