git commit -m "first commit for v2"

This commit is contained in:
2025-12-29 16:21:22 +07:00
commit aa3d832d5c
1807 changed files with 307078 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
---
BasedOnStyle: Google
AccessModifierOffset: -2
ConstructorInitializerIndentWidth: 2
AlignEscapedNewlinesLeft: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: true
BinPackParameters: true
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: true
DerivePointerBinding: false
PointerBindsToType: true
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 60
PenaltyBreakString: 100
PenaltyBreakFirstLessLess: 1000
PenaltyExcessCharacter: 1000
PenaltyReturnTypeOnItsOwnLine: 70
SpacesBeforeTrailingComments: 2
Cpp11BracedListStyle: false
Standard: Auto
IndentWidth: 2
TabWidth: 2
UseTab: Never
IndentFunctionDeclarationAfterType: false
SpacesInParentheses: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterControlStatementKeyword: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4
SortIncludes: false
SpaceAfterCStyleCast: false
# Configure each individual brace in BraceWrapping
BreakBeforeBraces: Custom
# Control of individual brace wrapping cases
BraceWrapping:
AfterClass: 'true'
AfterControlStatement: 'true'
AfterEnum : 'true'
AfterFunction : 'true'
AfterNamespace : 'true'
AfterStruct : 'true'
AfterUnion : 'true'
BeforeCatch : 'true'
BeforeElse : 'true'
IndentBraces : 'false'
...

View File

@@ -0,0 +1,17 @@
# This is a format job. Pre-commit has a first-party GitHub action, so we use
# that: https://github.com/pre-commit/action
name: Format
on: [push, pull_request]
jobs:
pre-commit:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Install clang-format-10
run: sudo apt-get install clang-format-10
- uses: pre-commit/action@v2.0.0

View File

@@ -0,0 +1,68 @@
# This config uses industrial_ci (https://github.com/ros-industrial/industrial_ci.git).
# For troubleshooting, see readme (https://github.com/ros-industrial/industrial_ci/blob/master/README.rst)
name: BuildAndTest
on:
workflow_dispatch:
pull_request:
push:
branches:
- master
jobs:
industrial_ci:
strategy:
matrix:
env:
- ROS_DISTRO: noetic
ROS_REPO: main
CATKIN_LINT: true
- ROS_DISTRO: melodic
ROS_REPO: main
CATKIN_LINT: true
- ROS_DISTRO: kinetic
ROS_REPO: main
env:
CCACHE_DIR: "${{ github.workspace }}/.ccache"
BASEDIR: ${{ github.workspace }}/.work
CACHE_PREFIX: "${{ matrix.env.ROS_DISTRO }}-${{ matrix.env.ROS_REPO }}"
name: "${{ matrix.env.ROS_DISTRO }}-${{ matrix.env.ROS_REPO }}${{ matrix.env.CATKIN_LINT && ' + catkin_lint' || ''}}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# The target directory cache doesn't include the source directory because
# that comes from the checkout. See "prepare target_ws for cache" task below
- name: cache target_ws
if: ${{ ! matrix.env.CCOV }}
uses: pat-s/always-upload-cache@v2.1.5
with:
path: ${{ env.BASEDIR }}/target_ws
key: target_ws-${{ env.CACHE_PREFIX }}-${{ hashFiles('**/CMakeLists.txt', '**/package.xml') }}-${{ github.run_id }}
restore-keys: |
target_ws-${{ env.CACHE_PREFIX }}-${{ hashFiles('**/CMakeLists.txt', '**/package.xml') }}
- name: cache ccache
uses: pat-s/always-upload-cache@v2.1.5
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ env.CACHE_PREFIX }}-${{ github.sha }}-${{ github.run_id }}
restore-keys: |
ccache-${{ env.CACHE_PREFIX }}-${{ github.sha }}
ccache-${{ env.CACHE_PREFIX }}
- name: industrial_ci
uses: 'ros-industrial/industrial_ci@master'
env: ${{ matrix.env }}
- name: upload test artifacts (on failure)
uses: actions/upload-artifact@v2
if: failure()
with:
name: test-results
path: ${{ env.BASEDIR }}/target_ws/**/test_results/**/*.xml
- name: prepare target_ws for cache
if: ${{ always() && ! matrix.env.CCOV }}
run: |
du -sh ${{ env.BASEDIR }}/target_ws
sudo find ${{ env.BASEDIR }}/target_ws -wholename '*/test_results/*' -delete
sudo rm -rf ${{ env.BASEDIR }}/target_ws/src
du -sh ${{ env.BASEDIR }}/target_ws

View File

@@ -0,0 +1,26 @@
# This config uses industrial_ci (https://github.com/ros-industrial/industrial_ci.git).
# For troubleshooting, see readme (https://github.com/ros-industrial/industrial_ci/blob/master/README.rst)
name: pre-release
on:
workflow_dispatch:
jobs:
default:
strategy:
fail-fast: false
matrix:
distro: [melodic, noetic]
env:
ROS_DISTRO: ${{ matrix.distro }}
PRERELEASE: true
BASEDIR: ${{ github.workspace }}/.work
name: "${{ matrix.distro }}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: industrial_ci
uses: ros-industrial/industrial_ci@master

View File

@@ -0,0 +1 @@
*~

View File

@@ -0,0 +1,43 @@
# To use:
#
# pre-commit run -a
#
# Or:
#
# pre-commit install # (runs every time you commit in git)
#
# To update this file:
#
# pre-commit autoupdate
#
# See https://github.com/pre-commit/pre-commit
repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- repo: local
hooks:
- id: clang-format
name: clang-format
description: Format files with ClangFormat.
entry: clang-format-10
language: system
files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$
args: ['-fallback-style=none', '-i']

View File

@@ -0,0 +1,130 @@
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package random_numbers
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.3.2 (2018-02-27)
------------------
* Update maintainership. (`#11 <https://github.com/ros-planning/random_numbers/issues/11>`_)
* Contributors: Steven! Ragnarök
0.3.1 (2016-04-04)
------------------
* Merge pull request `#10 <https://github.com/ros-planning/random_numbers/issues/10>`_ from jspricke/cmake_lib
Use catkin variables for install dirs
* Contributors: Dave Coleman, Jochen Sprickerhof
0.3.0 (2014-09-05)
------------------
* Update README.md with Documentation
* Allow the randomly generated seed to be saved so that experiments / benc...
* Initialize static int to 0
* Save the first_seed even when passed in manually.
* Allow the randomly generated seed to be saved so that experiments / benchmarks can be recreated in the future
* Added ability to specify random number generator seed for stochastic behavior
* Added travis build status indicator in README.md
* Contributors: Dave Coleman, Dave Hershberger, Ioan A Sucan
0.2.0 (2013-07-16)
------------------
* Merge pull request `#2 <https://github.com/ros-planning/random_numbers/issues/2>`_ from wjwwood/patch-1
Fix linkedit error on OS X with newer versions of Boost
* Fix linkedit error on OS X with newer versions of Boost
When building `random_numbers` on OS X with Boost 1.53.0 I get:
```
==> Processing catkin package: 'random_numbers'
==> Creating build directory: 'build_isolated/random_numbers'
==> Building with env: '/Users/william/moveit_ws/install_isolated/env.sh'
==> cmake /Users/william/moveit_ws/src/random_numbers -DCATKIN_DEVEL_PREFIX=/Users/william/moveit_ws/devel_isolated/random_numbers -DCMAKE_INSTALL_PREFIX=/Users/william/moveit_ws/install_isolated
-- The C compiler identification is Clang 4.2.0
-- The CXX compiler identification is Clang 4.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Using CATKIN_DEVEL_PREFIX: /Users/william/moveit_ws/devel_isolated/random_numbers
-- Using CMAKE_PREFIX_PATH: /Users/william/moveit_ws/install_isolated
-- This workspace overlays: /Users/william/moveit_ws/install_isolated
-- Found PythonInterp: /usr/bin/python (found version "2.7.2")
-- Found PY_em: /Library/Python/2.7/site-packages/em.pyc
-- Found gtest: gtests will be built
-- Using CATKIN_TEST_RESULTS_DIR: /Users/william/moveit_ws/build_isolated/random_numbers/test_results
-- catkin 0.5.65
WARNING: 'catkin' should be listed as a buildtool dependency in the package.xml (instead of build dependency)
-- Boost version: 1.53.0
-- Found the following Boost libraries:
-- date_time
-- thread
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/william/moveit_ws/build_isolated/random_numbers
==> make -j4 -l4 in '/Users/william/moveit_ws/build_isolated/random_numbers'
Scanning dependencies of target random_numbers
[100%] Building CXX object CMakeFiles/random_numbers.dir/src/random_numbers.cpp.o
Linking CXX shared library /Users/william/moveit_ws/devel_isolated/random_numbers/lib/librandom_numbers.dylib
Undefined symbols for architecture x86_64:
"boost::system::system_category()", referenced from:
___cxx_global_var_init3 in random_numbers.cpp.o
boost::thread_exception::thread_exception(int, char const*) in random_numbers.cpp.o
"boost::system::generic_category()", referenced from:
___cxx_global_var_init1 in random_numbers.cpp.o
___cxx_global_var_init2 in random_numbers.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [/Users/william/moveit_ws/devel_isolated/random_numbers/lib/librandom_numbers.dylib] Error 1
make[1]: *** [CMakeFiles/random_numbers.dir/all] Error 2
make: *** [all] Error 2
Traceback (most recent call last):
File "./src/catkin/bin/../python/catkin/builder.py", line 658, in build_workspace_isolated
number=index + 1, of=len(ordered_packages)
File "./src/catkin/bin/../python/catkin/builder.py", line 443, in build_package
install, jobs, force_cmake, quiet, last_env, cmake_args, make_args
File "./src/catkin/bin/../python/catkin/builder.py", line 297, in build_catkin_package
run_command(make_cmd, build_dir, quiet)
File "./src/catkin/bin/../python/catkin/builder.py", line 186, in run_command
raise subprocess.CalledProcessError(proc.returncode, ' '.join(cmd))
CalledProcessError: Command '/Users/william/moveit_ws/install_isolated/env.sh make -j4 -l4' returned non-zero exit status 2
<== Failed to process package 'random_numbers':
Command '/Users/william/moveit_ws/install_isolated/env.sh make -j4 -l4' returned non-zero exit status 2
Reproduce this error by running:
==> /Users/william/moveit_ws/install_isolated/env.sh make -j4 -l4
Command failed, exiting.
```
Adding the `system` element to the `Boost` components being found fixes this.
* fix typo
* Create README.md
* update description
* Merge pull request `#1 <https://github.com/ros-planning/random_numbers/issues/1>`_ from ablasdel/patch-1
Update package.xml to buildtool_depend
* Update package.xml to buildtool_depend
* Added tag 0.1.3 for changeset 78f37b23c724
* Contributors: Aaron Blasdel, Tully Foote, William Woodall, isucan
0.1.3 (2012-10-12 20:13)
------------------------
* removing outdated install rule
* fixing install rule
* Added tag 0.1.2 for changeset 42db44939f5e
* Contributors: Tully Foote
0.1.2 (2012-10-12 19:50)
------------------------
* forgot rename
* Added tag 0.1.2 for changeset 79869d337273
* updating catkinization and 0.1.2
* Added tag 0.1.1 for changeset 2e564507c3d1
* Contributors: Ioan Sucan, Tully Foote
0.1.1 (2012-06-18 13:21)
------------------------
* fix manifest
* Added tag 0.1.0 for changeset a1286e23910e
* Contributors: Ioan Sucan
0.1.0 (2012-06-18 13:17)
------------------------
* add initial version
* Contributors: Ioan Sucan

View File

@@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.0.2)
project(random_numbers)
find_package(catkin REQUIRED)
catkin_package(
LIBRARIES ${PROJECT_NAME}
INCLUDE_DIRS include
)
find_package(Boost REQUIRED date_time system thread)
include_directories(${Boost_INCLUDE_DIR})
include_directories(include)
add_library(${PROJECT_NAME}
src/random_numbers.cpp)
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
set_target_properties(${PROJECT_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION})
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})

View File

@@ -0,0 +1,12 @@
# random_numbers
This library contains wrappers for generating floating point values, integers, quaternions using boost libraries.
## Build Status
[![BuildAndTest](https://github.com/ros-planning/random_numbers/actions/workflows/industrial_ci_action.yaml/badge.svg?branch=master)](https://github.com/ros-planning/random_numbers/actions/workflows/industrial_ci_action.yaml?branch=master)
[![Format](https://github.com/ros-planning/random_numbers/actions/workflows/format.yaml/badge.svg?branch=master)](https://github.com/ros-planning/random_numbers/actions/workflows/format.yaml?branch=master)
## Features
New: you can pass in a custom random number generator seed to allow optional deterministic behavior during debugging, testing, etc. using the secondary constructor.

View File

@@ -0,0 +1,118 @@
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2008, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the Willow Garage nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/
/* Author: Ioan Sucan */
#ifndef RANDOM_NUMBERS_RANDOM_NUMBERS_
#define RANDOM_NUMBERS_RANDOM_NUMBERS_
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_real.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/variate_generator.hpp>
#include <boost/random/normal_distribution.hpp>
namespace random_numbers
{
/** \brief Random number generation (wrapper for boost). An instance of this class
cannot be used by multiple threads at once (member functions
are not const). However, the constructor is thread safe and
different instances can be used safely in any number of
threads. It is also guaranteed that all created instances will
have a "random" random seed. */
class RandomNumberGenerator
{
public:
/** \brief Constructor. Always sets a "random" random seed */
RandomNumberGenerator(void);
/** \brief Constructor. Allow a seed to be specified for deterministic behaviour */
RandomNumberGenerator(boost::uint32_t seed);
/** \brief Generate a random real between 0 and 1 */
double uniform01(void)
{
return uni_();
}
/**
* @brief Generate a random real within given bounds: [\e lower_bound, \e upper_bound)
* @param lower_bound The lower bound
* @param upper_bound The upper bound
*/
double uniformReal(double lower_bound, double upper_bound)
{
return (upper_bound - lower_bound) * uni_() + lower_bound;
}
/** \brief Generate a random real using a normal distribution with mean 0 and variance 1 */
double gaussian01(void)
{
return normal_();
}
/** \brief Generate a random real using a normal distribution with given mean and variance */
double gaussian(double mean, double stddev)
{
return normal_() * stddev + mean;
}
/** \brief Uniform random unit quaternion sampling. The computed value has the order (x,y,z,w)
* @param value[4] A four dimensional array in which the computed quaternion will be returned
*/
void quaternion(double value[4]);
/** \brief Generate an integer uniformly at random within a specified range (inclusive) */
int uniformInteger(int min, int max)
{
boost::uniform_int<> dis(min, max);
return dis(generator_);
}
/**
* \brief Allow the randomly generated seed to be saved so that experiments / benchmarks can be recreated in the
* future
*/
boost::uint32_t getFirstSeed();
private:
boost::mt19937 generator_;
boost::uniform_real<> uniDist_;
boost::normal_distribution<> normalDist_;
boost::variate_generator<boost::mt19937&, boost::uniform_real<> > uni_;
boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > normal_;
};
} // namespace random_numbers
#endif

View File

@@ -0,0 +1,20 @@
<package>
<name>random_numbers</name>
<version>0.3.2</version>
<description>
This library contains wrappers for generating floating point values, integers, quaternions using boost libraries.
The constructor of the wrapper is guaranteed to be thread safe and initialize its random number generator to a random seed.
Seeds are obtained using a separate and different random number generator.
</description>
<author email="isucan@willowgarage.edu">Ioan Sucan</author>
<maintainer email="stevenragnarok@osrfoundation.org">Steven! Ragnarök</maintainer>
<license>BSD</license>
<url type="website">http://ros.org/wiki/random_numbers</url>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>boost</build_depend>
<run_depend>boost</run_depend>
</package>

View File

@@ -0,0 +1,108 @@
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2008, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the Willow Garage nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/
/* Author: Ioan Sucan */
#include "random_numbers/random_numbers.h"
#include <boost/random/lagged_fibonacci.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/scoped_ptr.hpp>
static boost::uint32_t first_seed_ = 0;
/// Compute the first seed to be used; this function should be called only once
static boost::uint32_t firstSeed(void)
{
boost::scoped_ptr<int> mem(new int());
first_seed_ = (boost::uint32_t)(
(boost::posix_time::microsec_clock::universal_time() - boost::posix_time::ptime(boost::date_time::min_date_time))
.total_microseconds() +
(unsigned long long)(mem.get()));
return first_seed_;
}
/// We use a different random number generator for the seeds of the
/// Other random generators. The root seed is from the number of
/// nano-seconds in the current time.
static boost::uint32_t nextSeed(void)
{
static boost::mutex rngMutex;
boost::mutex::scoped_lock slock(rngMutex);
static boost::lagged_fibonacci607 sGen(firstSeed());
static boost::uniform_int<> sDist(1, 1000000000);
static boost::variate_generator<boost::lagged_fibonacci607&, boost::uniform_int<> > s(sGen, sDist);
boost::uint32_t v = s();
return v;
}
random_numbers::RandomNumberGenerator::RandomNumberGenerator(void)
: generator_(nextSeed())
, uniDist_(0, 1)
, normalDist_(0, 1)
, uni_(generator_, uniDist_)
, normal_(generator_, normalDist_)
{
}
random_numbers::RandomNumberGenerator::RandomNumberGenerator(boost::uint32_t seed)
: generator_(seed), uniDist_(0, 1), normalDist_(0, 1), uni_(generator_, uniDist_), normal_(generator_, normalDist_)
{
// Because we manually specified a seed, we need to save it ourselves
first_seed_ = seed;
}
// From: "Uniform Random Rotations", Ken Shoemake, Graphics Gems III,
// pg. 124-132
void random_numbers::RandomNumberGenerator::quaternion(double value[4])
{
double x0 = uni_();
double r1 = sqrt(1.0 - x0), r2 = sqrt(x0);
double t1 = 2.0 * boost::math::constants::pi<double>() * uni_(),
t2 = 2.0 * boost::math::constants::pi<double>() * uni_();
double c1 = cos(t1), s1 = sin(t1);
double c2 = cos(t2), s2 = sin(t2);
value[0] = s1 * r1;
value[1] = c1 * r1;
value[2] = s2 * r2;
value[3] = c2 * r2;
}
boost::uint32_t random_numbers::RandomNumberGenerator::getFirstSeed()
{
return first_seed_;
}