ezWheelSAS/swd_ros2_controllers

How can I run Starter Kit with swd_ros2_controllers?

Closed this issue · 1 comments

Do you have launch file for Starter Kit with swd_ros2_controllers like swd_starter_kit_bringup?

For now, there is no official swd_starter_kit_bringup for ROS2.

You will find hereafter a example (without localization/mapping) of what it might look like.

bringup.launch.py

import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution, TextSubstitution
from launch.launch_context import LaunchContext
from launch.actions import RegisterEventHandler
from launch.event_handlers.on_process_exit import OnProcessExit
from launch.events.process.process_exited import ProcessExited

from nav2_common.launch import RewrittenYaml

import time


def generate_launch_description():

    bringup_dir = get_package_share_directory('bringup')
    swd_ros2_controllers_dir = get_package_share_directory(
        'swd_ros2_controllers')
    nav2_bringup_dir = get_package_share_directory('nav2_bringup')

    # Create the launch configuration variables
    baseline_m = LaunchConfiguration('baseline_m')

    # Nodes description
    def swd_diff_drive_controller_description():
        return IncludeLaunchDescription(
            PythonLaunchDescriptionSource([os.path.join(
                swd_ros2_controllers_dir, 'launch', 'swd_diff_drive_controller.launch.py')]),
            launch_arguments={'baseline_m': baseline_m}.items()
        )

     # Launch description
    return LaunchDescription([
        # Declare the launch options
        DeclareLaunchArgument(
            'baseline_m',
            default_value='0.485',  # Starter-kit
        ),
        # SWD diff drive controller
        swd_diff_drive_controller_description(),
        # LiDAR 1
        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(
                [os.path.join(bringup_dir, 'launch/lidar_idec_se2l.launch.py')]),
            launch_arguments={'prefix': 'laser'}.items()
        ),        
        # Xbox pad
        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(
                [os.path.join(bringup_dir, 'launch/xbox.launch.py')])
        )
    ])

lidar_idec_se2l.launch.py

from email.policy import default
from math import remainder
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration, TextSubstitution


def generate_launch_description():
    # Create the launch configuration variables
    prefix = LaunchConfiguration('prefix')

    # Launch description
    return LaunchDescription([
        # Declare the launch arguments
        DeclareLaunchArgument(
            'prefix',
            default_value='laser'
        ),
        # TF
        Node(
            package='tf2_ros',
            executable='static_transform_publisher',
            arguments=['0.04', '0', '0', '0', '0', '0', 'base_link', prefix] # Starter-kit type
        ),
        # LiDAR
        Node(
            package='urg_node',
            executable='urg_node_driver',
            namespace=prefix,
            parameters=[{'ip_address': '10.0.0.5', 'laser_frame_id': prefix}]
        )
    ])

xbox.launch.py

import os

from launch import LaunchDescription
from launch_ros.actions import Node


def generate_launch_description():

    # Launch description
    return LaunchDescription([
        # Nodes
        Node(
            package='joy_linux', 
            executable='joy_linux_node', 
            name='joy_linux_node',
            parameters=[{
                'dev': '/dev/input/js0',
                'autorepeat_rate': 20.0,
            }]
        ),
        Node(
            package='teleop_twist_joy', 
            executable='teleop_node',
            name='teleop_twist_joy_node', 
            parameters=[{
                'axis_linear.x': 1, # Left thumb stick vertical
                'axis_angular.yaw': 3, # Left thumb stick horizontal
                'scale_linear.x': 1.0,
                'scale_linear_turbo.x': 1.3,
                'scale_angular.yaw': 0.7,
                'scale_angular_turbo.yaw': 1.4,
                'enable_button': 5, # R1 BUTTON
                'enable_turbo_button': 6, # L2 BUTTON/AXIS 
            }]
            # 0   L3 LEFT RIGHT AXIS    
            # 1   L1 FRONT BACK AXIS
            # 2   TRIANGLE BUTTON
            # 3   SQUARE BUTTON  
            # 4   L1 BUTTON     
            # 5   R1 BUTTON    
            # 6   L2 BUTTON/AXIS 
            # 7   R2 BUTTON/AXIS     
            # 8   SHARE BUTTON 
            # 9   OPTIONS BUTTON
        )
    ])