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 
37 
39 #include <bfl/wrappers/rng/rng.h>
40 #include <cmath>
41 #include <cassert>
42 
43 using namespace tf;
44 
45 namespace BFL
46 {
47 GaussianPosVel::GaussianPosVel(const StatePosVel& mu, const StatePosVel& sigma)
48  : Pdf<StatePosVel> (1),
49  mu_(mu),
50  sigma_(sigma),
51  gauss_pos_(mu.pos_, sigma.pos_),
52  gauss_vel_(mu.vel_, sigma.vel_)
53 {}
54 
55 
57 
59 {
60  return new GaussianPosVel(mu_, sigma_);
61 }
62 
63 std::ostream& operator<< (std::ostream& os, const GaussianPosVel& g)
64 {
65  os << "\nMu pos :\n" << g.ExpectedValueGet().pos_ << endl
66  << "\nMu vel :\n" << g.ExpectedValueGet().vel_ << endl
67  << "\nSigma:\n" << g.CovarianceGet() << endl;
68  return os;
69 }
70 
71 
72 Probability GaussianPosVel::ProbabilityGet(const StatePosVel& input) const
73 {
75 }
76 
77 
78 bool
79 GaussianPosVel::SampleFrom(vector<Sample<StatePosVel> >& list_samples, const int num_samples, int method, void * args) const
80 {
81  list_samples.resize(num_samples);
82  vector<Sample<StatePosVel> >::iterator sample_it = list_samples.begin();
83  for (sample_it = list_samples.begin(); sample_it != list_samples.end(); sample_it++)
84  SampleFrom(*sample_it, method, args);
85 
86  return true;
87 }
88 
89 
90 bool
91 GaussianPosVel::SampleFrom(Sample<StatePosVel>& one_sample, int method, void * args) const
92 {
93  one_sample.ValueSet(StatePosVel(Vector3(rnorm(mu_.pos_[0], sigma_.pos_[0]*dt_),
94  rnorm(mu_.pos_[1], sigma_.pos_[1]*dt_),
95  rnorm(mu_.pos_[2], sigma_.pos_[2]*dt_)),
96  Vector3(rnorm(mu_.vel_[0], sigma_.vel_[0]*dt_),
97  rnorm(mu_.vel_[1], sigma_.vel_[1]*dt_),
98  rnorm(mu_.vel_[2], sigma_.vel_[2]*dt_))));
99  return true;
100 }
101 
102 
105 {
106  return mu_;
107 }
108 
109 SymmetricMatrix
111 {
112  SymmetricMatrix sigma(6);
113  sigma = 0;
114  for (unsigned int i = 0; i < 3; i++)
115  {
116  sigma(i + 1, i + 1) = pow(sigma_.pos_[i], 2);
117  sigma(i + 4, i + 4) = pow(sigma_.vel_[i], 2);
118  }
119  return sigma;
120 }
121 
122 } // End namespace BFL
virtual MatrixWrapper::SymmetricMatrix CovarianceGet() const
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
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 Fri Jun 7 2019 22:07:49