gaussian_pos_vel.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 *********************************************************************/
34 
35 /* Author: Wim Meeussen */
36 
38 #include <bfl/wrappers/rng/rng.h>
39 #include <cmath>
40 #include <cassert>
41 #include <vector>
42 
43 namespace BFL
44 {
46  : Pdf<StatePosVel> (1),
47  mu_(mu),
48  sigma_(sigma),
49  gauss_pos_(mu.pos_, sigma.pos_),
50  gauss_vel_(mu.vel_, sigma.vel_)
51 {}
52 
54 
56 {
57  return new GaussianPosVel(mu_, sigma_);
58 }
59 
60 std::ostream& operator<< (std::ostream& os, const GaussianPosVel& g)
61 {
62  os << "\nMu pos :\n" << g.ExpectedValueGet().pos_ << std::endl
63  << "\nMu vel :\n" << g.ExpectedValueGet().vel_ << std::endl
64  << "\nSigma:\n" << g.CovarianceGet() << std::endl;
65  return os;
66 }
67 
69 {
71 }
72 
73 bool
74 GaussianPosVel::SampleFrom(std::vector<Sample<StatePosVel> >& list_samples, const int num_samples, int method,
75  void * args) const
76 {
77  list_samples.resize(num_samples);
78  std::vector<Sample<StatePosVel> >::iterator sample_it = list_samples.begin();
79  for (sample_it = list_samples.begin(); sample_it != list_samples.end(); sample_it++)
80  SampleFrom(*sample_it, method, args);
81 
82  return true;
83 }
84 
85 bool
86 GaussianPosVel::SampleFrom(Sample<StatePosVel>& one_sample, int method, void * args) const
87 {
89  rnorm(mu_.pos_[1], sigma_.pos_[1]*dt_),
90  rnorm(mu_.pos_[2], sigma_.pos_[2]*dt_)),
92  rnorm(mu_.vel_[1], sigma_.vel_[1]*dt_),
93  rnorm(mu_.vel_[2], sigma_.vel_[2]*dt_))));
94  return true;
95 }
96 
99 {
100  return mu_;
101 }
102 
103 SymmetricMatrix
105 {
106  SymmetricMatrix sigma(6);
107  sigma = 0;
108  for (unsigned int i = 0; i < 3; i++)
109  {
110  sigma(i + 1, i + 1) = pow(sigma_.pos_[i], 2);
111  sigma(i + 4, i + 4) = pow(sigma_.vel_[i], 2);
112  }
113  return sigma;
114 }
115 } // End namespace BFL
virtual MatrixWrapper::SymmetricMatrix CovarianceGet() const
double rnorm(const double &mu, const double &sigma)
Class representing state with pos and vel.
Definition: state_pos_vel.h:46
virtual Probability ProbabilityGet(const tf::Vector3 &input) const
GaussianPosVel(const StatePosVel &mu, const StatePosVel &sigma)
Constructor.
virtual GaussianPosVel * Clone() const
clone function
void ValueSet(const T &value)
virtual StatePosVel ExpectedValueGet() const
virtual Probability ProbabilityGet(const StatePosVel &input) const
virtual ~GaussianPosVel()
Destructor.
friend std::ostream & operator<<(std::ostream &os, const GaussianPosVel &g)
output stream for GaussianPosVel
Class representing gaussian pos_vel.
GaussianVector gauss_vel_
tf::Vector3 vel_
Definition: state_pos_vel.h:49
tf::Vector3 pos_
Definition: state_pos_vel.h:49
bool SampleFrom(vector< Sample< StatePosVel > > &list_samples, const int num_samples, int method=DEFAULT, void *args=NULL) const
GaussianVector gauss_pos_


people_tracking_filter
Author(s): Caroline Pantofaru
autogenerated on Sun Feb 21 2021 03:56:47