Skip to content

Commit

Permalink
Added lots of profiling to OSL code.
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Feb 3, 2025
1 parent 4af51e8 commit 4a3a361
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions opensourceleg/hardware/actuators.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from ..tools.safety import ThermalLimitException
from .thermal import ThermalModel
from .AS5048B_encoder import AS5048B_Encoder
from NeuroLocoMiddleware.StatProfiler import SSProfile

"""
Module Overview:
Expand Down Expand Up @@ -513,6 +514,7 @@ def stop(self, close_communication=True) -> None:
if close_communication:
self.close()

@SSProfile("actpack_update").decorate
def update(self) -> None:
"""
Queries the latest values from the actpack.
Expand Down
3 changes: 3 additions & 0 deletions opensourceleg/hardware/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

from ..tools.logger import Logger
from .joints import Joint
from NeuroLocoMiddleware.StatProfiler import SSProfile


"""
Module Overview:
Expand Down Expand Up @@ -154,6 +156,7 @@ def reset(self):
self._loadcell_zero = np.zeros(shape=(1, 6), dtype=np.double)
self._zeroed = False

@SSProfile("loadcell_update").decorate
def update(self, loadcell_zero=None) -> None:
"""
Queries the loadcell for the latest data.
Expand Down
2 changes: 1 addition & 1 deletion opensourceleg/osl.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(
file_path=file_name, log_format="[%(asctime)s] %(levelname)s: %(message)s"
)

self.clock = SoftRealtimeLoop(dt=1.0 / self._frequency, report=False, fade=0.1)
self.clock = SoftRealtimeLoop(dt=1.0 / self._frequency, report=False, fade=0.1, track_naive_time=True)

self._timestamp: float = time.time()

Expand Down
2 changes: 2 additions & 0 deletions opensourceleg/tools/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import csv
import logging
from logging.handlers import RotatingFileHandler
from NeuroLocoMiddleware.StatProfiler import SSProfile

"""
Module Overview:
Expand Down Expand Up @@ -150,6 +151,7 @@ def add_attributes(
self._containers.append(container)
self._attributes.append(attributes)

@SSProfile("log_update").decorate
def update(self) -> None:
"""
Logs the attributes of the class instance to the csv file
Expand Down

0 comments on commit 4a3a361

Please sign in to comment.