Skip to content

Commit

Permalink
🔨 Renamed generic my_param variable accordingly throughout package to…
Browse files Browse the repository at this point in the history
… more informative label of use_image_viewer.

Signed-off-by: Bey Hao Yun <[email protected]>
  • Loading branch information
cardboardcode committed Mar 11, 2024
1 parent eb665d0 commit 3acb8a9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions launch/showimageraw.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

def generate_launch_description():

my_param = DeclareLaunchArgument(
'my_param',
imageviewer_flag_param = DeclareLaunchArgument(
'use_image_viewer',
default_value='false',
description='Set use_image_viewer [yes/no]'
)
Expand All @@ -32,11 +32,11 @@ def generate_launch_description():
executable='virtual_camera',
output='screen',
parameters=[{
'my_param': LaunchConfiguration('my_param')
'use_image_viewer': LaunchConfiguration('use_image_viewer')
}]
)

return LaunchDescription([
my_param,
imageviewer_flag_param,
vcam_node
])
2 changes: 1 addition & 1 deletion scripts/show_image.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

source /opt/ros/humble/setup.bash
source install/setup.bash
ros2 launch virtual_camera showimageraw.launch.py my_param:=true
ros2 launch virtual_camera showimageraw.launch.py use_image_viewer:=true
8 changes: 4 additions & 4 deletions src/virtual_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ int main(int argc, char * argv[])
}

// Declare a boolean parameter within the main function
vcamera_node->declare_parameter("my_param", true);
vcamera_node->declare_parameter("use_image_viewer", false);

// Get the parameter value
bool param_value = vcamera_node->get_parameter("my_param").as_bool();
RCLCPP_INFO(vcamera_node->get_logger(), "my_param value: %s", param_value ? "true" : "false");
bool imageviewer_flag = vcamera_node->get_parameter("use_image_viewer").as_bool();
RCLCPP_INFO(vcamera_node->get_logger(), "use_image_viewer set to: [%s]", imageviewer_flag ? "true" : "false");

auto image_view_node = std::make_shared<ImageViewer>();

executor.add_node(vcamera_node);

if (param_value) {
if (imageviewer_flag) {
executor.add_node(image_view_node);
}

Expand Down

0 comments on commit 3acb8a9

Please sign in to comment.