Skip to content

Commit

Permalink
Validate automatic naming in process-wide machinery
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Hidalgo <[email protected]>
  • Loading branch information
mhidalgo-bdai committed Oct 20, 2023
1 parent ab8b08e commit ccf4533
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions bdai_ros2_wrappers/bdai_ros2_wrappers/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
import sys
import threading
import typing
import warnings

import rclpy
import rclpy.executors
import rclpy.logging
import rclpy.node
from rclpy.exceptions import InvalidNamespaceException, InvalidNodeNameException
from rclpy.validate_namespace import validate_namespace
from rclpy.validate_node_name import validate_node_name

import bdai_ros2_wrappers.context as context
import bdai_ros2_wrappers.scope as scope
Expand Down Expand Up @@ -79,9 +83,17 @@ def __init__(
program_name = cli.prog
name, _ = os.path.splitext(program_name)
if prebaked is True:
prebaked = name
try:
validate_node_name(name)
prebaked = name
except InvalidNodeNameException:
warnings.warn(f"'{name}' cannot be used as node name, using scope default")
if namespace is True:
namespace = name
try:
validate_namespace(name)
namespace = name
except InvalidNamespaceException:
warnings.warn(f"'{name}' cannot be used as namespace, using scope default")
if forward_logging is None:
forward_logging = bool(prebaked)
if autospin is None:
Expand Down

0 comments on commit ccf4533

Please sign in to comment.