Skip to content

Commit

Permalink
Improved logging (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-bass authored Nov 3, 2024
1 parent 2d737e5 commit 2f40891
Show file tree
Hide file tree
Showing 38 changed files with 657 additions and 574 deletions.
1 change: 1 addition & 0 deletions pyrobosim/examples/demo_pddl.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def start_planner(world, args):
# Wait for the GUI to load
while not world.has_gui:
time.sleep(1.0)
time.sleep(0.5) # Extra time for log messages to not interfere with prompt

if args.example == "01_simple":
# Task specification for simple example.
Expand Down
6 changes: 4 additions & 2 deletions pyrobosim/pyrobosim/core/dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import copy
import numpy as np
import warnings

from ..utils.logging import get_global_logger
from ..utils.pose import Pose


Expand Down Expand Up @@ -86,7 +86,9 @@ def step(self, cmd_vel, dt, world=None, check_collisions=False):
# Check collisions
if check_collisions:
if world is None:
warnings.warn("Cannot check collisions without a world.")
warn_msg = "Cannot check collisions without a world."
logger = self.robot.logger if self.robot else get_global_logger()
logger.warning(warn_msg)
return

if world.collides_with_robots(
Expand Down
14 changes: 9 additions & 5 deletions pyrobosim/pyrobosim/core/gazebo.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,16 @@ def export(self, classic=False, out_folder=None):
model_path_env = "GAZEBO_MODEL_PATH"
command = "gazebo"

print(f"\nWorld file saved to {world_file_name}\n")
print(f"Ensure to update your Gazebo model path:")
include_path_str = ":".join(self.include_model_paths)
print(f" export {model_path_env}=${model_path_env}:{include_path_str}\n")
print(f"To start the world, enter")
print(f" {command} {world_file_name}\n")
help_string = f"\nWorld file saved to {world_file_name}\n"
help_string += "Ensure to update your Gazebo model path:\n"
help_string += (
f" export {model_path_env}=${model_path_env}:{include_path_str}\n"
)
help_string += "To start the world, enter:\n"
help_string += f" {command} {world_file_name}\n"
self.world.logger.info(help_string)

return self.out_folder

def create_walls_for_export(self, walls_name="walls"):
Expand Down
Loading

0 comments on commit 2f40891

Please sign in to comment.