ObservationModel.cpp
Go to the documentation of this file.
1 // SVN $HeadURL$
2 // SVN $Id$
3 
4 /*
5  * 6D localization for humanoid robots
6  *
7  * Copyright 2009-2012 Armin Hornung, University of Freiburg
8  * http://www.ros.org/wiki/humanoid_localization
9  *
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, version 3.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
25 
26 using namespace std;
27 using namespace tf;
28 
29 namespace humanoid_localization{
30 
31 ObservationModel::ObservationModel(ros::NodeHandle* nh, boost::shared_ptr<MapModel> mapModel, EngineT* rngEngine )
32 : m_mapModel(mapModel),
33  m_rngNormal(*rngEngine, NormalDistributionT(0.0, 1.0)),
34  m_rngUniform(*rngEngine, UniformDistributionT(0.0, 1.0)),
35  m_weightRoll(1.0), m_weightPitch(1.0), m_weightZ(1.0),
36  m_sigmaZ(0.02), m_sigmaRoll(0.05), m_sigmaPitch(0.05),
37  m_use_squared_error(false)
38 {
39 
40  m_map = m_mapModel->getMap();
41 
42  nh->param("weight_factor_roll", m_weightRoll, m_weightRoll);
43  nh->param("weight_factor_pitch", m_weightPitch, m_weightPitch);
44  nh->param("weight_factor_z", m_weightZ, m_weightZ);
45  nh->param("motion_sigma_z", m_sigmaZ, m_sigmaZ);
46  nh->param("motion_sigma_roll", m_sigmaRoll, m_sigmaRoll);
47  nh->param("motion_sigma_pitch", m_sigmaPitch, m_sigmaPitch);
48  nh->param("obs_squared_distance", m_use_squared_error, m_use_squared_error);
49 
50  if (m_sigmaZ <= 0.0 || m_sigmaRoll <= 0.0 || m_sigmaPitch <= 0.0){
51  ROS_ERROR("Sigma (std.dev) needs to be > 0 in ObservationModel");
52  }
53 }
54 
56 }
57 
58 void ObservationModel::integratePoseMeasurement(Particles& particles, double poseRoll, double posePitch, const tf::StampedTransform& footprintToTorso){
59  // TODO: move to HumanoidLocalization, skip individual parts if z/rp constrained
60  double poseHeight = footprintToTorso.getOrigin().getZ();
61  ROS_DEBUG("Pose measurement z=%f R=%f P=%f", poseHeight, poseRoll, posePitch);
62  // TODO cluster xy of particles => speedup
63 #pragma omp parallel for
64  for (unsigned i=0; i < particles.size(); ++i){
65  // integrate IMU meas.:
66  double roll, pitch, yaw;
67  particles[i].pose.getBasis().getRPY(roll, pitch, yaw);
68  particles[i].weight += m_weightRoll * logLikelihood(poseRoll - roll, m_sigmaRoll);
69  particles[i].weight += m_weightPitch * logLikelihood(posePitch - pitch, m_sigmaPitch);
70 
71  // integrate height measurement (z)
72  double heightError;
73  if (getHeightError(particles[i],footprintToTorso, heightError))
74  particles[i].weight += m_weightZ * logLikelihood(heightError, m_sigmaZ);
75 
76 
77  }
78 
79 }
80 
82  m_map = map;
83 }
84 
85 }
virtual void setMap(boost::shared_ptr< octomap::OcTree > map)
boost::shared_ptr< octomap::OcTree > m_map
boost::uniform_real UniformDistributionT
boost::mt19937 EngineT
Boost RNG engine:
TFSIMD_FORCE_INLINE const tfScalar & getZ() const
static double logLikelihood(double x, double sigma)
Helper function to compute the log likelihood.
boost::shared_ptr< MapModel > m_mapModel
boost::normal_distribution NormalDistributionT
Boost RNG distribution:
bool param(const std::string &param_name, T &param_val, const T &default_val) const
TFSIMD_FORCE_INLINE Vector3 & getOrigin()
virtual void integratePoseMeasurement(Particles &particles, double roll, double pitch, const tf::StampedTransform &footprintToTorso)
virtual bool getHeightError(const Particle &p, const tf::StampedTransform &footprintToBase, double &heightError) const =0
std::vector< Particle > Particles
#define ROS_ERROR(...)
#define ROS_DEBUG(...)


humanoid_localization
Author(s): Armin Hornung, Stefan Osswald, Daniel Maier
autogenerated on Mon Jun 10 2019 13:38:31