Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Toggle main menu visibility
Main Page
Related Pages
Topics
Data Structures
Data Structures
Data Structure Index
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerator
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
m
n
p
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
v
w
z
Enumerator
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
Loading...
Searching...
No Matches
pprz_random.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) Joost Meulenbeld
3
*
4
* This file is part of paparazzi
5
*
6
* paparazzi is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
9
* any later version.
10
*
11
* paparazzi is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with paparazzi; see the file COPYING. If not, see
18
* <http://www.gnu.org/licenses/>.
19
*/
26
#include "
pprz_random.h
"
27
28
#ifdef BOARD_CONFIG
29
#include "
mcu_periph/sys_time.h
"
30
#else
31
#include <time.h>
32
#endif
33
34
35
void
init_random
(
void
)
36
{
37
#ifdef BOARD_CONFIG
38
srand
(
get_sys_time_msec
());
39
#else
40
srand
(
time
(
NULL
));
41
#endif
42
43
}
35
void
init_random
(
void
) {
…
}
44
45
double
rand_uniform
(
void
)
46
{
47
return
(
double
)
rand
() /
RAND_MAX
;
48
}
45
double
rand_uniform
(
void
) {
…
}
49
50
/*
51
* http://www.taygeta.com/random/gaussian.html
52
*/
53
double
rand_gaussian
(
void
)
54
{
55
static
int
nb_call
= 0;
56
static
double
x2;
57
static
double
w;
58
double
x1;
59
60
nb_call
++;
61
if
(
nb_call
% 2) {
62
do
{
63
x1 = 2.0 *
rand_uniform
() - 1.0;
64
x2 = 2.0 *
rand_uniform
() - 1.0;
65
w = x1 * x1 + x2 * x2;
66
}
while
(w >= 1.0 || w == 0.0);
67
68
w =
sqrt
((-2.0 *
log
(w)) / w);
69
return
x1 * w;
70
}
else
{
71
return
x2 * w;
72
}
73
}
53
double
rand_gaussian
(
void
) {
…
}
get_sys_time_msec
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
Definition
sys_time_arch.c:98
time
float time
Definition
eff_scheduling_rotwing_V2.c:400
foo
uint16_t foo
Definition
main_demo5.c:58
init_random
void init_random(void)
Definition
pprz_random.c:35
rand_gaussian
double rand_gaussian(void)
Definition
pprz_random.c:53
rand_uniform
double rand_uniform(void)
Definition
pprz_random.c:45
pprz_random.h
sys_time.h
Architecture independent timing functions.
sw
airborne
math
pprz_random.c
Generated on Fri Apr 4 2025 14:56:50 for Paparazzi UAS by
1.9.8