-
Notifications
You must be signed in to change notification settings - Fork 1
/
make_object_limt.py
61 lines (49 loc) · 2.17 KB
/
make_object_limt.py
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
57
58
59
import math
import numpy
from math import atan2, pi, ceil, floor, cos, sin
INFINIT = "__FLT_MAX__"
FRONT_LIMIT = 570 # 420
SIDE_LIMIT = 240
ROBOT_FRONT = 170
NUM_ANGLE = 360
end_angle = ceil(atan2(SIDE_LIMIT, ROBOT_FRONT) / pi * 180)
front_angle = floor(atan2(SIDE_LIMIT, FRONT_LIMIT) / pi * 180)
print("Front_angle = " + str(front_angle))
print("End_angle = " + str(end_angle))
limit = [INFINIT for i in range(NUM_ANGLE)]
for i in range(NUM_ANGLE):
if i == 0:
limit[i] = str(FRONT_LIMIT)
if (0 < i <= front_angle) or (NUM_ANGLE - front_angle <= i < NUM_ANGLE):
limit[i] = str(round(abs(FRONT_LIMIT / cos(i / 180 * pi)), 2))
if (front_angle < i <= end_angle) or (NUM_ANGLE-end_angle <= i < NUM_ANGLE - front_angle):
limit[i] = str(round(abs(SIDE_LIMIT / sin(i / 180 * pi)), 2))
limit_short = []
for i in range((NUM_ANGLE - end_angle), (NUM_ANGLE - front_angle)):
limit_short.append(str(round(abs(SIDE_LIMIT / sin(i / 180 * pi)), 2)))
for i in range((NUM_ANGLE - front_angle), NUM_ANGLE):
limit_short.append(str(round(abs(FRONT_LIMIT / cos(i / 180 * pi)), 2)))
for i in range(end_angle + 1):
if i == 0:
limit_short.append(str(FRONT_LIMIT))
if (0 < i <= front_angle) or (NUM_ANGLE - front_angle <= i < NUM_ANGLE):
limit_short.append(str(round(abs(FRONT_LIMIT / cos(i / 180 * pi)), 2)))
if (front_angle < i <= end_angle) or (NUM_ANGLE-end_angle <= i < NUM_ANGLE - front_angle):
limit_short.append(str(round(abs(SIDE_LIMIT / sin(i / 180 * pi)), 2)))
# limit_short = []
# for i in range(NUM_ANGLE):
# if i == 0:
# limit_short.append(str(FRONT_LIMIT))
# if (0 < i <= front_angle) or (NUM_ANGLE - front_angle <= i < NUM_ANGLE):
# limit_short.append(str(round(abs(FRONT_LIMIT / cos(i / 180 * pi)), 2)))
# if (front_angle < i <= end_angle) or (NUM_ANGLE-end_angle <= i < NUM_ANGLE - front_angle):
# limit_short.append(str(round(abs(SIDE_LIMIT / sin(i / 180 * pi)), 2)))
object_range = len(limit_short)
limit_short = "{" + ", ".join(limit_short) + "};"
limit = "{" + ", ".join(limit) + "};"
print("limit:")
print(limit)
print("limit_short:")
print(limit_short)
print("OBJECT_RANGE =")
print(object_range)