-
Notifications
You must be signed in to change notification settings - Fork 225
/
GazeboUtils.h
57 lines (45 loc) · 941 Bytes
/
GazeboUtils.h
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
49
50
51
52
53
54
55
56
/*
* http://github.com/dusty-nv/jetson-reinforcement
*/
#ifndef __GAZEBO_PLUGIN_UTILITIES_H__
#define __GAZEBO_PLUGIN_UTILITIES_H__
#include <gazebo/gazebo.hh>
#include <gazebo/physics/physics.hh>
#include <gazebo/common/common.hh>
// compute the distance between two bounding boxes
inline float BoxDistance(const gazebo::math::Box& a, const gazebo::math::Box& b)
{
float sqrDist = 0;
if( b.max.x < a.min.x )
{
float d = b.max.x - a.min.x;
sqrDist += d * d;
}
else if( b.min.x > a.max.x )
{
float d = b.min.x - a.max.x;
sqrDist += d * d;
}
if( b.max.y < a.min.y )
{
float d = b.max.y - a.min.y;
sqrDist += d * d;
}
else if( b.min.y > a.max.y )
{
float d = b.min.y - a.max.y;
sqrDist += d * d;
}
if( b.max.z < a.min.z )
{
float d = b.max.z - a.min.z;
sqrDist += d * d;
}
else if( b.min.z > a.max.z )
{
float d = b.min.z - a.max.z;
sqrDist += d * d;
}
return sqrtf(sqrDist);
}
#endif