Skip to content

Commit

Permalink
Update lidarbot_bringup_launch.py to use new ros2_control controller …
Browse files Browse the repository at this point in the history
…syntax
  • Loading branch information
TheNoobInventor committed Aug 22, 2024
1 parent a195faf commit e30e3b3
Showing 1 changed file with 49 additions and 26 deletions.
75 changes: 49 additions & 26 deletions lidarbot_bringup/launch/lidarbot_bringup_launch.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# This launch file brings up the physical lidarbot, the raspberry pi camera v1.3,
# RPLIDAR A1 and also integrates ros2_control, twist_mux, robot_localization and joystick
# control

# File adapted from https://automaticaddison.com

import os

from launch import LaunchDescription
from launch.actions import (
DeclareLaunchArgument,
ExecuteProcess,
IncludeLaunchDescription,
TimerAction,
RegisterEventHandler,
Expand Down Expand Up @@ -78,53 +85,71 @@ def generate_launch_description():
parameters=[{"robot_description": robot_description}, controller_params_file],
)

# Start joint_state_broadcaster
load_joint_state_broadcaster = ExecuteProcess(
cmd=[
"ros2",
"control",
"load_controller",
"--set-state",
"active",
"joint_broadcaster",
],
output="screen",
)

# Start diff_drive_controller
load_diff_drive_controller = ExecuteProcess(
cmd=[
"ros2",
"control",
"load_controller",
"--set-state",
"active",
"diff_controller",
],
output="screen",
)

# Start imu_sensor_broadcaster
load_imu_sensor_broadcaster = ExecuteProcess(
cmd=[
"ros2",
"control",
"load_controller",
"--set-state",
"active",
"imu_broadcaster",
],
output="screen",
)

# Delayed controller manager action
start_delayed_controller_manager = TimerAction(
period=2.0, actions=[start_controller_manager_cmd]
)

# Spawn diff_controller
start_diff_controller_cmd = Node(
package="controller_manager",
executable="spawner",
arguments=["diff_controller", "--controller-manager", "/controller_manager"],
)

# Delayed diff_drive_spawner action
start_delayed_diff_drive_spawner = RegisterEventHandler(
event_handler=OnProcessStart(
target_action=start_controller_manager_cmd,
on_start=[start_diff_controller_cmd],
on_start=[load_diff_drive_controller],
)
)

# Spawn joint_state_broadcaser
start_joint_broadcaster_cmd = Node(
package="controller_manager",
executable="spawner",
arguments=["joint_broadcaster", "--controller-manager", "/controller_manager"],
)

# Delayed joint_broadcaster_spawner action
start_delayed_joint_broadcaster_spawner = RegisterEventHandler(
event_handler=OnProcessStart(
target_action=start_controller_manager_cmd,
on_start=[start_joint_broadcaster_cmd],
on_start=[load_joint_state_broadcaster],
)
)

# Spawn imu_sensor_broadcaster
start_imu_broadcaster_cmd = Node(
package="controller_manager",
executable="spawner",
arguments=["imu_broadcaster", "--controller-manager", "/controller_manager"],
)

# Delayed imu_broadcaster_spawner action
start_delayed_imu_broadcaster_spawner = RegisterEventHandler(
event_handler=OnProcessStart(
target_action=start_controller_manager_cmd,
on_start=[start_imu_broadcaster_cmd],
on_start=[load_imu_sensor_broadcaster],
)
)

Expand Down Expand Up @@ -186,5 +211,3 @@ def generate_launch_description():
ld.add_action(start_twist_mux_cmd)

return ld

# TODO: Launch file summary

0 comments on commit e30e3b3

Please sign in to comment.