-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Launch引数指定 #55
Merged
Merged
Launch引数指定 #55
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8a52de2
Add parameter `param_file` in power_map_launch.py
H1rono 090dd03
Add log info
H1rono 1c248b8
Update README in power_map
H1rono ee567d7
Add camera_image index in imshow_launch.py
H1rono e643b4b
Update README in imshow
H1rono 965d3fb
Add index argument in camera_reader_launch.py
H1rono 93a33ea
Update README in camera_reader
H1rono dc0031e
Add arguments in led_launch.py
H1rono edcaed0
Update README in pi_led
H1rono 9396f3f
Rename node by index
H1rono 4cc46c2
Add launch files in ul
H1rono 67c624b
`ruff format`
H1rono cddf7d1
Update README
H1rono 83a9615
Fix
H1rono 1812dd8
Use `FindPackageShare`
H1rono 5b55b02
Add launch argument in `ul/simple_joy_app_pc.py`
H1rono 576ac3a
Add `log_level`
H1rono File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1,15 +1,38 @@ | ||
from typing import Any | ||
|
||
from launch import LaunchDescription | ||
from launch.actions import DeclareLaunchArgument | ||
from launch.conditions import IfCondition, UnlessCondition | ||
from launch.substitutions import LaunchConfiguration, PythonExpression | ||
from launch_ros.actions import Node | ||
|
||
|
||
def generate_launch_description(): | ||
return LaunchDescription( | ||
[ | ||
Node( | ||
package="imshow", | ||
executable="imshow", | ||
namespace="app", | ||
remappings=[("/app/camera_image", "/packet/camera_image")], | ||
), | ||
], | ||
def imshow_node(**kwargs: Any) -> Node: | ||
kwargs["package"] = "imshow" | ||
kwargs["executable"] = "imshow" | ||
kwargs["namespace"] = "app" | ||
return Node(**kwargs) | ||
|
||
|
||
def generate_launch_description() -> LaunchDescription: | ||
index_arg = DeclareLaunchArgument("index", default_value="-1") | ||
log_level_arg = DeclareLaunchArgument( | ||
"log_level", | ||
default_value="info", | ||
choices=["debug", "info", "warn", "error", "fatal"], | ||
) | ||
index = LaunchConfiguration("index") | ||
log_level = LaunchConfiguration("log_level") | ||
index_specified = PythonExpression([index, ">= 0"]) | ||
indexed_imshow = imshow_node( | ||
name=["imshow_", index], | ||
remappings=[("/app/camera_image", ["/packet/camera_image_", index])], | ||
ros_arguments=["--log-level", log_level], | ||
condition=IfCondition(index_specified), | ||
) | ||
unindexed_imshow = imshow_node( | ||
remappings=[("/app/camera_image", "/packet/camera_image")], | ||
ros_arguments=["--log-level", log_level], | ||
condition=UnlessCondition(index_specified), | ||
) | ||
return LaunchDescription([index_arg, log_level_arg, indexed_imshow, unindexed_imshow]) |
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
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
from launch import LaunchDescription | ||
from launch.actions import DeclareLaunchArgument | ||
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution | ||
from launch_ros.actions import Node | ||
from launch_ros.substitutions import FindPackageShare | ||
|
||
|
||
def generate_launch_description(): | ||
param_file = PathJoinSubstitution( | ||
[FindPackageShare("power_map"), "config", "default_param.yml"] | ||
) | ||
param_file_arg = DeclareLaunchArgument("param_file", default_value=param_file) | ||
log_level_arg = DeclareLaunchArgument( | ||
"log_level", | ||
default_value="info", | ||
choices=["debug", "info", "warn", "error", "fatal"], | ||
) | ||
log_level = LaunchConfiguration("log_level") | ||
power_map = Node( | ||
package="power_map", | ||
executable="power-map", | ||
namespace="app", | ||
parameters=[LaunchConfiguration("param_file")], | ||
remappings=[("/app/power", "/device/order/power")], | ||
ros_arguments=["--log-level", log_level], | ||
) | ||
return LaunchDescription([param_file_arg, log_level_arg, power_map]) |
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
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 |
---|---|---|
@@ -1,15 +1,21 @@ | ||
from launch import LaunchDescription | ||
from launch.actions import DeclareLaunchArgument | ||
from launch.substitutions import LaunchConfiguration | ||
from launch_ros.actions import Node | ||
|
||
|
||
def generate_launch_description(): | ||
return LaunchDescription( | ||
[ | ||
Node( | ||
package="simple_joy_app", | ||
executable="app", | ||
namespace="app", | ||
remappings=[("/app/joystick", "/packet/joystick")], | ||
), | ||
], | ||
log_level_arg = DeclareLaunchArgument( | ||
"log_level", | ||
default_value="info", | ||
choices=["debug", "info", "warn", "error", "fatal"], | ||
) | ||
log_level = LaunchConfiguration("log_level") | ||
app = Node( | ||
package="simple_joy_app", | ||
executable="app", | ||
namespace="app", | ||
remappings=[("/app/joystick", "/packet/joystick")], | ||
ros_arguments=["--log-level", log_level], | ||
) | ||
return LaunchDescription([log_level_arg, app]) |
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
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 |
---|---|---|
@@ -1,24 +1,42 @@ | ||
import os | ||
from typing import Any | ||
|
||
from ament_index_python.packages import get_package_share_directory | ||
from launch import LaunchDescription | ||
from launch.actions import DeclareLaunchArgument | ||
from launch.conditions import IfCondition, UnlessCondition | ||
from launch.substitutions import ( | ||
LaunchConfiguration, | ||
PathJoinSubstitution, | ||
PythonExpression, | ||
) | ||
from launch_ros.actions import Node | ||
from launch_ros.substitutions import FindPackageShare | ||
|
||
|
||
def generate_launch_description(): | ||
config = os.path.join( | ||
get_package_share_directory("camera_reader"), | ||
"config", | ||
"default_param.yml", | ||
def camera_node(**kwargs: Any) -> Node: | ||
kwargs["package"] = "camera_reader" | ||
kwargs["executable"] = "camera" | ||
kwargs["namespace"] = "device" | ||
return Node(**kwargs) | ||
|
||
|
||
def generate_launch_description() -> LaunchDescription: | ||
index_arg = DeclareLaunchArgument("index", default_value="-1") | ||
index = LaunchConfiguration("index") | ||
index_specified = PythonExpression([index, ">= 0"]) | ||
default_config_path = PathJoinSubstitution( | ||
[FindPackageShare("camera_reader"), "config", "default_param.yml"] | ||
) | ||
use_index = camera_node( | ||
name=["camera_", index], | ||
parameters=[{"camera_id": index}], | ||
remappings=[("/device/camera_image", ["/packet/camera_image_", index])], | ||
condition=IfCondition(index_specified), | ||
) | ||
unuse_index = camera_node( | ||
parameters=[default_config_path], | ||
remappings=[("/device/camera_image", "/packet/camera_image")], | ||
condition=UnlessCondition(index_specified), | ||
) | ||
return LaunchDescription( | ||
[ | ||
Node( | ||
package="camera_reader", | ||
executable="camera", | ||
namespace="device", | ||
parameters=[config], | ||
remappings=[("/device/camera_image", "/packet/camera_image")], | ||
), | ||
], | ||
[index_arg, use_index, unuse_index], | ||
) |
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
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
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,33 @@ | ||
# pi_led | ||
|
||
ラズパイのGPIOでLED(フルカラー)を扱う | ||
|
||
## Nodes | ||
|
||
- `Led`: LEDを扱う。以下のparameterを(起動時のみ)受け取る | ||
- `led_pin_r`: Redのピン | ||
- `led_pin_g`: Greenのピン | ||
- `led_pin_b`: Blueのピン | ||
|
||
parameterの設定例は./config以下を参照 | ||
|
||
## Executables | ||
|
||
- `pi_led`: `Led`Nodeをspinする | ||
|
||
## Launches | ||
|
||
- `led_launch.py`: `Led`Nodeを`device`namespace下でspinする。以下のlaunch引数が与えられる | ||
- `variant`: 使用するGPIO Pinセットの略称。`default`, `right`, `left`, `custom`のいずれか | ||
- `default`: ./config/default_param.ymlのparameter設定でspinする。 | ||
topic`/device/led_color`が`/packet/order/led_color`にremapされる | ||
- `right`: ./config/default_param.ymlのparameter設定でspinする。 | ||
Node名が`led_right`に書きかわり、 | ||
topic`/device/led_color`が`/packet/order/led_color_right`にremapされる | ||
- `left`: ./config/left_param.ymlのparameter設定でspinする。 | ||
Node名が`led_left`に書きかわり、 | ||
topic`/device/led_color`が`/packet/order/led_color_left`にremapされる | ||
- `custom`: launch引数`param_file`で指定されたparameterでspinする。 | ||
Node名が`led_custom`に書きかわり、 | ||
topic`/device/led_color`が`/packet/order/led_color_custom`にremapされる | ||
- `param_file`: カスタムのparameter設定ファイル。`variant:=custom`の時のみ有効 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
は文字列の結合のようなことをしているのでしょうか?
f"/packet/camera_image_{index}"
などしないのは、
index
がLaunchConfiguration()
の返り値であることと関係がありますか?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
はい。
はい。これはlaunchファイルのsubstitutionという機能で、launchの実行時に文字列の結合が行われます。例えば
ros2 launch --show-args imshow imshow_launch.py
ではlaunchの読み込みのみが行われて該当部分の文字列の結合は発生しません。ref: ROS2を深く理解する:launchファイル編2 substitution