created anchor package and launch file

This commit is contained in:
Tristan McGinnis
2025-02-19 20:09:25 -06:00
parent 3bdef8b591
commit a0e4649c13
7 changed files with 148 additions and 0 deletions

Binary file not shown.

100
launch/rover_launch.py Normal file
View File

@@ -0,0 +1,100 @@
#!/usr/bin/env python3
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, OpaqueFunction
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
def launch_setup(context, *args, **kwargs):
# Retrieve the resolved value of the launch argument 'mode'
mode = LaunchConfiguration('mode').perform(context)
nodes = []
if mode == 'anchor':
# Launch every node and pass "anchor" as the parameter
nodes.append(
Node(
package='arm_pkg',
executable='arm', # change as needed
name='arm',
output='screen',
parameters=[{'launch_arg': mode}]
)
)
nodes.append(
Node(
package='core_pkg',
executable='core', # change as needed
name='core',
output='screen',
parameters=[{'launch_arg': mode}]
)
)
# nodes.append(
# Node(
# package='bio_pkg',
# executable='bio', # change as needed
# name='bio',
# output='screen',
# parameters=[{'launch_arg': mode}]
# )
# )
nodes.append(
Node(
package='anchor_pkg',
executable='anchor', # change as needed
name='anchor',
output='screen',
parameters=[{'launch_arg': mode}]
)
)
elif mode in ['arm', 'core', 'bio']:
# Only launch the node corresponding to the provided mode.
if mode == 'arm':
nodes.append(
Node(
package='arm_pkg',
executable='arm',
name='arm',
output='screen',
parameters=[{'launch_arg': mode}]
)
)
elif mode == 'core':
nodes.append(
Node(
package='core_pkg',
executable='core',
name='core',
output='screen',
parameters=[{'launch_arg': mode}]
)
)
# elif mode == 'bio':
# nodes.append(
# Node(
# package='bio_pkg',
# executable='bio',
# name='bio',
# output='screen',
# parameters=[{'launch_arg': mode}]
# )
# )
else:
# If an invalid mode is provided, print an error.
# (You might want to raise an exception or handle it differently.)
print("Invalid mode provided. Choose one of: arm, core, bio, anchor.")
return nodes
def generate_launch_description():
declare_arg = DeclareLaunchArgument(
'mode',
default_value='anchor',
description='Launch mode: arm, core, bio, or anchor'
)
return LaunchDescription([
declare_arg,
OpaqueFunction(function=launch_setup)
])