Skip to content

Commit

Permalink
Add lidar launch
Browse files Browse the repository at this point in the history
Co-authored-by: 0nhc <thefoxfoxfox@outlook.com>
  • Loading branch information
Tiryoh and 0nhc committed Mar 4, 2023
1 parent d78a344 commit 7db67d6
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Open 2 terminals and ssh login to Mini Pupper on both.
```sh
# Terminal 1 (ssh)
. ~/ros2_ws/install/setup.bash # setup.zsh if you use zsh instead of bash
ros2 launch mini_pupper_bringup bringup.launch.py
ros2 launch mini_pupper_bringup bringup.launch.py lidar:=false

# Terminal 2 (ssh)
ros2 run teleop_twist_keyboard teleop_twist_keyboard
Expand Down
33 changes: 27 additions & 6 deletions mini_pupper_bringup/launch/bringup.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution, PythonExpression
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch_ros.substitutions import FindPackageShare
from launch_ros.actions import Node
Expand Down Expand Up @@ -57,10 +57,14 @@ def generate_launch_description():
servo_interface_launch_path = PathJoinSubstitution(
[FindPackageShare('mini_pupper_control'), 'launch', 'servo_interface.launch.py']
)
lidar_launch_path = PathJoinSubstitution(
[FindPackageShare('mini_pupper_bringup'), 'launch', 'lidar.launch.py']
)

robot_name = LaunchConfiguration("robot_name")
sim = LaunchConfiguration("sim")
joint_hardware_connected = LaunchConfiguration("joint_hardware_connected")
lidar_connected = LaunchConfiguration("lidar_connected")
rviz = LaunchConfiguration("rviz")

declare_robot_name = DeclareLaunchArgument(
Expand All @@ -87,6 +91,12 @@ def generate_launch_description():
description='Set to true if connected to a physical robot'
)

declare_lidar_connected = DeclareLaunchArgument(
name='lidar_connected',
default_value='true',
description='Set to true if connected to a lidar'
)

rviz2_node = Node(
package="rviz2",
namespace="",
Expand Down Expand Up @@ -114,10 +124,19 @@ def generate_launch_description():
}.items(),
)

servo_interface_launch = (
IncludeLaunchDescription(
PythonLaunchDescriptionSource(servo_interface_launch_path),
condition=IfCondition(joint_hardware_connected),
servo_interface_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(servo_interface_launch_path),
condition=IfCondition(joint_hardware_connected),
)

lidar_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(lidar_launch_path),
condition=IfCondition(
PythonExpression([
joint_hardware_connected,
" and ",
lidar_connected
])
),
)

Expand All @@ -126,7 +145,9 @@ def generate_launch_description():
declare_sim,
declare_rviz,
declare_hardware_connected,
declare_lidar_connected,
rviz2_node,
bringup_launch,
servo_interface_launch
servo_interface_launch,
lidar_launch,
])
41 changes: 41 additions & 0 deletions mini_pupper_bringup/launch/lidar.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python3

# SPDX-License-Identifier: Apache-2.0
#
# Copyright (c) 2022-2023 MangDang
#
# 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,
# 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_ros.actions import Node


def generate_launch_description():
return LaunchDescription([
Node(
package='ldlidar_stl_ros2',
executable='ldlidar_stl_ros2_node',
name='LD06',
output='screen',
parameters=[
{'product_name': 'LDLiDAR_LD06'},
{'topic_name': 'scan'},
{'frame_id': 'base_lidar'},
{'port_name': '/dev/ttyUSB0'},
{'port_baudrate': 230400},
{'laser_scan_dir': True},
{'enable_angle_crop_func': False},
{'angle_crop_min': 135.0},
{'angle_crop_max': 225.0}],
),
])

0 comments on commit 7db67d6

Please sign in to comment.