Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better consistency naming of headmodes #653

Merged
merged 5 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from bitbots_msgs.msg import Audio, HeadMode, RobotControlState

THeadMode: TypeAlias = Literal[ # type: ignore[valid-type]
HeadMode.BALL_MODE,
HeadMode.FIELD_FEATURES,
HeadMode.SEARCH_BALL,
HeadMode.SEARCH_FIELD_FEATURES,
HeadMode.LOOK_FORWARD,
HeadMode.DONT_MOVE,
HeadMode.BALL_MODE_PENALTY,
HeadMode.LOOK_FRONT,
HeadMode.SEARCH_BALL_PENALTY,
HeadMode.SEARCH_FRONT,
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ class SearchBall(AbstractHeadModeElement):
"""Look for ball"""

def perform(self):
self.blackboard.misc.set_head_duty(HeadMode.BALL_MODE)
self.blackboard.misc.set_head_duty(HeadMode.SEARCH_BALL)
return self.pop()


class LookAtFieldFeatures(AbstractHeadModeElement):
"""Look generally for all features on the field (ball, goals, corners, center point)"""

def perform(self):
self.blackboard.misc.set_head_duty(HeadMode.FIELD_FEATURES)
self.blackboard.misc.set_head_duty(HeadMode.SEARCH_FIELD_FEATURES)
return self.pop()


Expand All @@ -77,13 +77,13 @@ class LookAtBallPenalty(AbstractHeadModeElement):
"""Ball Mode adapted for Penalty Kick"""

def perform(self):
self.blackboard.misc.set_head_duty(HeadMode.BALL_MODE_PENALTY)
self.blackboard.misc.set_head_duty(HeadMode.SEARCH_BALL_PENALTY)
return self.pop()


class LookAtFront(AbstractHeadModeElement):
"""Search in front of the robot"""

def perform(self):
self.blackboard.misc.set_head_duty(HeadMode.LOOK_FRONT)
self.blackboard.misc.set_head_duty(HeadMode.SEARCH_FRONT)
return self.pop()
16 changes: 8 additions & 8 deletions bitbots_misc/bitbots_teleop/scripts/teleop_keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ def loop(self):
self.head_pub.publish(self.head_msg)
elif key == "0":
# Search for Ball and track it if found
self.head_mode_msg.head_mode = HeadMode.BALL_MODE
assert int(key) == HeadMode.BALL_MODE
self.head_mode_msg.head_mode = HeadMode.SEARCH_BALL
assert int(key) == HeadMode.SEARCH_BALL
elif key == "1":
# Look generally for all features on the field (ball, goals, corners, center point)
self.head_mode_msg.head_mode = HeadMode.FIELD_FEATURES
assert int(key) == HeadMode.FIELD_FEATURES
self.head_mode_msg.head_mode = HeadMode.SEARCH_FIELD_FEATURES
assert int(key) == HeadMode.SEARCH_FIELD_FEATURES
elif key == "2":
# Simply look directly forward
self.head_mode_msg.head_mode = HeadMode.LOOK_FORWARD
Expand All @@ -238,12 +238,12 @@ def loop(self):
assert int(key) == HeadMode.DONT_MOVE
elif key == "4":
# Ball Mode adapted for Penalty Kick
self.head_mode_msg.head_mode = HeadMode.BALL_MODE_PENALTY
assert int(key) == HeadMode.BALL_MODE_PENALTY
self.head_mode_msg.head_mode = HeadMode.SEARCH_BALL_PENALTY
assert int(key) == HeadMode.SEARCH_BALL_PENALTY
elif key == "5":
# Do a pattern which only looks in front of the robot
self.head_mode_msg.head_mode = HeadMode.LOOK_FRONT
assert int(key) == HeadMode.LOOK_FRONT
self.head_mode_msg.head_mode = HeadMode.SEARCH_FRONT
assert int(key) == HeadMode.SEARCH_FRONT
elif key == "y":
# kick left forward
pass
Expand Down
Loading
Loading