Skip to content

Commit

Permalink
Nacho/fix flake8 remaining tests (ros-navigation#3942)
Browse files Browse the repository at this point in the history
* Use ament_black as linter

* Fix standard flake8 errors for `tools

- F401 'ament_index_python.packages.get_package_share_directory' imported but unused

* Fix flake8 tests for nav2_common

- nav2_common/nav2_common/launch/__init__.py:15:1: F401 '.has_node_params.HasNodeParams' imported but unused
- nav2_common/nav2_common/launch/__init__.py:16:1: F401 '.rewritten_yaml.RewrittenYaml' imported but unused
- nav2_common/nav2_common/launch/__init__.py:17:1: F401 '.replace_string.ReplaceString' imported but unused
- nav2_common/nav2_common/launch/__init__.py:18:1: F401 '.parse_multirobot_pose.ParseMultiRobotPose' imported but unused

* Fix flake8 nav2_common linterr

- nav2_common/nav2_common/launch/replace_string.py:97:100: E501 line too long (108 > 99 characters)

* Fix flake8 nav2_common linter

- nav2_common/nav2_common/launch/rewritten_yaml.py:142:16: E713 test for membership should be 'not in'

* Fix flake8 nav_common linter

-  nav2_common/nav2_common/launch/has_node_params.py:21:1: F401 'sys' imported but unused

* Fix nav2_system_tests flake8 linter

This came after using black as formatter. So respecting the previous
code

* Fix flake8-builtins linter

* Fix flake8-comprehensions linter

* Fix flake8-import-order linter for nav2_sumple_commander

* Fix flake8-import-order linter for nav2_system_tests

* Fix flake8-import-order linter for nav2_common

* Fix flake8-import-order linter for tools

* Fix flake8-docstring linter

* Fix flake8-quotes linter for nav2_common

* Fix flake8-quotes linter for nav2_system_tests

* Fix flake8-quotes linter for nav2_collision_monitor

* Fix flake8-quotes linter for nav2_map_server

* Fix flake8-quotes linter for nav2_bringup

* Fix flake8-quotes linter for tools

* Fix flake8-quotes linter for nav2_simple_commander

* Fix flake8-quotes linter for nav2_lifecycle

* Fix flake8-quotes linter for nav2_costmap2d

* Fix flake8-quotes linter for nav2_smac_planner

* Fix linter... again
  • Loading branch information
nachovizzo authored Nov 8, 2023
1 parent 98af3b9 commit be370db
Show file tree
Hide file tree
Showing 89 changed files with 3,410 additions and 2,322 deletions.
174 changes: 99 additions & 75 deletions nav2_bringup/launch/bringup_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import (DeclareLaunchArgument, GroupAction,
IncludeLaunchDescription, SetEnvironmentVariable)
from launch.actions import (
DeclareLaunchArgument,
GroupAction,
IncludeLaunchDescription,
SetEnvironmentVariable,
)
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PythonExpression
Expand Down Expand Up @@ -51,8 +55,7 @@ def generate_launch_description():
# https://github.com/ros/robot_state_publisher/pull/30
# TODO(orduno) Substitute with `PushNodeRemapping`
# https://github.com/ros2/launch_ros/issues/56
remappings = [('/tf', 'tf'),
('/tf_static', 'tf_static')]
remappings = [('/tf', 'tf'), ('/tf_static', 'tf_static')]

# Only it applys when `use_namespace` is True.
# '<robot_namespace>' keyword shall be replaced by 'namespace' launch argument
Expand All @@ -61,113 +64,134 @@ def generate_launch_description():
params_file = ReplaceString(
source_file=params_file,
replacements={'<robot_namespace>': ('/', namespace)},
condition=IfCondition(use_namespace))
condition=IfCondition(use_namespace),
)

configured_params = ParameterFile(
RewrittenYaml(
source_file=params_file,
root_key=namespace,
param_rewrites={},
convert_types=True),
allow_substs=True)
convert_types=True,
),
allow_substs=True,
)

stdout_linebuf_envvar = SetEnvironmentVariable(
'RCUTILS_LOGGING_BUFFERED_STREAM', '1')
'RCUTILS_LOGGING_BUFFERED_STREAM', '1'
)

declare_namespace_cmd = DeclareLaunchArgument(
'namespace',
default_value='',
description='Top-level namespace')
'namespace', default_value='', description='Top-level namespace'
)

declare_use_namespace_cmd = DeclareLaunchArgument(
'use_namespace',
default_value='false',
description='Whether to apply a namespace to the navigation stack')
description='Whether to apply a namespace to the navigation stack',
)

declare_slam_cmd = DeclareLaunchArgument(
'slam',
default_value='False',
description='Whether run a SLAM')
'slam', default_value='False', description='Whether run a SLAM'
)

declare_map_yaml_cmd = DeclareLaunchArgument(
'map',
default_value='',
description='Full path to map yaml file to load')
'map', default_value='', description='Full path to map yaml file to load'
)

declare_use_sim_time_cmd = DeclareLaunchArgument(
'use_sim_time',
default_value='false',
description='Use simulation (Gazebo) clock if true')
description='Use simulation (Gazebo) clock if true',
)

declare_params_file_cmd = DeclareLaunchArgument(
'params_file',
default_value=os.path.join(bringup_dir, 'params', 'nav2_params.yaml'),
description='Full path to the ROS2 parameters file to use for all launched nodes')
description='Full path to the ROS2 parameters file to use for all launched nodes',
)

declare_autostart_cmd = DeclareLaunchArgument(
'autostart', default_value='true',
description='Automatically startup the nav2 stack')
'autostart',
default_value='true',
description='Automatically startup the nav2 stack',
)

declare_use_composition_cmd = DeclareLaunchArgument(
'use_composition', default_value='True',
description='Whether to use composed bringup')
'use_composition',
default_value='True',
description='Whether to use composed bringup',
)

declare_use_respawn_cmd = DeclareLaunchArgument(
'use_respawn', default_value='False',
description='Whether to respawn if a node crashes. Applied when composition is disabled.')
'use_respawn',
default_value='False',
description='Whether to respawn if a node crashes. Applied when composition is disabled.',
)

declare_log_level_cmd = DeclareLaunchArgument(
'log_level', default_value='info',
description='log level')
'log_level', default_value='info', description='log level'
)

# Specify the actions
bringup_cmd_group = GroupAction([
PushROSNamespace(
condition=IfCondition(use_namespace),
namespace=namespace),

Node(
condition=IfCondition(use_composition),
name='nav2_container',
package='rclcpp_components',
executable='component_container_isolated',
parameters=[configured_params, {'autostart': autostart}],
arguments=['--ros-args', '--log-level', log_level],
remappings=remappings,
output='screen'),

IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(launch_dir, 'slam_launch.py')),
condition=IfCondition(slam),
launch_arguments={'namespace': namespace,
'use_sim_time': use_sim_time,
'autostart': autostart,
'use_respawn': use_respawn,
'params_file': params_file}.items()),

IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(launch_dir,
'localization_launch.py')),
condition=IfCondition(PythonExpression(['not ', slam])),
launch_arguments={'namespace': namespace,
'map': map_yaml_file,
'use_sim_time': use_sim_time,
'autostart': autostart,
'params_file': params_file,
'use_composition': use_composition,
'use_respawn': use_respawn,
'container_name': 'nav2_container'}.items()),

IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(launch_dir, 'navigation_launch.py')),
launch_arguments={'namespace': namespace,
'use_sim_time': use_sim_time,
'autostart': autostart,
'params_file': params_file,
'use_composition': use_composition,
'use_respawn': use_respawn,
'container_name': 'nav2_container'}.items()),
])
bringup_cmd_group = GroupAction(
[
PushROSNamespace(condition=IfCondition(use_namespace), namespace=namespace),
Node(
condition=IfCondition(use_composition),
name='nav2_container',
package='rclcpp_components',
executable='component_container_isolated',
parameters=[configured_params, {'autostart': autostart}],
arguments=['--ros-args', '--log-level', log_level],
remappings=remappings,
output='screen',
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(launch_dir, 'slam_launch.py')
),
condition=IfCondition(slam),
launch_arguments={
'namespace': namespace,
'use_sim_time': use_sim_time,
'autostart': autostart,
'use_respawn': use_respawn,
'params_file': params_file,
}.items(),
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(launch_dir, 'localization_launch.py')
),
condition=IfCondition(PythonExpression(['not ', slam])),
launch_arguments={
'namespace': namespace,
'map': map_yaml_file,
'use_sim_time': use_sim_time,
'autostart': autostart,
'params_file': params_file,
'use_composition': use_composition,
'use_respawn': use_respawn,
'container_name': 'nav2_container',
}.items(),
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(launch_dir, 'navigation_launch.py')
),
launch_arguments={
'namespace': namespace,
'use_sim_time': use_sim_time,
'autostart': autostart,
'params_file': params_file,
'use_composition': use_composition,
'use_respawn': use_respawn,
'container_name': 'nav2_container',
}.items(),
),
]
)

# Create the launch description and populate
ld = LaunchDescription()
Expand Down
Loading

0 comments on commit be370db

Please sign in to comment.