forked from sergionr2/RacingRobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.py
85 lines (73 loc) · 2.31 KB
/
constants.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""
File containing all the constants used in the different files
"""
from __future__ import print_function, division, absolute_import
import numpy as np
# Camera Constants
CAMERA_RESOLUTION = (640 // 2, 480 // 2)
# https://picamera.readthedocs.io/en/release-1.13/fov.html#sensor-modes
# mode 4, larger FoV but FPS <= 40
CAMERA_MODE = 4
# Regions of interest
MAX_WIDTH = CAMERA_RESOLUTION[0]
MAX_HEIGHT = CAMERA_RESOLUTION[1]
# r = [margin_left, margin_top, width, height]
ROI = [0, 75, MAX_WIDTH, MAX_HEIGHT - 75]
# Image Analyser
RECORD_VIDEO = True # Record video to debug folder
# Training
FACTOR = 4 # Resize factor
INPUT_WIDTH = ROI[2] // FACTOR
INPUT_HEIGHT = ROI[3] // FACTOR
N_CHANNELS = 3
SPLIT_SEED = 42 # For train/val/test split
MODEL_TYPE = "custom" # Network architecture {cnn or custom}
WEIGHTS_PTH = MODEL_TYPE + "_model.pth" # Path to the trained model
NUM_OUTPUT = 6 # Predict 3 points -> 6 outputs
# Direction and speed
THETA_MIN = 70 # value in [0, 255] sent to the servo
THETA_MAX = 150
MAX_SPEED_STRAIGHT_LINE = 30 # order between 0 and 100
MAX_SPEED_SHARP_TURN = 25
MIN_SPEED = 25
# Path Planning
TARGET_POINT = 0.5 # between [0, 1] position on the bezier curve
# Stanley Steering Control params
# Control gain (compromise between smooth control
# and precise track following)
K_STANLEY_CONTROL = 1
CAR_LENGTH = 300 # Wheel base of vehicle (in the warped pixel space)
MAX_STEERING_ANGLE = np.radians(30.0) # [rad]
# Radius of curvature
MIN_RADIUS = 5 # Below this value, we consider to be in a sharp turn
MAX_RADIUS = 40 # Above this value, we consider to be in a straight line
# PID Control
Kp_turn = 65
Kp_line = 65
Kd = 4
Ki = 0
ALPHA = 1 # alpha of the moving mean for the turn coefficient
# Main Program
FPS = 40
N_SECONDS = 3000 # number of seconds before exiting the program
BAUDRATE = 115200 # Communication with the Arduino
# Number of messages we can send to the Arduino without receiving an acknowledgment
N_MESSAGES_ALLOWED = 3
COMMAND_QUEUE_SIZE = 2
# Image Processing
# Straight line angle
REF_ANGLE = - np.pi / 2
# Max turn angle
MAX_ANGLE = np.pi / 4 # 2 * np.pi / 3
# Teleoperation
TELEOP_PORT = "5556"
RASPBERRY_IP = "192.168.12.252"
# Arrow keys
UP_KEY = 82
DOWN_KEY = 84
RIGHT_KEY = 83
LEFT_KEY = 81
ENTER_KEY = 10
SPACE_KEY = 32
EXIT_KEYS = [113, 27] # Escape and q
S_KEY = 115 # S key