Skip to content

Commit 6ec6d3a

Browse files
authored
Merge pull request #261 from thedropbears/rescale_ball_size
2 parents 9da0464 + b718a93 commit 6ec6d3a

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

components/ballistics.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
from components.injector import InjectorComponent
1515
from components.led_component import LightStrip
1616
from components.shooter import ShooterComponent
17-
from utilities.game import FIELD_LENGTH, FIELD_WIDTH, is_red
17+
from utilities.game import (
18+
ALGAE_MAX_DIAMETER,
19+
ALGAE_MIN_DIAMETER,
20+
FIELD_LENGTH,
21+
FIELD_WIDTH,
22+
is_red,
23+
)
1824

1925

2026
@wpiutil.wpistruct.make_wpistruct
@@ -42,16 +48,16 @@ class BallisticsComponent:
4248
# Tuples are values corresponding to the distances above
4349
# fmt: off
4450
FLYWHEEL_TOP_SPEED_LOOKUP = {
45-
16.0: (30, 32.5, 38.0), # , 90
51+
ALGAE_MIN_DIAMETER: (30, 32.5, 38.0), # , 90
4652
# 16.5: (60, 80),
47-
17.0: (33, 36, 39.0), # , 50
53+
ALGAE_MAX_DIAMETER: (33, 36, 39.0), # , 50
4854
}
4955
# Currently we use the same speed top and bottom, but this could be seperate
5056
FLYWHEEL_BOTTOM_SPEED_LOOKUP = FLYWHEEL_TOP_SPEED_LOOKUP
5157
FLYWHEEL_ANGLE_LOOKUP = {
52-
16.0: (math.radians(-10), math.radians(-12), math.radians(-19)), # , math.radians(-25)
58+
ALGAE_MIN_DIAMETER: (math.radians(-10), math.radians(-12), math.radians(-19)), # , math.radians(-25)
5359
# 16.5: (math.radians(-15), math.radians(-20)),
54-
17.0: (math.radians(-10), math.radians(-12), math.radians(-19)), # , math.radians(-25)
60+
ALGAE_MAX_DIAMETER: (math.radians(-10), math.radians(-12), math.radians(-19)), # , math.radians(-25)
5561
}
5662
# fmt: on
5763
BALL_SIZES = list(FLYWHEEL_ANGLE_LOOKUP.keys())

controllers/algae_measurement.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from components.injector import InjectorComponent
44
from components.shooter import ShooterComponent
5+
from utilities.game import ALGAE_MAX_DIAMETER, ALGAE_MIN_DIAMETER
56
from utilities.scalers import scale_value
67

78

@@ -73,7 +74,13 @@ def measuring(self, initial_call) -> None:
7374
) - sum(self.injector_starting_positions)
7475
self.measured_raw_sizes.append(injector_position_delta)
7576
self.measured_sizes.append(
76-
scale_value(injector_position_delta, 7.2, 4.9, 16.0, 17.0)
77+
scale_value(
78+
injector_position_delta,
79+
7.2,
80+
4.9,
81+
ALGAE_MIN_DIAMETER,
82+
ALGAE_MAX_DIAMETER,
83+
)
7784
)
7885

7986
self.next_state(self.calculating)

utilities/game.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
+ get_fiducial_pose(21).translation().toTranslation2d()
4343
) / 2
4444

45+
ALGAE_MIN_DIAMETER = 16.0 # inches
46+
ALGAE_MAX_DIAMETER = 16.5 # inches
47+
4548

4649
def cage_pos(is_red: bool) -> list[Translation2d]:
4750
if is_red:

0 commit comments

Comments
 (0)