-
Notifications
You must be signed in to change notification settings - Fork 0
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 #66 from rogy-AquaLab/order-launch
Nucleoに命令出す用のlaunchファイル
- Loading branch information
Showing
1 changed file
with
56 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,56 @@ | ||
from launch import LaunchDescription | ||
from launch.actions import DeclareLaunchArgument, ExecuteProcess | ||
from launch.conditions import IfCondition | ||
from launch.substitutions import LaunchConfiguration, PythonExpression | ||
|
||
|
||
def generate_launch_description() -> LaunchDescription: | ||
state_arg = DeclareLaunchArgument( | ||
"state", default_value="running", choices=["initializing", "suspend", "running"] | ||
) | ||
power_topic_arg = DeclareLaunchArgument("power_topic", default_value="{}") | ||
# launch_ros.actions.Nodeを使っていないためlog_level引数はない | ||
state = LaunchConfiguration("state") | ||
power_topic = LaunchConfiguration("power_topic") | ||
state_is_initializing = PythonExpression(["'", state, "' == 'initializing'"]) | ||
state_is_suspend = PythonExpression(["'", state, "' == 'suspend'"]) | ||
state_is_running = PythonExpression(["'", state, "' == 'running'"]) | ||
order_power = ExecuteProcess( | ||
cmd=[ | ||
"ros2", | ||
"topic", | ||
"pub", | ||
"--once", | ||
"/packet/order/power", | ||
"packet_interfaces/msg/Power", | ||
power_topic, | ||
], | ||
condition=IfCondition(state_is_running), | ||
) | ||
order_initializing = ExecuteProcess( | ||
cmd=[ | ||
"ros2", | ||
"topic", | ||
"pub", | ||
"--once", | ||
"/packet/order/initialize", | ||
"std_msgs/msg/Empty", | ||
"{}", | ||
], | ||
condition=IfCondition(state_is_initializing), | ||
) | ||
order_suspend = ExecuteProcess( | ||
cmd=[ | ||
"ros2", | ||
"topic", | ||
"pub", | ||
"--once", | ||
"/packet/order/suspend", | ||
"std_msgs/msg/Empty", | ||
"{}", | ||
], | ||
condition=IfCondition(state_is_suspend), | ||
) | ||
return LaunchDescription( | ||
[state_arg, power_topic_arg, order_power, order_initializing, order_suspend] | ||
) |