vex-ast 0.1.0__py3-none-any.whl → 0.2.1__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 +51 -0
- vex_ast/READMEAPI.md +318 -0
- vex_ast/__init__.py +20 -17
- vex_ast/ast/README.md +87 -0
- vex_ast/ast/__init__.py +1 -1
- vex_ast/ast/navigator.py +12 -0
- vex_ast/parser/README.md +47 -0
- vex_ast/parser/__init__.py +27 -0
- vex_ast/registry/README.md +29 -0
- vex_ast/registry/functions/__init__.py +11 -0
- vex_ast/registry/functions/display.py +147 -0
- vex_ast/registry/functions/drivetrain.py +163 -0
- vex_ast/registry/functions/initialize.py +28 -0
- vex_ast/registry/functions/motor.py +140 -0
- vex_ast/registry/functions/sensors.py +195 -0
- vex_ast/registry/functions/timing.py +104 -0
- vex_ast/types/README.md +26 -0
- vex_ast/types/__init__.py +140 -0
- vex_ast/types/base.py +84 -0
- vex_ast/types/enums.py +97 -0
- vex_ast/types/objects.py +64 -0
- vex_ast/types/primitives.py +69 -0
- vex_ast/types/type_checker.py +32 -0
- vex_ast/utils/README.md +39 -0
- vex_ast/utils/__init__.py +38 -0
- vex_ast/utils/type_definitions.py +9 -0
- vex_ast/visitors/README.md +49 -0
- vex_ast/visitors/__init__.py +28 -0
- {vex_ast-0.1.0.dist-info → vex_ast-0.2.1.dist-info}/METADATA +9 -11
- vex_ast-0.2.1.dist-info/RECORD +63 -0
- vex_ast-0.2.1.dist-info/licenses/LICENSE +1 -0
- vex_ast-0.1.0.dist-info/RECORD +0 -41
- {vex_ast-0.1.0.dist-info → vex_ast-0.2.1.dist-info}/WHEEL +0 -0
- {vex_ast-0.1.0.dist-info → vex_ast-0.2.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +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__":
|
147
|
+
register_display_functions()
|
@@ -0,0 +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()
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"""Initialize all VEX function definitions in the registry"""
|
2
|
+
|
3
|
+
from . import motor, drivetrain, sensors, timing, display
|
4
|
+
# Import other function modules as they are added
|
5
|
+
|
6
|
+
def initialize_registry():
|
7
|
+
"""Initialize the registry with all VEX functions"""
|
8
|
+
# Motor functions
|
9
|
+
motor.register_motor_functions()
|
10
|
+
|
11
|
+
# Drivetrain functions
|
12
|
+
drivetrain.register_drivetrain_functions()
|
13
|
+
|
14
|
+
# Sensor functions
|
15
|
+
sensors.register_sensor_functions()
|
16
|
+
|
17
|
+
# Timing functions
|
18
|
+
timing.register_timing_functions()
|
19
|
+
|
20
|
+
# Display functions
|
21
|
+
display.register_display_functions()
|
22
|
+
|
23
|
+
# Add other function registration calls as modules are added
|
24
|
+
|
25
|
+
print("VEX function registry initialized successfully")
|
26
|
+
|
27
|
+
if __name__ == "__main__":
|
28
|
+
initialize_registry()
|
@@ -0,0 +1,140 @@
|
|
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, VELOCITY_UNITS, ROTATION_UNITS, BRAKE_TYPE
|
6
|
+
from ...types.objects import MOTOR
|
7
|
+
|
8
|
+
def register_motor_functions():
|
9
|
+
"""Register motor-related functions in the registry"""
|
10
|
+
|
11
|
+
# Motor.spin() method
|
12
|
+
spin_params = [
|
13
|
+
VexFunctionParameter("direction", DIRECTION_TYPE, description="Direction to spin the motor"),
|
14
|
+
VexFunctionParameter("velocity", FLOAT, 50.0, description="Velocity to spin at"),
|
15
|
+
VexFunctionParameter("units", VELOCITY_UNITS, "RPM", description="Velocity units")
|
16
|
+
]
|
17
|
+
|
18
|
+
spin_signature = VexFunctionSignature(
|
19
|
+
name="spin",
|
20
|
+
return_type=VOID,
|
21
|
+
parameters=spin_params,
|
22
|
+
description="Spin the motor in the specified direction",
|
23
|
+
category=SimulationCategory.MOTOR_CONTROL,
|
24
|
+
python_name="spin",
|
25
|
+
cpp_name="spin",
|
26
|
+
object_type=MOTOR,
|
27
|
+
method_name="spin"
|
28
|
+
)
|
29
|
+
|
30
|
+
registry.register_function(spin_signature)
|
31
|
+
|
32
|
+
# Motor.stop() method
|
33
|
+
stop_params = [
|
34
|
+
VexFunctionParameter("mode", BRAKE_TYPE, "COAST", description="Stopping mode (coast, brake, hold)")
|
35
|
+
]
|
36
|
+
|
37
|
+
stop_signature = VexFunctionSignature(
|
38
|
+
name="stop",
|
39
|
+
return_type=VOID,
|
40
|
+
parameters=stop_params,
|
41
|
+
description="Stop the motor",
|
42
|
+
category=SimulationCategory.MOTOR_CONTROL,
|
43
|
+
python_name="stop",
|
44
|
+
cpp_name="stop",
|
45
|
+
object_type=MOTOR,
|
46
|
+
method_name="stop"
|
47
|
+
)
|
48
|
+
|
49
|
+
registry.register_function(stop_signature)
|
50
|
+
|
51
|
+
# Motor.spin_to_position() method
|
52
|
+
spin_to_position_params = [
|
53
|
+
VexFunctionParameter("position", FLOAT, description="Position to spin to"),
|
54
|
+
VexFunctionParameter("units", ROTATION_UNITS, "DEGREES", description="Rotation units"),
|
55
|
+
VexFunctionParameter("velocity", FLOAT, 50.0, description="Velocity to spin at"),
|
56
|
+
VexFunctionParameter("units_v", VELOCITY_UNITS, "RPM", description="Velocity units"),
|
57
|
+
VexFunctionParameter("wait", BOOL, True, description="Whether to wait for completion")
|
58
|
+
]
|
59
|
+
|
60
|
+
spin_to_position_signature = VexFunctionSignature(
|
61
|
+
name="spin_to_position",
|
62
|
+
return_type=VOID,
|
63
|
+
parameters=spin_to_position_params,
|
64
|
+
description="Spin the motor to an absolute position",
|
65
|
+
category=SimulationCategory.MOTOR_CONTROL,
|
66
|
+
python_name="spin_to_position",
|
67
|
+
cpp_name="spinToPosition",
|
68
|
+
object_type=MOTOR,
|
69
|
+
method_name="spin_to_position"
|
70
|
+
)
|
71
|
+
|
72
|
+
registry.register_function(spin_to_position_signature)
|
73
|
+
|
74
|
+
# Motor.spin_for() method
|
75
|
+
spin_for_params = [
|
76
|
+
VexFunctionParameter("direction", DIRECTION_TYPE, description="Direction to spin"),
|
77
|
+
VexFunctionParameter("amount", FLOAT, description="Amount to spin"),
|
78
|
+
VexFunctionParameter("units", ROTATION_UNITS, "DEGREES", description="Rotation units"),
|
79
|
+
VexFunctionParameter("velocity", FLOAT, 50.0, description="Velocity to spin at"),
|
80
|
+
VexFunctionParameter("units_v", VELOCITY_UNITS, "RPM", description="Velocity units"),
|
81
|
+
VexFunctionParameter("wait", BOOL, True, description="Whether to wait for completion")
|
82
|
+
]
|
83
|
+
|
84
|
+
spin_for_signature = VexFunctionSignature(
|
85
|
+
name="spin_for",
|
86
|
+
return_type=VOID,
|
87
|
+
parameters=spin_for_params,
|
88
|
+
description="Spin the motor for a relative amount",
|
89
|
+
category=SimulationCategory.MOTOR_CONTROL,
|
90
|
+
python_name="spin_for",
|
91
|
+
cpp_name="spinFor",
|
92
|
+
object_type=MOTOR,
|
93
|
+
method_name="spin_for"
|
94
|
+
)
|
95
|
+
|
96
|
+
registry.register_function(spin_for_signature)
|
97
|
+
|
98
|
+
# Motor.set_velocity() method
|
99
|
+
set_velocity_params = [
|
100
|
+
VexFunctionParameter("velocity", FLOAT, description="Velocity to set"),
|
101
|
+
VexFunctionParameter("units", VELOCITY_UNITS, "RPM", description="Velocity units")
|
102
|
+
]
|
103
|
+
|
104
|
+
set_velocity_signature = VexFunctionSignature(
|
105
|
+
name="set_velocity",
|
106
|
+
return_type=VOID,
|
107
|
+
parameters=set_velocity_params,
|
108
|
+
description="Set the velocity of the motor",
|
109
|
+
category=SimulationCategory.MOTOR_CONTROL,
|
110
|
+
python_name="set_velocity",
|
111
|
+
cpp_name="setVelocity",
|
112
|
+
object_type=MOTOR,
|
113
|
+
method_name="set_velocity"
|
114
|
+
)
|
115
|
+
|
116
|
+
registry.register_function(set_velocity_signature)
|
117
|
+
|
118
|
+
# Motor.set_stopping() method
|
119
|
+
set_stopping_params = [
|
120
|
+
VexFunctionParameter("mode", BRAKE_TYPE, description="Stopping mode (coast, brake, hold)")
|
121
|
+
]
|
122
|
+
|
123
|
+
set_stopping_signature = VexFunctionSignature(
|
124
|
+
name="set_stopping",
|
125
|
+
return_type=VOID,
|
126
|
+
parameters=set_stopping_params,
|
127
|
+
description="Set the stopping mode of the motor",
|
128
|
+
category=SimulationCategory.MOTOR_CONTROL,
|
129
|
+
python_name="set_stopping",
|
130
|
+
cpp_name="setStopping",
|
131
|
+
object_type=MOTOR,
|
132
|
+
method_name="set_stopping"
|
133
|
+
)
|
134
|
+
|
135
|
+
registry.register_function(set_stopping_signature)
|
136
|
+
|
137
|
+
# Add more motor functions as needed...
|
138
|
+
|
139
|
+
if __name__ == "__main__":
|
140
|
+
register_motor_functions()
|
@@ -0,0 +1,195 @@
|
|
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
|
5
|
+
from ...types.enums import DISTANCE_UNITS, ROTATION_UNITS, VELOCITY_UNITS
|
6
|
+
from ...types.objects import DISTANCE, ROTATION, INERTIAL, OPTICAL, GPS
|
7
|
+
|
8
|
+
def register_sensor_functions():
|
9
|
+
"""Register sensor-related functions in the registry"""
|
10
|
+
|
11
|
+
# Distance sensor functions
|
12
|
+
|
13
|
+
# Distance.object_distance() method
|
14
|
+
object_distance_params = [
|
15
|
+
VexFunctionParameter("units", DISTANCE_UNITS, "MM", description="Distance units")
|
16
|
+
]
|
17
|
+
|
18
|
+
object_distance_signature = VexFunctionSignature(
|
19
|
+
name="object_distance",
|
20
|
+
return_type=FLOAT,
|
21
|
+
parameters=object_distance_params,
|
22
|
+
description="Get the distance to the detected object",
|
23
|
+
category=SimulationCategory.SENSOR_READING,
|
24
|
+
python_name="object_distance",
|
25
|
+
cpp_name="objectDistance",
|
26
|
+
object_type=DISTANCE,
|
27
|
+
method_name="object_distance"
|
28
|
+
)
|
29
|
+
|
30
|
+
registry.register_function(object_distance_signature)
|
31
|
+
|
32
|
+
# Distance.is_object_detected() method
|
33
|
+
is_object_detected_signature = VexFunctionSignature(
|
34
|
+
name="is_object_detected",
|
35
|
+
return_type=BOOL,
|
36
|
+
parameters=[],
|
37
|
+
description="Check if an object is detected",
|
38
|
+
category=SimulationCategory.SENSOR_READING,
|
39
|
+
python_name="is_object_detected",
|
40
|
+
cpp_name="isObjectDetected",
|
41
|
+
object_type=DISTANCE,
|
42
|
+
method_name="is_object_detected"
|
43
|
+
)
|
44
|
+
|
45
|
+
registry.register_function(is_object_detected_signature)
|
46
|
+
|
47
|
+
# Rotation sensor functions
|
48
|
+
|
49
|
+
# Rotation.angle() method
|
50
|
+
angle_params = [
|
51
|
+
VexFunctionParameter("units", ROTATION_UNITS, "DEGREES", description="Rotation units")
|
52
|
+
]
|
53
|
+
|
54
|
+
angle_signature = VexFunctionSignature(
|
55
|
+
name="angle",
|
56
|
+
return_type=FLOAT,
|
57
|
+
parameters=angle_params,
|
58
|
+
description="Get the angle of the rotation sensor",
|
59
|
+
category=SimulationCategory.SENSOR_READING,
|
60
|
+
python_name="angle",
|
61
|
+
cpp_name="angle",
|
62
|
+
object_type=ROTATION,
|
63
|
+
method_name="angle"
|
64
|
+
)
|
65
|
+
|
66
|
+
registry.register_function(angle_signature)
|
67
|
+
|
68
|
+
# Rotation.reset_position() method
|
69
|
+
reset_position_signature = VexFunctionSignature(
|
70
|
+
name="reset_position",
|
71
|
+
return_type=VOID,
|
72
|
+
parameters=[],
|
73
|
+
description="Reset the position of the rotation sensor",
|
74
|
+
category=SimulationCategory.SENSOR_READING,
|
75
|
+
python_name="reset_position",
|
76
|
+
cpp_name="resetPosition",
|
77
|
+
object_type=ROTATION,
|
78
|
+
method_name="reset_position"
|
79
|
+
)
|
80
|
+
|
81
|
+
registry.register_function(reset_position_signature)
|
82
|
+
|
83
|
+
# Rotation.set_position() method
|
84
|
+
set_position_params = [
|
85
|
+
VexFunctionParameter("value", FLOAT, description="Position value to set"),
|
86
|
+
VexFunctionParameter("units", ROTATION_UNITS, "DEGREES", description="Rotation units")
|
87
|
+
]
|
88
|
+
|
89
|
+
set_position_signature = VexFunctionSignature(
|
90
|
+
name="set_position",
|
91
|
+
return_type=VOID,
|
92
|
+
parameters=set_position_params,
|
93
|
+
description="Set the position of the rotation sensor",
|
94
|
+
category=SimulationCategory.SENSOR_READING,
|
95
|
+
python_name="set_position",
|
96
|
+
cpp_name="setPosition",
|
97
|
+
object_type=ROTATION,
|
98
|
+
method_name="set_position"
|
99
|
+
)
|
100
|
+
|
101
|
+
registry.register_function(set_position_signature)
|
102
|
+
|
103
|
+
# Rotation.velocity() method
|
104
|
+
velocity_params = [
|
105
|
+
VexFunctionParameter("units", VELOCITY_UNITS, "RPM", description="Velocity units")
|
106
|
+
]
|
107
|
+
|
108
|
+
velocity_signature = VexFunctionSignature(
|
109
|
+
name="velocity",
|
110
|
+
return_type=FLOAT,
|
111
|
+
parameters=velocity_params,
|
112
|
+
description="Get the velocity of the rotation sensor",
|
113
|
+
category=SimulationCategory.SENSOR_READING,
|
114
|
+
python_name="velocity",
|
115
|
+
cpp_name="velocity",
|
116
|
+
object_type=ROTATION,
|
117
|
+
method_name="velocity"
|
118
|
+
)
|
119
|
+
|
120
|
+
registry.register_function(velocity_signature)
|
121
|
+
|
122
|
+
# Inertial sensor functions
|
123
|
+
|
124
|
+
# Inertial.calibrate() method
|
125
|
+
calibrate_signature = VexFunctionSignature(
|
126
|
+
name="calibrate",
|
127
|
+
return_type=VOID,
|
128
|
+
parameters=[],
|
129
|
+
description="Calibrate the inertial sensor",
|
130
|
+
category=SimulationCategory.SENSOR_READING,
|
131
|
+
python_name="calibrate",
|
132
|
+
cpp_name="calibrate",
|
133
|
+
object_type=INERTIAL,
|
134
|
+
method_name="calibrate"
|
135
|
+
)
|
136
|
+
|
137
|
+
registry.register_function(calibrate_signature)
|
138
|
+
|
139
|
+
# Inertial.is_calibrating() method
|
140
|
+
is_calibrating_signature = VexFunctionSignature(
|
141
|
+
name="is_calibrating",
|
142
|
+
return_type=BOOL,
|
143
|
+
parameters=[],
|
144
|
+
description="Check if the inertial sensor is calibrating",
|
145
|
+
category=SimulationCategory.SENSOR_READING,
|
146
|
+
python_name="is_calibrating",
|
147
|
+
cpp_name="isCalibrating",
|
148
|
+
object_type=INERTIAL,
|
149
|
+
method_name="is_calibrating"
|
150
|
+
)
|
151
|
+
|
152
|
+
registry.register_function(is_calibrating_signature)
|
153
|
+
|
154
|
+
# Inertial.heading() method
|
155
|
+
heading_params = [
|
156
|
+
VexFunctionParameter("units", ROTATION_UNITS, "DEGREES", description="Rotation units")
|
157
|
+
]
|
158
|
+
|
159
|
+
heading_signature = VexFunctionSignature(
|
160
|
+
name="heading",
|
161
|
+
return_type=FLOAT,
|
162
|
+
parameters=heading_params,
|
163
|
+
description="Get the heading of the inertial sensor",
|
164
|
+
category=SimulationCategory.SENSOR_READING,
|
165
|
+
python_name="heading",
|
166
|
+
cpp_name="heading",
|
167
|
+
object_type=INERTIAL,
|
168
|
+
method_name="heading"
|
169
|
+
)
|
170
|
+
|
171
|
+
registry.register_function(heading_signature)
|
172
|
+
|
173
|
+
# Inertial.rotation() method
|
174
|
+
rotation_params = [
|
175
|
+
VexFunctionParameter("units", ROTATION_UNITS, "DEGREES", description="Rotation units")
|
176
|
+
]
|
177
|
+
|
178
|
+
rotation_signature = VexFunctionSignature(
|
179
|
+
name="rotation",
|
180
|
+
return_type=FLOAT,
|
181
|
+
parameters=rotation_params,
|
182
|
+
description="Get the rotation of the inertial sensor",
|
183
|
+
category=SimulationCategory.SENSOR_READING,
|
184
|
+
python_name="rotation",
|
185
|
+
cpp_name="rotation",
|
186
|
+
object_type=INERTIAL,
|
187
|
+
method_name="rotation"
|
188
|
+
)
|
189
|
+
|
190
|
+
registry.register_function(rotation_signature)
|
191
|
+
|
192
|
+
# Add more sensor functions for other sensor types...
|
193
|
+
|
194
|
+
if __name__ == "__main__":
|
195
|
+
register_sensor_functions()
|