-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding basic roboter info to the app control
- Loading branch information
1 parent
1651b81
commit 4859240
Showing
2 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from rosys.automation import Automator | ||
from rosys.automation import app_controls as RosysAppControls | ||
from rosys.hardware import RobotBrain | ||
|
||
from .hardware.field_friend import FieldFriend | ||
|
||
|
||
class AppControls(RosysAppControls): | ||
|
||
def __init__(self, | ||
robot_brain: RobotBrain, | ||
automator: Automator, | ||
robot: FieldFriend, | ||
) -> None: | ||
super().__init__(robot_brain, automator) | ||
self.robot = robot | ||
self.last_info: str = '' | ||
self.APP_CONNECTED.register(self.reset) | ||
|
||
async def sync(self) -> None: | ||
await super().sync() | ||
infos = [] | ||
|
||
if self.robot.estop.active: | ||
infos.append("E Stop active") | ||
if self.robot.bumper.active_bumpers: | ||
infos.append(f'Bumper ({" ".join(self.robot.bumper.active_bumpers)}) active') | ||
if self.robot.bms.state.is_charging: | ||
infos.append('charging battery') | ||
battery = f'{self.robot.bms.state.percentage:.0f}%' if self.robot.bms.state.percentage is not None else '?' | ||
infos.append(f'Battery: {battery}') | ||
|
||
info = ' | '.join(infos) | ||
if info != self.last_info: | ||
await self.set_info(info) | ||
self.last_info = info | ||
|
||
def reset(self) -> None: | ||
self.last_info = 'loading' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters