Rand.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 /* Desc: Random number generator
18  * Author: Nate Koenig
19  * Date: 27 May 2009
20  */
21 
22 #ifndef _RAND_HH_
23 #define _RAND_HH_
24 
25 #include <boost/random.hpp>
26 #include "gazebo/util/system.hh"
27 
28 namespace gazebo
29 {
30  namespace math
31  {
34  typedef boost::mt19937 GeneratorType;
37  typedef boost::uniform_real<double> UniformRealDist;
40  typedef boost::normal_distribution<double> NormalRealDist;
43  typedef boost::uniform_int<int> UniformIntDist;
44 
47  typedef boost::variate_generator<GeneratorType&, UniformRealDist > URealGen;
50  typedef boost::variate_generator<GeneratorType&, NormalRealDist > NRealGen;
53  typedef boost::variate_generator<GeneratorType&, UniformIntDist > UIntGen;
54 
57 
60  class GZ_MATH_VISIBLE Rand
61  {
66  public: static void SetSeed(uint32_t _seed)
67  GAZEBO_DEPRECATED(8.0);
68 
73  public: static uint32_t GetSeed()
74  GAZEBO_DEPRECATED(8.0);
75 
80  public: static double GetDblUniform(double _min = 0, double _max = 1)
81  GAZEBO_DEPRECATED(8.0);
82 
87  public: static double GetDblNormal(double _mean = 0, double _sigma = 1)
88  GAZEBO_DEPRECATED(8.0);
89 
94  public: static int GetIntUniform(int _min, int _max)
95  GAZEBO_DEPRECATED(8.0);
96 
101  public: static int GetIntNormal(int _mean, int _sigma)
102  GAZEBO_DEPRECATED(8.0);
103 
104  // The random number generator
105  private: static GeneratorType *randGenerator;
106 
107  private: static uint32_t seed;
108  };
110  }
111 }
112 #endif
113 
T T _min
Definition: Helpers.hh:130
boost::mt19937 GeneratorType
Definition: Rand.hh:34
static const double GAZEBO_DEPRECATED(8.0) MAX_D
Double maximum value. This value will be similar to 1.79769e+308.
Definition: Helpers.hh:140
Random number generator class.
Definition: Rand.hh:60
boost::normal_distribution< double > NormalRealDist
Definition: Rand.hh:40
boost::uniform_real< double > UniformRealDist
Definition: Rand.hh:37
boost::uniform_int< int > UniformIntDist
Definition: Rand.hh:43
boost::variate_generator< GeneratorType &, UniformRealDist > URealGen
Definition: Rand.hh:47
boost::variate_generator< GeneratorType &, NormalRealDist > NRealGen
Definition: Rand.hh:50
boost::variate_generator< GeneratorType &, UniformIntDist > UIntGen
Definition: Rand.hh:53