Skip to content

Commit

Permalink
Merge pull request #66 from rogy-AquaLab/order-launch
Browse files Browse the repository at this point in the history
Nucleoに命令出す用のlaunchファイル
  • Loading branch information
H1rono authored Aug 16, 2024
2 parents e63681e + f2a55ab commit f7bb884
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions ul/launch/order_nucleo.py
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]
)

0 comments on commit f7bb884

Please sign in to comment.