-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
56 additions
and
25 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
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
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
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 |
---|---|---|
|
@@ -38,3 +38,4 @@ def namespace(self): | |
@property | ||
def launch_controllers(self): | ||
return self._launch_controllers | ||
|
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,31 @@ | ||
import logging as log | ||
from sensor_msgs.msg import BatteryState | ||
|
||
class StateController: | ||
""" | ||
A class for managing the robot's state. | ||
Attributes | ||
---------- | ||
ros_interface (ROSInterface): An object for managing ROS2 communications and functionalities. | ||
battery_state (BatteryState): Stores the current state of the robot's battery. | ||
Methods | ||
------- | ||
battery_state_cb(data): Callback method for updating battery state. | ||
""" | ||
|
||
def __init__(self, ros_interface): | ||
self._ros_interface = ros_interface | ||
self._ros_interface.create_subscriber( | ||
"/battery_status", BatteryState, self.battery_state_cb) | ||
self._battery_state = None | ||
log.info("State Controller ready") | ||
|
||
def battery_state_cb(self, data): | ||
self._battery_state = data | ||
|
||
@property | ||
def battery_state(self): | ||
return self._battery_state |