MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / rand_float

Function rand_float

libraries/AP_Math/AP_Math.cpp:343–350  ·  view source on GitHub ↗

generate a random float between -1 and 1

Source from the content-addressed store, hash-verified

341
342// generate a random float between -1 and 1
343float rand_float(void)
344{
345#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
346 return ((((unsigned)random()) % 2000000) - 1.0e6) / 1.0e6;
347#else
348 return (get_random16() / 65535.0) * 2 - 1;
349#endif
350}
351
352// generate a random Vector3f with each value between -1.0 and 1.0
353Vector3f rand_vec3f(void)

Callers 15

updateMethod · 0.85
calculate_noiseFunction · 0.85
generate_accelMethod · 0.85
generate_gyroMethod · 0.85
_timerMethod · 0.85
_sonar_pin_voltageMethod · 0.85
_writeMethod · 0.85
_update_airspeedMethod · 0.85
simulate_jammingMethod · 0.85
updateMethod · 0.85
send_imu_packetMethod · 0.85

Calls 1

get_random16Function · 0.85

Tested by 1

TESTFunction · 0.68