-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathconstants.py
More file actions
131 lines (112 loc) · 3.84 KB
/
Copy pathconstants.py
File metadata and controls
131 lines (112 loc) · 3.84 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
"""
Important constants for VLA training and evaluation.
Attempts to automatically identify the correct constants to set based on the Python command used to launch
training or evaluation. If it is unclear, defaults to using the LIBERO simulation benchmark constants.
"""
import sys
from enum import Enum
# Llama 2 token constants
IGNORE_INDEX = -100
ACTION_TOKEN_BEGIN_IDX = 31743
STOP_INDEX = 2 # '</s>'
# lisa method
ACTION_TOKEN_IDX = 32001
# Defines supported normalization schemes for action and proprioceptive state.
class NormalizationType(str, Enum):
# fmt: off
NORMAL = "normal" # Normalize to Mean = 0, Stdev = 1
BOUNDS = "bounds" # Normalize to Interval = [-1, 1]
BOUNDS_Q99 = "bounds_q99" # Normalize [quantile_01, ..., quantile_99] --> [-1, ..., 1]
# fmt: on
# Define constants for each robot platform
LIBERO_CONSTANTS = {
"NUM_ACTIONS_CHUNK": 8,
"ACTION_DIM": 7,
"PROPRIO_DIM": 8,
"ACTION_PROPRIO_NORMALIZATION_TYPE": NormalizationType.BOUNDS_Q99,
}
ALOHA_CONSTANTS = {
"NUM_ACTIONS_CHUNK": 25,
"ACTION_DIM": 14,
"PROPRIO_DIM": 14,
"ACTION_PROPRIO_NORMALIZATION_TYPE": NormalizationType.BOUNDS,
}
BRIDGE_CONSTANTS = {
"NUM_ACTIONS_CHUNK": 5,
"ACTION_DIM": 7,
"PROPRIO_DIM": 7,
"ACTION_PROPRIO_NORMALIZATION_TYPE": NormalizationType.BOUNDS_Q99,
}
FRACTAL_CONSTANTS = {
"NUM_ACTIONS_CHUNK": 5,
"ACTION_DIM": 7,
"PROPRIO_DIM": 8,
"ACTION_PROPRIO_NORMALIZATION_TYPE": NormalizationType.BOUNDS_Q99,
}
G1_CONSTANTS = {
"NUM_ACTIONS_CHUNK": 25,
"ACTION_DIM": 16,
"PROPRIO_DIM": 16,
"ACTION_PROPRIO_NORMALIZATION_TYPE": NormalizationType.BOUNDS,
}
G1_EE_6D_CONSTANTS = {
"NUM_ACTIONS_CHUNK": 25,
"ACTION_DIM": 23,
"PROPRIO_DIM": 23,
"ACTION_PROPRIO_NORMALIZATION_TYPE": NormalizationType.BOUNDS_Q99,
}
G1_STACK_BLOCK_CONSTANTS = {
"NUM_ACTIONS_CHUNK": 25,
"ACTION_DIM": 23,
"PROPRIO_DIM": 23,
"ACTION_PROPRIO_NORMALIZATION_TYPE": NormalizationType.BOUNDS_Q99,
}
# Function to detect robot platform from command line arguments
def detect_robot_platform():
cmd_args = " ".join(sys.argv).lower()
print(cmd_args)
if "libero" in cmd_args:
return "LIBERO"
elif "aloha" in cmd_args:
return "ALOHA"
elif "bridge" in cmd_args:
return "BRIDGE"
elif "fractal" in cmd_args:
return "FRACTAL"
elif "ee_6d" in cmd_args:
return "G1_EE_6D"
elif "joint" in cmd_args:
return "G1"
elif "stack_block" in cmd_args:
return "G1_STACK_BLOCK"
else:
return "G1_EE_6D"
# Determine which robot platform to use
ROBOT_PLATFORM = detect_robot_platform()
# Set the appropriate constants based on the detected platform
if ROBOT_PLATFORM == "LIBERO":
constants = LIBERO_CONSTANTS
elif ROBOT_PLATFORM == "ALOHA":
constants = ALOHA_CONSTANTS
elif ROBOT_PLATFORM == "BRIDGE":
constants = BRIDGE_CONSTANTS
elif ROBOT_PLATFORM == "FRACTAL":
constants = FRACTAL_CONSTANTS
elif ROBOT_PLATFORM == "G1_EE_6D":
constants = G1_EE_6D_CONSTANTS
elif ROBOT_PLATFORM == "G1":
constants = G1_CONSTANTS
elif ROBOT_PLATFORM == "G1_STACK_BLOCK":
constants = G1_STACK_BLOCK_CONSTANTS
# Assign constants to global variables
NUM_ACTIONS_CHUNK = constants["NUM_ACTIONS_CHUNK"]
ACTION_DIM = constants["ACTION_DIM"]
PROPRIO_DIM = constants["PROPRIO_DIM"]
ACTION_PROPRIO_NORMALIZATION_TYPE = constants["ACTION_PROPRIO_NORMALIZATION_TYPE"]
# Print which robot platform constants are being used (for debugging)
print(f"Using {ROBOT_PLATFORM} constants:")
print(f" in constants.py NUM_ACTIONS_CHUNK = {NUM_ACTIONS_CHUNK}")
print(f" ACTION_DIM = {ACTION_DIM}")
print(f" PROPRIO_DIM = {PROPRIO_DIM}")
print(f" ACTION_PROPRIO_NORMALIZATION_TYPE = {ACTION_PROPRIO_NORMALIZATION_TYPE}")
print("If needed, manually set the correct constants in `training/vla/constants.py`!")