mirror of
https://github.com/SHC-ASTRA/rover-ros2.git
synced 2026-02-11 09:20:40 +00:00
created anchor package and launch file
This commit is contained in:
BIN
launch/__pycache__/rover_launch.cpython-312.pyc
Normal file
BIN
launch/__pycache__/rover_launch.cpython-312.pyc
Normal file
Binary file not shown.
100
launch/rover_launch.py
Normal file
100
launch/rover_launch.py
Normal 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)
|
||||||
|
])
|
||||||
0
src/anchor_pkg/anchor_pkg/__init__.py
Normal file
0
src/anchor_pkg/anchor_pkg/__init__.py
Normal file
20
src/anchor_pkg/package.xml
Normal file
20
src/anchor_pkg/package.xml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<package format="3">
|
||||||
|
<name>anchor_pkg</name>
|
||||||
|
<version>0.0.0</version>
|
||||||
|
<description>TODO: Package description</description>
|
||||||
|
<maintainer email="tristanmcginnis26@gmail.com">tristan</maintainer>
|
||||||
|
<license>TODO: License declaration</license>
|
||||||
|
|
||||||
|
<depend>rclpy</depend>
|
||||||
|
|
||||||
|
<test_depend>ament_copyright</test_depend>
|
||||||
|
<test_depend>ament_flake8</test_depend>
|
||||||
|
<test_depend>ament_pep257</test_depend>
|
||||||
|
<test_depend>python3-pytest</test_depend>
|
||||||
|
|
||||||
|
<export>
|
||||||
|
<build_type>ament_python</build_type>
|
||||||
|
</export>
|
||||||
|
</package>
|
||||||
0
src/anchor_pkg/resource/anchor_pkg
Normal file
0
src/anchor_pkg/resource/anchor_pkg
Normal file
4
src/anchor_pkg/setup.cfg
Normal file
4
src/anchor_pkg/setup.cfg
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[develop]
|
||||||
|
script_dir=$base/lib/anchor_pkg
|
||||||
|
[install]
|
||||||
|
install_scripts=$base/lib/anchor_pkg
|
||||||
24
src/anchor_pkg/setup.py
Normal file
24
src/anchor_pkg/setup.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
|
package_name = 'anchor_pkg'
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name=package_name,
|
||||||
|
version='0.0.0',
|
||||||
|
packages=find_packages(exclude=['test']),
|
||||||
|
data_files=[
|
||||||
|
('share/ament_index/resource_index/packages',
|
||||||
|
['resource/' + package_name]),
|
||||||
|
('share/' + package_name, ['package.xml']),
|
||||||
|
],
|
||||||
|
install_requires=['setuptools'],
|
||||||
|
zip_safe=True,
|
||||||
|
maintainer='tristan',
|
||||||
|
maintainer_email='tristanmcginnis26@gmail.com',
|
||||||
|
description='TODO: Package description',
|
||||||
|
license='TODO: License declaration',
|
||||||
|
entry_points={
|
||||||
|
'console_scripts': [
|
||||||
|
],
|
||||||
|
},
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user