Skip to content

Commit

Permalink
pre-commit update
Browse files Browse the repository at this point in the history
  • Loading branch information
ipa-vsp committed Apr 22, 2024
1 parent b78f871 commit b3dfdc9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
3 changes: 2 additions & 1 deletion canopen_core/src/device_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ bool DeviceContainer::load_component(
std::vector<std::string> remap_rules;

std::string can_ns = this->get_namespace();
if (!can_ns.empty()) {
if (!can_ns.empty())
{
remap_rules.push_back("--ros-args");
remap_rules.push_back("-r");
remap_rules.push_back("__ns:=" + can_ns);
Expand Down
8 changes: 4 additions & 4 deletions canopen_tests/ROS_NAMESPACES.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
The `cia402_namespaced_system.launch.py` example demonstrates how to run a
CIA402 system in a namespace to allow multiple CANOpen-based robots in the
same ROS domain. This example is neccessary because the controller names
The `cia402_namespaced_system.launch.py` example demonstrates how to run a
CIA402 system in a namespace to allow multiple CANOpen-based robots in the
same ROS domain. This example is necessary because the controller names
are picked up from `ros2_controllers.yaml` and we must define their names
in that file with a `__namespace__/controller_name:` key, then use
ReplaceString from `nav2_common` to dynamically add the namespace to the
controller definition.

For a proxy system, no example is included; it's sufficient to include, e.g.
the `proxy_setup.launch.py` launch description in another launch file and
push a namespace onto it with PushROSNamespace in the ordinary way.
push a namespace onto it with PushROSNamespace in the ordinary way.
38 changes: 23 additions & 15 deletions canopen_tests/launch/cia402_namespaced_system.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from launch.actions import GroupAction
from launch_ros.actions import PushROSNamespace


def launch_setup(context, *args, **kwargs):

name = LaunchConfiguration("name")
Expand Down Expand Up @@ -101,7 +102,6 @@ def launch_setup(context, *args, **kwargs):
)
robot_description = {"robot_description": robot_description_content}


# ros2 control configuration
ros2_control_config_package = LaunchConfiguration("ros2_control_config_package")
ros2_control_config_directory = LaunchConfiguration("ros2_control_config_directory")
Expand All @@ -118,8 +118,7 @@ def launch_setup(context, *args, **kwargs):
# Our controllers get their names from the control config, so we have to
# include their namespace here to get them to start up within it.
ros2_control_config = ReplaceString(
source_file=ros2_control_config,
replacements={"__namespace__/":(bot_ns, "/")}
source_file=ros2_control_config, replacements={"__namespace__/": (bot_ns, "/")}
)

# nodes to start are listed below
Expand All @@ -140,13 +139,17 @@ def launch_setup(context, *args, **kwargs):
cia402_device_controller_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["cia402_device_1_controller",]
arguments=[
"cia402_device_1_controller",
],
)

forward_position_controller = Node(
package="controller_manager",
executable="spawner",
arguments=["forward_position_controller",]
arguments=[
"forward_position_controller",
],
)

robot_state_publisher_node = Node(
Expand All @@ -173,22 +176,27 @@ def launch_setup(context, *args, **kwargs):
}.items(),
)

namespaced_nodes = [GroupAction(actions=[PushROSNamespace(bot_ns),
control_node,
robot_state_publisher_node,
joint_state_broadcaster_spawner,
slave_node_1,
cia402_device_controller_spawner,
forward_position_controller])]
namespaced_nodes = [
GroupAction(
actions=[
PushROSNamespace(bot_ns),
control_node,
robot_state_publisher_node,
joint_state_broadcaster_spawner,
slave_node_1,
cia402_device_controller_spawner,
forward_position_controller,
]
)
]
return namespaced_nodes


def generate_launch_description():

declared_arguments = []
declared_arguments.append(
DeclareLaunchArgument(
"bot_ns", description="Namespace for these nodes", default_value=""
)
DeclareLaunchArgument("bot_ns", description="Namespace for these nodes", default_value="")
)
declared_arguments.append(
DeclareLaunchArgument(
Expand Down

0 comments on commit b3dfdc9

Please sign in to comment.