diff --git a/.github/workflows/ci_jazzy.yaml b/.github/workflows/ci_jazzy.yaml index ed932d2..5e324e5 100644 --- a/.github/workflows/ci_jazzy.yaml +++ b/.github/workflows/ci_jazzy.yaml @@ -11,9 +11,9 @@ jobs: ci: runs-on: ${{ matrix.os }} if: | - ((github.event.action == 'labeled') && (github.event.label.name == 'TESTING') && (github.base_ref == 'main' )) || - ((github.event.action == 'synchronize') && (github.base_ref == 'main') && contains(github.event.pull_request.labels.*.name, 'TESTING')) || - (github.ref_name == 'main') + ((github.event.action == 'labeled') && (github.event.label.name == 'TESTING') && (github.base_ref == 'jazzy' )) || + ((github.event.action == 'synchronize') && (github.base_ref == 'jazzy') && contains(github.event.pull_request.labels.*.name, 'TESTING')) || + (github.ref_name == 'jazzy') container: image: osrf/ros:${{ matrix.ros_distribution }}-desktop timeout-minutes: 20 @@ -32,8 +32,8 @@ jobs: with: target-ros2-distro: ${{ matrix.ros_distribution }} import-token: ${{ secrets.GITHUB_TOKEN }} + vcs-repo-file-url: build_depends.repos package-name: | sanehal sanehal_bringup - sanehal_description - vcs-repo-file-url: build_depends.repos \ No newline at end of file + sanehal_vehicle_description \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index b3941fd..c061223 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,5 +9,8 @@ "/opt/ros/jazzy/lib/python3.10/site-packages", "/opt/ros/jazzy/local/lib/python3.10/dist-packages" ], - "ros.distro": "jazzy" + "ros.distro": "jazzy", + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" + } } \ No newline at end of file diff --git a/README.md b/README.md index ab7c032..b53752c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Project SANEHAL +[![ci_jazzy](https://github.com/MrBearing/sanehal/actions/workflows/ci_jazzy.yaml/badge.svg)](https://github.com/MrBearing/sanehal/actions/workflows/ci_jazzy.yaml) + ## 事前準備 - ROSのインストール diff --git a/build_depends.repos b/build_depends.repos index 52f9003..4859de6 100644 --- a/build_depends.repos +++ b/build_depends.repos @@ -14,7 +14,7 @@ repositories: ldlidar_stl_ros2: type: git url: https://github.com/MrBearing/ldlidar_stl_ros2.git - version: master + version: jazzy ldlidar_stl_utils: type: git url: https://github.com/MrBearing/ldlidar_stl_utils.git diff --git a/sanehal_bringup/launch/diffbot.launch.py b/sanehal_bringup/launch/diffbot.launch.py index c2661b2..a1cdc7e 100644 --- a/sanehal_bringup/launch/diffbot.launch.py +++ b/sanehal_bringup/launch/diffbot.launch.py @@ -1,24 +1,27 @@ # Copyright 2020 ros2_control Development Team # -# Licensed under the Apache License, Version 2.0 (the "License"); +# Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, +# distributed under the License is distributed on an 'AS IS' BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from launch import LaunchDescription -from launch.actions import RegisterEventHandler -from launch.event_handlers import OnProcessExit -from launch.substitutions import Command, FindExecutable, PathJoinSubstitution,LaunchConfiguration -from launch.actions import DeclareLaunchArgument +from launch.actions import DeclareLaunchArgument, Node, RegisterEventHandler -from launch_ros.actions import Node +from launch.event_handlers import OnProcessExit +from launch.substitutions import ( + Command, + FindExecutable, + LaunchConfiguration, + PathJoinSubstitution, +) from launch_ros.substitutions import FindPackageShare @@ -26,72 +29,83 @@ def generate_launch_description(): # Get URDF via xacro robot_description_content = Command( [ - PathJoinSubstitution([FindExecutable(name="xacro")]), - " ", + PathJoinSubstitution([FindExecutable(name='xacro')]), + ' ', PathJoinSubstitution( - [FindPackageShare("sanehal_vehicle_description"), "urdf", "diffbot.urdf.xacro"] + [ + FindPackageShare('sanehal_vehicle_description'), + 'urdf', + 'diffbot.urdf.xacro', + ] ), ] ) - robot_description = {"robot_description": robot_description_content} + robot_description = {'robot_description': robot_description_content} robot_controllers = PathJoinSubstitution( [ - FindPackageShare("sanehal_vehicle_description"), - "controllers", - "diffbot_controllers.yaml", + FindPackageShare('sanehal_vehicle_description'), + 'controllers', + 'diffbot_controllers.yaml', ] ) rviz_config_file = PathJoinSubstitution( - [FindPackageShare("sanehal_vehicle_description"), "config", "diffbot.rviz"] + [FindPackageShare('sanehal_vehicle_description'), 'config', 'diffbot.rviz'] ) # for debug - logger = LaunchConfiguration("log_level") + logger = LaunchConfiguration('log_level') launch_arg = DeclareLaunchArgument( - "log_level", - default_value=["debug"], - description="Logging level", + 'log_level', + default_value=['debug'], + description='Logging level', ) control_node = Node( - package="controller_manager", - executable="ros2_control_node", + package='controller_manager', + executable='ros2_control_node', parameters=[robot_description, robot_controllers], - output="both", - arguments=['--ros-args', - # '--log-level', logger - ] + output='both', + arguments=[ + '--ros-args', + '--log-level', logger + ], ) robot_state_pub_node = Node( - package="robot_state_publisher", - executable="robot_state_publisher", - output="both", + package='robot_state_publisher', + executable='robot_state_publisher', + output='both', parameters=[robot_description], remappings=[ - ("/diff_drive_controller/cmd_vel_unstamped", "/cmd_vel"), + ('/diff_drive_controller/cmd_vel_unstamped', '/cmd_vel'), ], ) rviz_node = Node( - package="rviz2", - executable="rviz2", - name="rviz2", - output="log", - arguments=["-d", rviz_config_file, + package='rviz2', + executable='rviz2', + name='rviz2', + output='log', + arguments=[ + '-d', + rviz_config_file, # '--ros-args', '--log-level', logger ], ) joint_state_broadcaster_spawner = Node( - package="controller_manager", - executable="spawner", - arguments=["joint_state_broadcaster", "--controller-manager", "/controller_manager"], + package='controller_manager', + executable='spawner', + arguments=[ + 'joint_state_broadcaster', + '--controller-manager', + '/controller_manager', + ], ) robot_controller_spawner = Node( - package="controller_manager", - executable="spawner", - arguments=["diffbot_base_controller", "-c", "/controller_manager"], + package='controller_manager', + executable='spawner', + arguments=['diffbot_base_controller', '-c', '/controller_manager'], ) # Delay rviz start after `joint_state_broadcaster` @@ -103,10 +117,12 @@ def generate_launch_description(): ) # Delay start of robot_controller after `joint_state_broadcaster` - delay_robot_controller_spawner_after_joint_state_broadcaster_spawner = RegisterEventHandler( - event_handler=OnProcessExit( - target_action=joint_state_broadcaster_spawner, - on_exit=[robot_controller_spawner], + delay_robot_controller_spawner_after_joint_state_broadcaster_spawner = ( + RegisterEventHandler( + event_handler=OnProcessExit( + target_action=joint_state_broadcaster_spawner, + on_exit=[robot_controller_spawner], + ) ) ) diff --git a/sanehal_bringup/launch/diffbot_on_pi.launch.py b/sanehal_bringup/launch/diffbot_on_pi.launch.py index 253cae8..fe704a9 100644 --- a/sanehal_bringup/launch/diffbot_on_pi.launch.py +++ b/sanehal_bringup/launch/diffbot_on_pi.launch.py @@ -1,13 +1,13 @@ # Copyright 2020 ros2_control Development Team # -# Licensed under the Apache License, Version 2.0 (the "License"); +# Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, +# distributed under the License is distributed on an 'AS IS' BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. @@ -15,9 +15,11 @@ from launch import LaunchDescription from launch.actions import RegisterEventHandler from launch.event_handlers import OnProcessExit -from launch.substitutions import Command, FindExecutable, PathJoinSubstitution,LaunchConfiguration -from launch.actions import DeclareLaunchArgument - +from launch.substitutions import ( + Command, + FindExecutable, + PathJoinSubstitution, +) from launch_ros.actions import Node from launch_ros.substitutions import FindPackageShare @@ -25,58 +27,50 @@ def generate_launch_description(): robot_description_content = Command( [ - PathJoinSubstitution([FindExecutable(name="xacro")]), - " ", + PathJoinSubstitution([FindExecutable(name='xacro')]), + ' ', PathJoinSubstitution( - [FindPackageShare("sanehal_vehicle_description"), "urdf", "diffbot.urdf.xacro"] + [FindPackageShare('sanehal_vehicle_description'), 'urdf', 'diffbot.urdf.xacro'] ), ] ) - robot_description = {"robot_description": robot_description_content} + robot_description = {'robot_description': robot_description_content} robot_controllers = PathJoinSubstitution( [ - FindPackageShare("sanehal_vehicle_description"), - "controllers", - "diffbot_controllers.yaml", + FindPackageShare('sanehal_vehicle_description'), + 'controllers', + 'diffbot_controllers.yaml', ] ) - # for debug - # logger = LaunchConfiguration("log_level") - # launch_arg = DeclareLaunchArgument( - # "log_level", - # default_value=["debug"], - # description="Logging level", - # ) - control_node = Node( - package="controller_manager", - executable="ros2_control_node", + package='controller_manager', + executable='ros2_control_node', parameters=[robot_description, robot_controllers], - output="both", + output='both', # arguments=['--ros-args', '--log-level', logger] ) robot_state_pub_node = Node( - package="robot_state_publisher", - executable="robot_state_publisher", - output="both", + package='robot_state_publisher', + executable='robot_state_publisher', + output='both', parameters=[robot_description], remappings=[ - ("/diff_drive_controller/cmd_vel_unstamped", "/cmd_vel"), + ('/diff_drive_controller/cmd_vel_unstamped', '/cmd_vel'), ], ) joint_state_broadcaster_spawner = Node( - package="controller_manager", - executable="spawner", - arguments=["joint_state_broadcaster", "--controller-manager", "/controller_manager"], + package='controller_manager', + executable='spawner', + arguments=['joint_state_broadcaster', '--controller-manager', '/controller_manager'], ) robot_controller_spawner = Node( - package="controller_manager", - executable="spawner", - arguments=["diffbot_base_controller", "-c", "/controller_manager"], + package='controller_manager', + executable='spawner', + arguments=['diffbot_base_controller', '-c', '/controller_manager'], ) # Delay start of robot_controller after `joint_state_broadcaster` diff --git a/sanehal_bringup/launch/ld19.launch.py b/sanehal_bringup/launch/ld19.launch.py index c0e4a57..e3f9b4a 100644 --- a/sanehal_bringup/launch/ld19.launch.py +++ b/sanehal_bringup/launch/ld19.launch.py @@ -2,58 +2,59 @@ from launch import LaunchDescription from launch_ros.actions import Node -''' +""" Parameter Description: --- -- Set laser scan directon: - 1. Set counterclockwise, example: {'laser_scan_dir': True} - 2. Set clockwise, example: {'laser_scan_dir': False} +- Set laser scan directon: + 1. Set counterclockwise, example: {'laser_scan_dir': True} + 2. Set clockwise, example: {'laser_scan_dir': False} - Angle crop setting, Mask data within the set angle range: - 1. Enable angle crop fuction: - 1.1. enable angle crop, example: {'enable_angle_crop_func': True} - 1.2. disable angle crop, example: {'enable_angle_crop_func': False} - 2. Angle cropping interval setting: - - The distance and intensity data within the set angle range will be set to 0. - - angle >= 'angle_crop_min' and angle <= 'angle_crop_max' which is [angle_crop_min, angle_crop_max], unit is degress. - example: - {'angle_crop_min': 135.0} - {'angle_crop_max': 225.0} - which is [135.0, 225.0], angle unit is degress. -''' + 1. Enable angle crop fuction: + 1.1. enable angle crop, example: {'enable_angle_crop_func': True} + 1.2. disable angle crop, example: {'enable_angle_crop_func': False} + 2. Angle cropping interval setting: + - The distance and intensity data within the set angle range will be set to 0. + - angle >= 'angle_crop_min' and angle <= 'angle_crop_max' \ + which is [angle_crop_min, angle_crop_max], unit is degress. + example: + {'angle_crop_min': 135.0} + {'angle_crop_max': 225.0} + which is [135.0, 225.0], angle unit is degress. +""" -def generate_launch_description(): - # LDROBOT LiDAR publisher node - ldlidar_node = Node( - package='ldlidar_stl_ros2', - executable='ldlidar_stl_ros2_node', - name='LD19', - output='screen', - parameters=[ - {'product_name': 'LDLiDAR_LD19'}, - {'topic_name': 'scan'}, - {'frame_id': 'base_laser'}, - {'port_name': '/dev/ldlidar'}, - {'port_baudrate': 230400}, - {'laser_scan_dir': True}, - {'enable_angle_crop_func': False}, - {'angle_crop_min': 135.0}, - {'angle_crop_max': 225.0} - ] - ) - # base_link to base_laser tf node - base_link_to_laser_tf_node = Node( - package='tf2_ros', - executable='static_transform_publisher', - name='base_link_to_base_laser_ld19', - arguments=['0','0','0.18','0','0','0','base_link','base_laser'] - ) +def generate_launch_description(): + # LDROBOT LiDAR publisher node + ldlidar_node = Node( + package='ldlidar_stl_ros2', + executable='ldlidar_stl_ros2_node', + name='LD19', + output='screen', + parameters=[ + {'product_name': 'LDLiDAR_LD19'}, + {'topic_name': 'scan'}, + {'frame_id': 'base_laser'}, + {'port_name': '/dev/ldlidar'}, + {'port_baudrate': 230400}, + {'laser_scan_dir': True}, + {'enable_angle_crop_func': False}, + {'angle_crop_min': 135.0}, + {'angle_crop_max': 225.0} + ] + ) + # base_link to base_laser tf node + base_link_to_laser_tf_node = Node( + package='tf2_ros', + executable='static_transform_publisher', + name='base_link_to_base_laser_ld19', + arguments=['0', '0', '0.18', '0', '0', '0', 'base_link', 'base_laser'] + ) - # Define LaunchDescription variable - ld = LaunchDescription() + # Define LaunchDescription variable + ld = LaunchDescription() - ld.add_action(ldlidar_node) - ld.add_action(base_link_to_laser_tf_node) + ld.add_action(ldlidar_node) + ld.add_action(base_link_to_laser_tf_node) - return ld \ No newline at end of file + return ld diff --git a/sanehal_bringup/launch/sanehal.launch.py b/sanehal_bringup/launch/sanehal.launch.py index 5191ad9..ff3ef77 100644 --- a/sanehal_bringup/launch/sanehal.launch.py +++ b/sanehal_bringup/launch/sanehal.launch.py @@ -1,20 +1,20 @@ from launch import LaunchDescription from launch.actions import IncludeLaunchDescription - -from launch_ros.substitutions import FindPackageShare from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch_ros.substitutions import FindPackageShare + def generate_launch_description(): - sanehal_bringup = FindPackageShare("sanehal_bringup") + sanehal_bringup = FindPackageShare('sanehal_bringup') - vehicle = IncludeLaunchDescription( - PythonLaunchDescriptionSource([sanehal_bringup,'/launch', '/diffbot_on_pi.launch.py']) - ) - lidar = IncludeLaunchDescription( - PythonLaunchDescriptionSource([sanehal_bringup,'/launch', '/ld19.launch.py']) - ) + vehicle = IncludeLaunchDescription( + PythonLaunchDescriptionSource([sanehal_bringup, '/launch', '/diffbot_on_pi.launch.py']) + ) + lidar = IncludeLaunchDescription( + PythonLaunchDescriptionSource([sanehal_bringup, '/launch', '/ld19.launch.py']) + ) - ld = LaunchDescription() - ld.add_action(vehicle) - ld.add_action(lidar) - return ld \ No newline at end of file + ld = LaunchDescription() + ld.add_action(vehicle) + ld.add_action(lidar) + return ld diff --git a/sanehal_bringup/launch/view_robot.launch.py b/sanehal_bringup/launch/view_robot.launch.py index 8749fcd..b6db730 100644 --- a/sanehal_bringup/launch/view_robot.launch.py +++ b/sanehal_bringup/launch/view_robot.launch.py @@ -14,7 +14,12 @@ from launch import LaunchDescription from launch.actions import DeclareLaunchArgument -from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution +from launch.substitutions import ( + Command, + FindExecutable, + LaunchConfiguration, + PathJoinSubstitution, +) from launch_ros.actions import Node from launch_ros.substitutions import FindPackageShare @@ -25,69 +30,69 @@ def generate_launch_description(): declared_arguments = [] declared_arguments.append( DeclareLaunchArgument( - "description_package", - default_value="sanehal_vehicle_description", - description="Description package with robot URDF/xacro files. Usually the argument \ - is not set, it enables use of a custom description.", + 'description_package', + default_value='sanehal_vehicle_description', + description='Description package with robot URDF/xacro files. Usually the argument \ + is not set, it enables use of a custom description.', ) ) declared_arguments.append( DeclareLaunchArgument( - "description_file", - default_value="diffbot_display.urdf.xacro", - description="URDF/XACRO description file with the robot.", + 'description_file', + default_value='diffbot_display.urdf.xacro', + description='URDF/XACRO description file with the robot.', ) ) declared_arguments.append( DeclareLaunchArgument( - "prefix", + 'prefix', default_value='""', - description="Prefix of the joint names, useful for \ + description='Prefix of the joint names, useful for \ multi-robot setup. If changed than also joint names in the controllers configuration \ - have to be updated.", + have to be updated.', ) ) # Initialize Arguments - description_package = LaunchConfiguration("description_package") - description_file = LaunchConfiguration("description_file") - prefix = LaunchConfiguration("prefix") + description_package = LaunchConfiguration('description_package') + description_file = LaunchConfiguration('description_file') + prefix = LaunchConfiguration('prefix') # Get URDF via xacro robot_description_content = Command( [ - PathJoinSubstitution([FindExecutable(name="xacro")]), - " ", + PathJoinSubstitution([FindExecutable(name='xacro')]), + ' ', PathJoinSubstitution( - [FindPackageShare(description_package), "urdf", description_file] + [FindPackageShare(description_package), 'urdf', description_file] ), - " ", - "prefix:=", + ' ', + 'prefix:=', prefix, ] ) - robot_description = {"robot_description": robot_description_content} + robot_description = {'robot_description': robot_description_content} rviz_config_file = PathJoinSubstitution( - [FindPackageShare(description_package), "config", "diffbot_view.rviz"] + [FindPackageShare(description_package), 'config', 'diffbot_view.rviz'] ) joint_state_publisher_node = Node( - package="joint_state_publisher_gui", - executable="joint_state_publisher_gui", + package='joint_state_publisher_gui', + executable='joint_state_publisher_gui', ) robot_state_publisher_node = Node( - package="robot_state_publisher", - executable="robot_state_publisher", - output="both", + package='robot_state_publisher', + executable='robot_state_publisher', + output='both', parameters=[robot_description], ) rviz_node = Node( - package="rviz2", - executable="rviz2", - name="rviz2", - output="log", - arguments=["-d", rviz_config_file], + package='rviz2', + executable='rviz2', + name='rviz2', + output='log', + arguments=['-d', rviz_config_file], ) nodes = [