vex-ast 0.2.4__py3-none-any.whl → 0.2.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vex_ast/README.md +101 -51
- vex_ast/READMEAPI.md +133 -318
- vex_ast/__init__.py +81 -72
- vex_ast/ast/README.md +87 -87
- vex_ast/ast/__init__.py +74 -74
- vex_ast/ast/core.py +71 -71
- vex_ast/ast/expressions.py +276 -276
- vex_ast/ast/interfaces.py +208 -208
- vex_ast/ast/literals.py +80 -80
- vex_ast/ast/navigator.py +225 -225
- vex_ast/ast/operators.py +135 -135
- vex_ast/ast/statements.py +351 -351
- vex_ast/ast/validators.py +121 -120
- vex_ast/ast/vex_nodes.py +279 -279
- vex_ast/parser/README.md +47 -47
- vex_ast/parser/__init__.py +26 -26
- vex_ast/parser/factory.py +190 -190
- vex_ast/parser/interfaces.py +34 -34
- vex_ast/parser/python_parser.py +831 -786
- vex_ast/registry/README.md +107 -29
- vex_ast/registry/__init__.py +51 -51
- vex_ast/registry/api.py +190 -155
- vex_ast/registry/categories.py +179 -136
- vex_ast/registry/functions/__init__.py +10 -10
- vex_ast/registry/functions/constructors.py +71 -0
- vex_ast/registry/functions/display.py +146 -146
- vex_ast/registry/functions/drivetrain.py +163 -163
- vex_ast/registry/functions/initialize.py +31 -28
- vex_ast/registry/functions/motor.py +140 -140
- vex_ast/registry/functions/sensors.py +194 -194
- vex_ast/registry/functions/timing.py +103 -103
- vex_ast/registry/language_map.py +77 -77
- vex_ast/registry/registry.py +164 -153
- vex_ast/registry/signature.py +269 -191
- vex_ast/registry/simulation_behavior.py +8 -8
- vex_ast/registry/validation.py +43 -43
- vex_ast/serialization/__init__.py +37 -37
- vex_ast/serialization/json_deserializer.py +284 -275
- vex_ast/serialization/json_serializer.py +148 -148
- vex_ast/serialization/schema.py +492 -470
- vex_ast/types/README.md +78 -26
- vex_ast/types/__init__.py +140 -140
- vex_ast/types/base.py +83 -83
- vex_ast/types/enums.py +122 -97
- vex_ast/types/objects.py +64 -64
- vex_ast/types/primitives.py +68 -68
- vex_ast/types/type_checker.py +31 -31
- vex_ast/utils/README.md +39 -39
- vex_ast/utils/__init__.py +37 -37
- vex_ast/utils/errors.py +112 -112
- vex_ast/utils/source_location.py +38 -38
- vex_ast/utils/type_definitions.py +8 -8
- vex_ast/visitors/README.md +49 -49
- vex_ast/visitors/__init__.py +27 -27
- vex_ast/visitors/analyzer.py +102 -102
- vex_ast/visitors/base.py +133 -133
- vex_ast/visitors/printer.py +196 -146
- {vex_ast-0.2.4.dist-info → vex_ast-0.2.6.dist-info}/METADATA +206 -174
- vex_ast-0.2.6.dist-info/RECORD +64 -0
- vex_ast-0.2.4.dist-info/RECORD +0 -63
- {vex_ast-0.2.4.dist-info → vex_ast-0.2.6.dist-info}/WHEEL +0 -0
- {vex_ast-0.2.4.dist-info → vex_ast-0.2.6.dist-info}/licenses/LICENSE +0 -0
- {vex_ast-0.2.4.dist-info → vex_ast-0.2.6.dist-info}/top_level.txt +0 -0
@@ -1,147 +1,147 @@
|
|
1
|
-
from ..registry import registry
|
2
|
-
from ..signature import VexFunctionSignature, VexFunctionParameter, ParameterMode, SimulationCategory
|
3
|
-
from ...types.base import VOID, ANY
|
4
|
-
from ...types.primitives import INT, FLOAT, BOOL, STRING
|
5
|
-
from ...types.objects import BRAIN_SCREEN, CONTROLLER
|
6
|
-
|
7
|
-
def register_display_functions():
|
8
|
-
"""Register display-related functions in the registry"""
|
9
|
-
|
10
|
-
# Brain screen functions
|
11
|
-
|
12
|
-
# Brain.Screen.print() method
|
13
|
-
print_params = [
|
14
|
-
VexFunctionParameter("text", ANY, description="Text to print")
|
15
|
-
]
|
16
|
-
|
17
|
-
print_signature = VexFunctionSignature(
|
18
|
-
name="print",
|
19
|
-
return_type=VOID,
|
20
|
-
parameters=print_params,
|
21
|
-
description="Print text to the brain screen",
|
22
|
-
category=SimulationCategory.DISPLAY_OUTPUT,
|
23
|
-
python_name="print",
|
24
|
-
cpp_name="print",
|
25
|
-
object_type=BRAIN_SCREEN,
|
26
|
-
method_name="print"
|
27
|
-
)
|
28
|
-
|
29
|
-
registry.register_function(print_signature)
|
30
|
-
|
31
|
-
# Brain.Screen.clear_screen() method
|
32
|
-
clear_screen_signature = VexFunctionSignature(
|
33
|
-
name="clear_screen",
|
34
|
-
return_type=VOID,
|
35
|
-
parameters=[],
|
36
|
-
description="Clear the brain screen",
|
37
|
-
category=SimulationCategory.DISPLAY_OUTPUT,
|
38
|
-
python_name="clear_screen",
|
39
|
-
cpp_name="clearScreen",
|
40
|
-
object_type=BRAIN_SCREEN,
|
41
|
-
method_name="clear_screen"
|
42
|
-
)
|
43
|
-
|
44
|
-
registry.register_function(clear_screen_signature)
|
45
|
-
|
46
|
-
# Brain.Screen.set_cursor() method
|
47
|
-
set_cursor_params = [
|
48
|
-
VexFunctionParameter("row", INT, description="Row position"),
|
49
|
-
VexFunctionParameter("col", INT, description="Column position")
|
50
|
-
]
|
51
|
-
|
52
|
-
set_cursor_signature = VexFunctionSignature(
|
53
|
-
name="set_cursor",
|
54
|
-
return_type=VOID,
|
55
|
-
parameters=set_cursor_params,
|
56
|
-
description="Set the cursor position on the brain screen",
|
57
|
-
category=SimulationCategory.DISPLAY_OUTPUT,
|
58
|
-
python_name="set_cursor",
|
59
|
-
cpp_name="setCursor",
|
60
|
-
object_type=BRAIN_SCREEN,
|
61
|
-
method_name="set_cursor"
|
62
|
-
)
|
63
|
-
|
64
|
-
registry.register_function(set_cursor_signature)
|
65
|
-
|
66
|
-
# Brain.Screen.draw_pixel() method
|
67
|
-
draw_pixel_params = [
|
68
|
-
VexFunctionParameter("x", INT, description="X coordinate"),
|
69
|
-
VexFunctionParameter("y", INT, description="Y coordinate")
|
70
|
-
]
|
71
|
-
|
72
|
-
draw_pixel_signature = VexFunctionSignature(
|
73
|
-
name="draw_pixel",
|
74
|
-
return_type=VOID,
|
75
|
-
parameters=draw_pixel_params,
|
76
|
-
description="Draw a pixel on the brain screen",
|
77
|
-
category=SimulationCategory.DISPLAY_OUTPUT,
|
78
|
-
python_name="draw_pixel",
|
79
|
-
cpp_name="drawPixel",
|
80
|
-
object_type=BRAIN_SCREEN,
|
81
|
-
method_name="draw_pixel"
|
82
|
-
)
|
83
|
-
|
84
|
-
registry.register_function(draw_pixel_signature)
|
85
|
-
|
86
|
-
# Brain.Screen.draw_line() method
|
87
|
-
draw_line_params = [
|
88
|
-
VexFunctionParameter("x1", INT, description="Start X coordinate"),
|
89
|
-
VexFunctionParameter("y1", INT, description="Start Y coordinate"),
|
90
|
-
VexFunctionParameter("x2", INT, description="End X coordinate"),
|
91
|
-
VexFunctionParameter("y2", INT, description="End Y coordinate")
|
92
|
-
]
|
93
|
-
|
94
|
-
draw_line_signature = VexFunctionSignature(
|
95
|
-
name="draw_line",
|
96
|
-
return_type=VOID,
|
97
|
-
parameters=draw_line_params,
|
98
|
-
description="Draw a line on the brain screen",
|
99
|
-
category=SimulationCategory.DISPLAY_OUTPUT,
|
100
|
-
python_name="draw_line",
|
101
|
-
cpp_name="drawLine",
|
102
|
-
object_type=BRAIN_SCREEN,
|
103
|
-
method_name="draw_line"
|
104
|
-
)
|
105
|
-
|
106
|
-
registry.register_function(draw_line_signature)
|
107
|
-
|
108
|
-
# Controller screen functions (V5 Controller)
|
109
|
-
|
110
|
-
# Controller.Screen.print() method
|
111
|
-
controller_print_params = [
|
112
|
-
VexFunctionParameter("text", ANY, description="Text to print")
|
113
|
-
]
|
114
|
-
|
115
|
-
controller_print_signature = VexFunctionSignature(
|
116
|
-
name="print",
|
117
|
-
return_type=VOID,
|
118
|
-
parameters=controller_print_params,
|
119
|
-
description="Print text to the controller screen",
|
120
|
-
category=SimulationCategory.DISPLAY_OUTPUT,
|
121
|
-
python_name="print",
|
122
|
-
cpp_name="print",
|
123
|
-
object_type=CONTROLLER,
|
124
|
-
method_name="print"
|
125
|
-
)
|
126
|
-
|
127
|
-
registry.register_function(controller_print_signature)
|
128
|
-
|
129
|
-
# Controller.Screen.clear_screen() method
|
130
|
-
controller_clear_screen_signature = VexFunctionSignature(
|
131
|
-
name="clear_screen",
|
132
|
-
return_type=VOID,
|
133
|
-
parameters=[],
|
134
|
-
description="Clear the controller screen",
|
135
|
-
category=SimulationCategory.DISPLAY_OUTPUT,
|
136
|
-
python_name="clear_screen",
|
137
|
-
cpp_name="clearScreen",
|
138
|
-
object_type=CONTROLLER,
|
139
|
-
method_name="clear_screen"
|
140
|
-
)
|
141
|
-
|
142
|
-
registry.register_function(controller_clear_screen_signature)
|
143
|
-
|
144
|
-
# Add more display functions as needed...
|
145
|
-
|
146
|
-
if __name__ == "__main__":
|
1
|
+
from ..registry import registry
|
2
|
+
from ..signature import VexFunctionSignature, VexFunctionParameter, ParameterMode, SimulationCategory
|
3
|
+
from ...types.base import VOID, ANY
|
4
|
+
from ...types.primitives import INT, FLOAT, BOOL, STRING
|
5
|
+
from ...types.objects import BRAIN_SCREEN, CONTROLLER
|
6
|
+
|
7
|
+
def register_display_functions():
|
8
|
+
"""Register display-related functions in the registry"""
|
9
|
+
|
10
|
+
# Brain screen functions
|
11
|
+
|
12
|
+
# Brain.Screen.print() method
|
13
|
+
print_params = [
|
14
|
+
VexFunctionParameter("text", ANY, description="Text to print")
|
15
|
+
]
|
16
|
+
|
17
|
+
print_signature = VexFunctionSignature(
|
18
|
+
name="print",
|
19
|
+
return_type=VOID,
|
20
|
+
parameters=print_params,
|
21
|
+
description="Print text to the brain screen",
|
22
|
+
category=SimulationCategory.DISPLAY_OUTPUT,
|
23
|
+
python_name="print",
|
24
|
+
cpp_name="print",
|
25
|
+
object_type=BRAIN_SCREEN,
|
26
|
+
method_name="print"
|
27
|
+
)
|
28
|
+
|
29
|
+
registry.register_function(print_signature)
|
30
|
+
|
31
|
+
# Brain.Screen.clear_screen() method
|
32
|
+
clear_screen_signature = VexFunctionSignature(
|
33
|
+
name="clear_screen",
|
34
|
+
return_type=VOID,
|
35
|
+
parameters=[],
|
36
|
+
description="Clear the brain screen",
|
37
|
+
category=SimulationCategory.DISPLAY_OUTPUT,
|
38
|
+
python_name="clear_screen",
|
39
|
+
cpp_name="clearScreen",
|
40
|
+
object_type=BRAIN_SCREEN,
|
41
|
+
method_name="clear_screen"
|
42
|
+
)
|
43
|
+
|
44
|
+
registry.register_function(clear_screen_signature)
|
45
|
+
|
46
|
+
# Brain.Screen.set_cursor() method
|
47
|
+
set_cursor_params = [
|
48
|
+
VexFunctionParameter("row", INT, description="Row position"),
|
49
|
+
VexFunctionParameter("col", INT, description="Column position")
|
50
|
+
]
|
51
|
+
|
52
|
+
set_cursor_signature = VexFunctionSignature(
|
53
|
+
name="set_cursor",
|
54
|
+
return_type=VOID,
|
55
|
+
parameters=set_cursor_params,
|
56
|
+
description="Set the cursor position on the brain screen",
|
57
|
+
category=SimulationCategory.DISPLAY_OUTPUT,
|
58
|
+
python_name="set_cursor",
|
59
|
+
cpp_name="setCursor",
|
60
|
+
object_type=BRAIN_SCREEN,
|
61
|
+
method_name="set_cursor"
|
62
|
+
)
|
63
|
+
|
64
|
+
registry.register_function(set_cursor_signature)
|
65
|
+
|
66
|
+
# Brain.Screen.draw_pixel() method
|
67
|
+
draw_pixel_params = [
|
68
|
+
VexFunctionParameter("x", INT, description="X coordinate"),
|
69
|
+
VexFunctionParameter("y", INT, description="Y coordinate")
|
70
|
+
]
|
71
|
+
|
72
|
+
draw_pixel_signature = VexFunctionSignature(
|
73
|
+
name="draw_pixel",
|
74
|
+
return_type=VOID,
|
75
|
+
parameters=draw_pixel_params,
|
76
|
+
description="Draw a pixel on the brain screen",
|
77
|
+
category=SimulationCategory.DISPLAY_OUTPUT,
|
78
|
+
python_name="draw_pixel",
|
79
|
+
cpp_name="drawPixel",
|
80
|
+
object_type=BRAIN_SCREEN,
|
81
|
+
method_name="draw_pixel"
|
82
|
+
)
|
83
|
+
|
84
|
+
registry.register_function(draw_pixel_signature)
|
85
|
+
|
86
|
+
# Brain.Screen.draw_line() method
|
87
|
+
draw_line_params = [
|
88
|
+
VexFunctionParameter("x1", INT, description="Start X coordinate"),
|
89
|
+
VexFunctionParameter("y1", INT, description="Start Y coordinate"),
|
90
|
+
VexFunctionParameter("x2", INT, description="End X coordinate"),
|
91
|
+
VexFunctionParameter("y2", INT, description="End Y coordinate")
|
92
|
+
]
|
93
|
+
|
94
|
+
draw_line_signature = VexFunctionSignature(
|
95
|
+
name="draw_line",
|
96
|
+
return_type=VOID,
|
97
|
+
parameters=draw_line_params,
|
98
|
+
description="Draw a line on the brain screen",
|
99
|
+
category=SimulationCategory.DISPLAY_OUTPUT,
|
100
|
+
python_name="draw_line",
|
101
|
+
cpp_name="drawLine",
|
102
|
+
object_type=BRAIN_SCREEN,
|
103
|
+
method_name="draw_line"
|
104
|
+
)
|
105
|
+
|
106
|
+
registry.register_function(draw_line_signature)
|
107
|
+
|
108
|
+
# Controller screen functions (V5 Controller)
|
109
|
+
|
110
|
+
# Controller.Screen.print() method
|
111
|
+
controller_print_params = [
|
112
|
+
VexFunctionParameter("text", ANY, description="Text to print")
|
113
|
+
]
|
114
|
+
|
115
|
+
controller_print_signature = VexFunctionSignature(
|
116
|
+
name="print",
|
117
|
+
return_type=VOID,
|
118
|
+
parameters=controller_print_params,
|
119
|
+
description="Print text to the controller screen",
|
120
|
+
category=SimulationCategory.DISPLAY_OUTPUT,
|
121
|
+
python_name="print",
|
122
|
+
cpp_name="print",
|
123
|
+
object_type=CONTROLLER,
|
124
|
+
method_name="print"
|
125
|
+
)
|
126
|
+
|
127
|
+
registry.register_function(controller_print_signature)
|
128
|
+
|
129
|
+
# Controller.Screen.clear_screen() method
|
130
|
+
controller_clear_screen_signature = VexFunctionSignature(
|
131
|
+
name="clear_screen",
|
132
|
+
return_type=VOID,
|
133
|
+
parameters=[],
|
134
|
+
description="Clear the controller screen",
|
135
|
+
category=SimulationCategory.DISPLAY_OUTPUT,
|
136
|
+
python_name="clear_screen",
|
137
|
+
cpp_name="clearScreen",
|
138
|
+
object_type=CONTROLLER,
|
139
|
+
method_name="clear_screen"
|
140
|
+
)
|
141
|
+
|
142
|
+
registry.register_function(controller_clear_screen_signature)
|
143
|
+
|
144
|
+
# Add more display functions as needed...
|
145
|
+
|
146
|
+
if __name__ == "__main__":
|
147
147
|
register_display_functions()
|
@@ -1,163 +1,163 @@
|
|
1
|
-
from ..registry import registry
|
2
|
-
from ..signature import VexFunctionSignature, VexFunctionParameter, ParameterMode, SimulationCategory
|
3
|
-
from ...types.base import VOID
|
4
|
-
from ...types.primitives import INT, FLOAT, BOOL
|
5
|
-
from ...types.enums import DIRECTION_TYPE, TURN_TYPE, VELOCITY_UNITS, ROTATION_UNITS, DISTANCE_UNITS, BRAKE_TYPE
|
6
|
-
from ...types.objects import DRIVETRAIN
|
7
|
-
|
8
|
-
def register_drivetrain_functions():
|
9
|
-
"""Register drivetrain-related functions in the registry"""
|
10
|
-
|
11
|
-
# Drivetrain.drive() method
|
12
|
-
drive_params = [
|
13
|
-
VexFunctionParameter("direction", DIRECTION_TYPE, description="Direction to drive"),
|
14
|
-
VexFunctionParameter("velocity", FLOAT, 50.0, description="Velocity to drive at"),
|
15
|
-
VexFunctionParameter("units", VELOCITY_UNITS, "RPM", description="Velocity units")
|
16
|
-
]
|
17
|
-
|
18
|
-
drive_signature = VexFunctionSignature(
|
19
|
-
name="drive",
|
20
|
-
return_type=VOID,
|
21
|
-
parameters=drive_params,
|
22
|
-
description="Drive the drivetrain in the specified direction",
|
23
|
-
category=SimulationCategory.MOTOR_CONTROL,
|
24
|
-
python_name="drive",
|
25
|
-
cpp_name="drive",
|
26
|
-
object_type=DRIVETRAIN,
|
27
|
-
method_name="drive"
|
28
|
-
)
|
29
|
-
|
30
|
-
registry.register_function(drive_signature)
|
31
|
-
|
32
|
-
# Drivetrain.drive_for() method
|
33
|
-
drive_for_params = [
|
34
|
-
VexFunctionParameter("direction", DIRECTION_TYPE, description="Direction to drive"),
|
35
|
-
VexFunctionParameter("distance", FLOAT, description="Distance to drive"),
|
36
|
-
VexFunctionParameter("units", DISTANCE_UNITS, "INCHES", description="Distance units"),
|
37
|
-
VexFunctionParameter("velocity", FLOAT, 50.0, description="Velocity to drive at"),
|
38
|
-
VexFunctionParameter("units_v", VELOCITY_UNITS, "RPM", description="Velocity units"),
|
39
|
-
VexFunctionParameter("wait", BOOL, True, description="Whether to wait for completion")
|
40
|
-
]
|
41
|
-
|
42
|
-
drive_for_signature = VexFunctionSignature(
|
43
|
-
name="drive_for",
|
44
|
-
return_type=VOID,
|
45
|
-
parameters=drive_for_params,
|
46
|
-
description="Drive the drivetrain for a specific distance",
|
47
|
-
category=SimulationCategory.MOTOR_CONTROL,
|
48
|
-
python_name="drive_for",
|
49
|
-
cpp_name="driveFor",
|
50
|
-
object_type=DRIVETRAIN,
|
51
|
-
method_name="drive_for"
|
52
|
-
)
|
53
|
-
|
54
|
-
registry.register_function(drive_for_signature)
|
55
|
-
|
56
|
-
# Drivetrain.turn() method
|
57
|
-
turn_params = [
|
58
|
-
VexFunctionParameter("direction", TURN_TYPE, description="Direction to turn"),
|
59
|
-
VexFunctionParameter("velocity", FLOAT, 50.0, description="Velocity to turn at"),
|
60
|
-
VexFunctionParameter("units", VELOCITY_UNITS, "RPM", description="Velocity units")
|
61
|
-
]
|
62
|
-
|
63
|
-
turn_signature = VexFunctionSignature(
|
64
|
-
name="turn",
|
65
|
-
return_type=VOID,
|
66
|
-
parameters=turn_params,
|
67
|
-
description="Turn the drivetrain in the specified direction",
|
68
|
-
category=SimulationCategory.MOTOR_CONTROL,
|
69
|
-
python_name="turn",
|
70
|
-
cpp_name="turn",
|
71
|
-
object_type=DRIVETRAIN,
|
72
|
-
method_name="turn"
|
73
|
-
)
|
74
|
-
|
75
|
-
registry.register_function(turn_signature)
|
76
|
-
|
77
|
-
# Drivetrain.turn_for() method
|
78
|
-
turn_for_params = [
|
79
|
-
VexFunctionParameter("direction", TURN_TYPE, description="Direction to turn"),
|
80
|
-
VexFunctionParameter("angle", FLOAT, description="Angle to turn"),
|
81
|
-
VexFunctionParameter("units", ROTATION_UNITS, "DEGREES", description="Rotation units"),
|
82
|
-
VexFunctionParameter("velocity", FLOAT, 50.0, description="Velocity to turn at"),
|
83
|
-
VexFunctionParameter("units_v", VELOCITY_UNITS, "RPM", description="Velocity units"),
|
84
|
-
VexFunctionParameter("wait", BOOL, True, description="Whether to wait for completion")
|
85
|
-
]
|
86
|
-
|
87
|
-
turn_for_signature = VexFunctionSignature(
|
88
|
-
name="turn_for",
|
89
|
-
return_type=VOID,
|
90
|
-
parameters=turn_for_params,
|
91
|
-
description="Turn the drivetrain for a specific angle",
|
92
|
-
category=SimulationCategory.MOTOR_CONTROL,
|
93
|
-
python_name="turn_for",
|
94
|
-
cpp_name="turnFor",
|
95
|
-
object_type=DRIVETRAIN,
|
96
|
-
method_name="turn_for"
|
97
|
-
)
|
98
|
-
|
99
|
-
registry.register_function(turn_for_signature)
|
100
|
-
|
101
|
-
# Drivetrain.stop() method
|
102
|
-
stop_params = [
|
103
|
-
VexFunctionParameter("mode", BRAKE_TYPE, "COAST", description="Stopping mode (coast, brake, hold)")
|
104
|
-
]
|
105
|
-
|
106
|
-
stop_signature = VexFunctionSignature(
|
107
|
-
name="stop",
|
108
|
-
return_type=VOID,
|
109
|
-
parameters=stop_params,
|
110
|
-
description="Stop the drivetrain",
|
111
|
-
category=SimulationCategory.MOTOR_CONTROL,
|
112
|
-
python_name="stop",
|
113
|
-
cpp_name="stop",
|
114
|
-
object_type=DRIVETRAIN,
|
115
|
-
method_name="stop"
|
116
|
-
)
|
117
|
-
|
118
|
-
registry.register_function(stop_signature)
|
119
|
-
|
120
|
-
# Drivetrain.set_drive_velocity() method
|
121
|
-
set_drive_velocity_params = [
|
122
|
-
VexFunctionParameter("velocity", FLOAT, description="Velocity to set"),
|
123
|
-
VexFunctionParameter("units", VELOCITY_UNITS, "RPM", description="Velocity units")
|
124
|
-
]
|
125
|
-
|
126
|
-
set_drive_velocity_signature = VexFunctionSignature(
|
127
|
-
name="set_drive_velocity",
|
128
|
-
return_type=VOID,
|
129
|
-
parameters=set_drive_velocity_params,
|
130
|
-
description="Set the drive velocity of the drivetrain",
|
131
|
-
category=SimulationCategory.MOTOR_CONTROL,
|
132
|
-
python_name="set_drive_velocity",
|
133
|
-
cpp_name="setDriveVelocity",
|
134
|
-
object_type=DRIVETRAIN,
|
135
|
-
method_name="set_drive_velocity"
|
136
|
-
)
|
137
|
-
|
138
|
-
registry.register_function(set_drive_velocity_signature)
|
139
|
-
|
140
|
-
# Drivetrain.set_turn_velocity() method
|
141
|
-
set_turn_velocity_params = [
|
142
|
-
VexFunctionParameter("velocity", FLOAT, description="Velocity to set"),
|
143
|
-
VexFunctionParameter("units", VELOCITY_UNITS, "RPM", description="Velocity units")
|
144
|
-
]
|
145
|
-
|
146
|
-
set_turn_velocity_signature = VexFunctionSignature(
|
147
|
-
name="set_turn_velocity",
|
148
|
-
return_type=VOID,
|
149
|
-
parameters=set_turn_velocity_params,
|
150
|
-
description="Set the turn velocity of the drivetrain",
|
151
|
-
category=SimulationCategory.MOTOR_CONTROL,
|
152
|
-
python_name="set_turn_velocity",
|
153
|
-
cpp_name="setTurnVelocity",
|
154
|
-
object_type=DRIVETRAIN,
|
155
|
-
method_name="set_turn_velocity"
|
156
|
-
)
|
157
|
-
|
158
|
-
registry.register_function(set_turn_velocity_signature)
|
159
|
-
|
160
|
-
# Add more drivetrain functions as needed...
|
161
|
-
|
162
|
-
if __name__ == "__main__":
|
163
|
-
register_drivetrain_functions()
|
1
|
+
from ..registry import registry
|
2
|
+
from ..signature import VexFunctionSignature, VexFunctionParameter, ParameterMode, SimulationCategory
|
3
|
+
from ...types.base import VOID
|
4
|
+
from ...types.primitives import INT, FLOAT, BOOL
|
5
|
+
from ...types.enums import DIRECTION_TYPE, TURN_TYPE, VELOCITY_UNITS, ROTATION_UNITS, DISTANCE_UNITS, BRAKE_TYPE
|
6
|
+
from ...types.objects import DRIVETRAIN
|
7
|
+
|
8
|
+
def register_drivetrain_functions():
|
9
|
+
"""Register drivetrain-related functions in the registry"""
|
10
|
+
|
11
|
+
# Drivetrain.drive() method
|
12
|
+
drive_params = [
|
13
|
+
VexFunctionParameter("direction", DIRECTION_TYPE, description="Direction to drive"),
|
14
|
+
VexFunctionParameter("velocity", FLOAT, 50.0, description="Velocity to drive at"),
|
15
|
+
VexFunctionParameter("units", VELOCITY_UNITS, "RPM", description="Velocity units")
|
16
|
+
]
|
17
|
+
|
18
|
+
drive_signature = VexFunctionSignature(
|
19
|
+
name="drive",
|
20
|
+
return_type=VOID,
|
21
|
+
parameters=drive_params,
|
22
|
+
description="Drive the drivetrain in the specified direction",
|
23
|
+
category=SimulationCategory.MOTOR_CONTROL,
|
24
|
+
python_name="drive",
|
25
|
+
cpp_name="drive",
|
26
|
+
object_type=DRIVETRAIN,
|
27
|
+
method_name="drive"
|
28
|
+
)
|
29
|
+
|
30
|
+
registry.register_function(drive_signature)
|
31
|
+
|
32
|
+
# Drivetrain.drive_for() method
|
33
|
+
drive_for_params = [
|
34
|
+
VexFunctionParameter("direction", DIRECTION_TYPE, description="Direction to drive"),
|
35
|
+
VexFunctionParameter("distance", FLOAT, description="Distance to drive"),
|
36
|
+
VexFunctionParameter("units", DISTANCE_UNITS, "INCHES", description="Distance units"),
|
37
|
+
VexFunctionParameter("velocity", FLOAT, 50.0, description="Velocity to drive at"),
|
38
|
+
VexFunctionParameter("units_v", VELOCITY_UNITS, "RPM", description="Velocity units"),
|
39
|
+
VexFunctionParameter("wait", BOOL, True, description="Whether to wait for completion")
|
40
|
+
]
|
41
|
+
|
42
|
+
drive_for_signature = VexFunctionSignature(
|
43
|
+
name="drive_for",
|
44
|
+
return_type=VOID,
|
45
|
+
parameters=drive_for_params,
|
46
|
+
description="Drive the drivetrain for a specific distance",
|
47
|
+
category=SimulationCategory.MOTOR_CONTROL,
|
48
|
+
python_name="drive_for",
|
49
|
+
cpp_name="driveFor",
|
50
|
+
object_type=DRIVETRAIN,
|
51
|
+
method_name="drive_for"
|
52
|
+
)
|
53
|
+
|
54
|
+
registry.register_function(drive_for_signature)
|
55
|
+
|
56
|
+
# Drivetrain.turn() method
|
57
|
+
turn_params = [
|
58
|
+
VexFunctionParameter("direction", TURN_TYPE, description="Direction to turn"),
|
59
|
+
VexFunctionParameter("velocity", FLOAT, 50.0, description="Velocity to turn at"),
|
60
|
+
VexFunctionParameter("units", VELOCITY_UNITS, "RPM", description="Velocity units")
|
61
|
+
]
|
62
|
+
|
63
|
+
turn_signature = VexFunctionSignature(
|
64
|
+
name="turn",
|
65
|
+
return_type=VOID,
|
66
|
+
parameters=turn_params,
|
67
|
+
description="Turn the drivetrain in the specified direction",
|
68
|
+
category=SimulationCategory.MOTOR_CONTROL,
|
69
|
+
python_name="turn",
|
70
|
+
cpp_name="turn",
|
71
|
+
object_type=DRIVETRAIN,
|
72
|
+
method_name="turn"
|
73
|
+
)
|
74
|
+
|
75
|
+
registry.register_function(turn_signature)
|
76
|
+
|
77
|
+
# Drivetrain.turn_for() method
|
78
|
+
turn_for_params = [
|
79
|
+
VexFunctionParameter("direction", TURN_TYPE, description="Direction to turn"),
|
80
|
+
VexFunctionParameter("angle", FLOAT, description="Angle to turn"),
|
81
|
+
VexFunctionParameter("units", ROTATION_UNITS, "DEGREES", description="Rotation units"),
|
82
|
+
VexFunctionParameter("velocity", FLOAT, 50.0, description="Velocity to turn at"),
|
83
|
+
VexFunctionParameter("units_v", VELOCITY_UNITS, "RPM", description="Velocity units"),
|
84
|
+
VexFunctionParameter("wait", BOOL, True, description="Whether to wait for completion")
|
85
|
+
]
|
86
|
+
|
87
|
+
turn_for_signature = VexFunctionSignature(
|
88
|
+
name="turn_for",
|
89
|
+
return_type=VOID,
|
90
|
+
parameters=turn_for_params,
|
91
|
+
description="Turn the drivetrain for a specific angle",
|
92
|
+
category=SimulationCategory.MOTOR_CONTROL,
|
93
|
+
python_name="turn_for",
|
94
|
+
cpp_name="turnFor",
|
95
|
+
object_type=DRIVETRAIN,
|
96
|
+
method_name="turn_for"
|
97
|
+
)
|
98
|
+
|
99
|
+
registry.register_function(turn_for_signature)
|
100
|
+
|
101
|
+
# Drivetrain.stop() method
|
102
|
+
stop_params = [
|
103
|
+
VexFunctionParameter("mode", BRAKE_TYPE, "COAST", description="Stopping mode (coast, brake, hold)")
|
104
|
+
]
|
105
|
+
|
106
|
+
stop_signature = VexFunctionSignature(
|
107
|
+
name="stop",
|
108
|
+
return_type=VOID,
|
109
|
+
parameters=stop_params,
|
110
|
+
description="Stop the drivetrain",
|
111
|
+
category=SimulationCategory.MOTOR_CONTROL,
|
112
|
+
python_name="stop",
|
113
|
+
cpp_name="stop",
|
114
|
+
object_type=DRIVETRAIN,
|
115
|
+
method_name="stop"
|
116
|
+
)
|
117
|
+
|
118
|
+
registry.register_function(stop_signature)
|
119
|
+
|
120
|
+
# Drivetrain.set_drive_velocity() method
|
121
|
+
set_drive_velocity_params = [
|
122
|
+
VexFunctionParameter("velocity", FLOAT, description="Velocity to set"),
|
123
|
+
VexFunctionParameter("units", VELOCITY_UNITS, "RPM", description="Velocity units")
|
124
|
+
]
|
125
|
+
|
126
|
+
set_drive_velocity_signature = VexFunctionSignature(
|
127
|
+
name="set_drive_velocity",
|
128
|
+
return_type=VOID,
|
129
|
+
parameters=set_drive_velocity_params,
|
130
|
+
description="Set the drive velocity of the drivetrain",
|
131
|
+
category=SimulationCategory.MOTOR_CONTROL,
|
132
|
+
python_name="set_drive_velocity",
|
133
|
+
cpp_name="setDriveVelocity",
|
134
|
+
object_type=DRIVETRAIN,
|
135
|
+
method_name="set_drive_velocity"
|
136
|
+
)
|
137
|
+
|
138
|
+
registry.register_function(set_drive_velocity_signature)
|
139
|
+
|
140
|
+
# Drivetrain.set_turn_velocity() method
|
141
|
+
set_turn_velocity_params = [
|
142
|
+
VexFunctionParameter("velocity", FLOAT, description="Velocity to set"),
|
143
|
+
VexFunctionParameter("units", VELOCITY_UNITS, "RPM", description="Velocity units")
|
144
|
+
]
|
145
|
+
|
146
|
+
set_turn_velocity_signature = VexFunctionSignature(
|
147
|
+
name="set_turn_velocity",
|
148
|
+
return_type=VOID,
|
149
|
+
parameters=set_turn_velocity_params,
|
150
|
+
description="Set the turn velocity of the drivetrain",
|
151
|
+
category=SimulationCategory.MOTOR_CONTROL,
|
152
|
+
python_name="set_turn_velocity",
|
153
|
+
cpp_name="setTurnVelocity",
|
154
|
+
object_type=DRIVETRAIN,
|
155
|
+
method_name="set_turn_velocity"
|
156
|
+
)
|
157
|
+
|
158
|
+
registry.register_function(set_turn_velocity_signature)
|
159
|
+
|
160
|
+
# Add more drivetrain functions as needed...
|
161
|
+
|
162
|
+
if __name__ == "__main__":
|
163
|
+
register_drivetrain_functions()
|