forked from microsoft/AirSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandomPointPoseGenerator.hpp
48 lines (40 loc) · 1.44 KB
/
RandomPointPoseGenerator.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include "common/Common.hpp"
class RandomPointPoseGenerator {
public:
private:
typedef common_utils::RandomGeneratorGaussianF RandomGeneratorGaussianF;
typedef msr::airlib::Vector3r Vector3r;
typedef msr::airlib::Quaternionr Quaternionr;
typedef common_utils::Utils Utils;
typedef msr::airlib::VectorMath VectorMath;
public:
Vector3r position;
Quaternionr orientation;
public:
RandomPointPoseGenerator(int random_seed)
:
//settings are for neighbourhood environement
//sigma = desired_max / 2 so 95% of the times we in desired
rand_xy_(0.0f, 75.0f), rand_z_(2.0f, 1.0f),
rand_pitch_(0.0f, M_PIf / 8), rand_roll_(0.0f, M_PIf / 16),
rand_yaw_(0.0f, M_PIf / 2)
{
rand_xy_.seed(random_seed);
rand_z_.seed(random_seed);
rand_pitch_.seed(random_seed);
rand_yaw_.seed(random_seed);
}
void next()
{
position.x() = rand_xy_.next();
position.y() = rand_xy_.next();
position.z() = Utils::clip(rand_z_.next(), -10.0f, -1.0f);
float pitch = Utils::clip(rand_pitch_.next(), -M_PIf / 2, M_PIf / 2);
float roll = Utils::clip(rand_pitch_.next(), -M_PIf / 4, M_PIf / 4);
float yaw = Utils::clip(rand_yaw_.next(), -M_PIf, M_PIf);
orientation = VectorMath::toQuaternion(pitch, roll, yaw);
}
private:
RandomGeneratorGaussianF rand_xy_, rand_z_, rand_pitch_, rand_yaw_, rand_roll_;
};