forked from USC-ACTLab/crazyswarm
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #440 from IMRCLab/issue433
crazyflie_examples: add launch.py
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import os | ||
|
||
from ament_index_python.packages import get_package_share_directory | ||
|
||
|
||
from launch import LaunchDescription | ||
from launch.actions import DeclareLaunchArgument | ||
from launch.actions import IncludeLaunchDescription | ||
from launch.launch_description_sources import PythonLaunchDescriptionSource | ||
from launch.substitutions import LaunchConfiguration, PythonExpression | ||
from launch_ros.actions import Node | ||
|
||
|
||
def generate_launch_description(): | ||
script = LaunchConfiguration('script') | ||
backend = LaunchConfiguration('backend') | ||
|
||
script_launch_arg = DeclareLaunchArgument( | ||
'script' | ||
) | ||
|
||
backend_launch_arg = DeclareLaunchArgument( | ||
'backend', | ||
default_value='cpp' | ||
) | ||
|
||
crazyflie = IncludeLaunchDescription( | ||
PythonLaunchDescriptionSource([os.path.join( | ||
get_package_share_directory('crazyflie'), 'launch'), | ||
'/launch.py']), | ||
launch_arguments={ | ||
'backend': backend, | ||
}.items() | ||
) | ||
|
||
example_node = Node( | ||
package='crazyflie_examples', | ||
executable=script, | ||
name=script, | ||
parameters=[{ | ||
'use_sim_time': PythonExpression(["'", backend, "' == 'sim'"]), | ||
}] | ||
) | ||
|
||
return LaunchDescription([ | ||
script_launch_arg, | ||
backend_launch_arg, | ||
crazyflie, | ||
example_node | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters