Skip to content

Wrapping LCM logger in Services#68

Merged
cmower merged 10 commits intomainfrom
dev-sdas-lcmlogger
Sep 12, 2025
Merged

Wrapping LCM logger in Services#68
cmower merged 10 commits intomainfrom
dev-sdas-lcmlogger

Conversation

@sarthakdas
Copy link
Copy Markdown
Contributor

Wrapped LCM logger into a node and a service that takes in a file path

@sarthakdas sarthakdas requested review from cmower and Copilot and removed request for Copilot September 11, 2025 13:45
Copy link
Copy Markdown
Contributor

@cmower cmower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address comment, and also include docstrings.

Comment thread ark/tools/data_logging/lcm_logger.py Outdated
Comment on lines +14 to +33
def start_logging(self, channel: str, msg: string_t) -> flag_t:
log.info("Starting logging to file: " + msg.data)
self.proc = subprocess.Popen(
['lcm-logger', msg.data],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
start_new_session=True,
)
msg = flag_t()
msg.flag = True
return msg

def stop_logging(self, channel: str, msg: flag_t) -> flag_t:
log.info("Stopping logging")
self.proc.kill()

msg = flag_t()
msg.flag = True
return msg

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user may make a mistake and call "logger/stop" first, or "lower/start" twice

the request also no need to be a string_t, i think can just be empty bytes

the response should contain

bool: success  # logger successfully started/stopped
str: message # when success=True, then something like "successfully started logger", if False then contain an informative message

maybe need a new type

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"the request also no need to be a string_t, i think can just be empty bytes" I think we should keep this to give users flexibility of the lcm-logger settings rather then only having default values.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, then this line needs to be updated

log.info("Starting logging to file: " + msg.data)

Copy link
Copy Markdown
Contributor

@cmower cmower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please address comments and also changes in Robotics-Ark/ark_types#15

Comment thread ark/tools/data_logging/lcm_logger.py Outdated
return out

try:
log.info("Stopping logging")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"stopped logging" also this line should appear after you called proc.kill()

log.info("Stopping logging")
self.proc.kill()
self.proc.wait(timeout=5)
self.proc = None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont we need to call del self.proc to make sure the memory is cleared?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sure couldn't see a difference with/without including for safety?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea perhaps

Comment thread ark/tools/data_logging/lcm_logger.py Outdated
class LoggerNode(BaseNode):

def __init__(self, name: str, config: Optional[dict[str, Any]] = None):
r"""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is r necessary?

Copy link
Copy Markdown
Contributor

@cmower cmower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sarthakdas please address all comments, some were missed from before.

Comment thread ark/tools/data_logging/lcm_logger.py Outdated
return out

try:
log.info("Starting logging")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Started logging"

Comment on lines +80 to +82
try:

self.proc.kill()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove additional space

Comment thread ark/tools/data_logging/lcm_logger.py Outdated

self.proc.kill()
self.proc.wait(timeout=5)
log.info("Stopping logging")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Stopped logging"

@cmower cmower merged commit 4a9d81f into main Sep 12, 2025
@cmower cmower deleted the dev-sdas-lcmlogger branch September 12, 2025 09:56
Douglas-Tilley pushed a commit that referenced this pull request Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants