Skip to content

Commit

Permalink
Parameters reorganisation (#472)
Browse files Browse the repository at this point in the history
* moved all params declarations to src/

* Update husarion_ugv_battery/launch/battery.launch.py

Co-authored-by: Rafal Gorecki <[email protected]>

---------

Co-authored-by: Rafal Gorecki <[email protected]>
  • Loading branch information
BOOTCFG and rafal-gorecki authored Jan 2, 2025
1 parent ac9a5de commit efc5411
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 8 deletions.
4 changes: 2 additions & 2 deletions husarion_ugv_battery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ add_executable(
src/battery_publisher/single_battery_publisher.cpp)
ament_target_dependencies(battery_driver_node ${PACKAGE_DEPENDENCIES})

generate_parameter_library(battery_parameters config/battery_parameters.yaml)
generate_parameter_library(battery_parameters src/battery_parameters.yaml)
target_link_libraries(battery_driver_node battery_parameters)

install(TARGETS battery_driver_node DESTINATION lib/${PROJECT_NAME})

install(DIRECTORY launch DESTINATION share/${PROJECT_NAME})
install(DIRECTORY config launch DESTINATION share/${PROJECT_NAME})

if(BUILD_TESTING)
find_package(ament_cmake_gtest REQUIRED)
Expand Down
15 changes: 15 additions & 0 deletions husarion_ugv_battery/config/battery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**:
battery_driver:
ros__parameters:
adc:
device0: "/sys/bus/iio/devices/iio:device0"
device1: "/sys/bus/iio/devices/iio:device1"
ma_window_len:
charge: 10
temp: 10
ma_window_len:
voltage: 10
current: 10
roboteq:
driver_state_timeout: 0.2
battery_timeout: 1.0
18 changes: 17 additions & 1 deletion husarion_ugv_battery/launch/battery.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import EnvironmentVariable, LaunchConfiguration
from launch.substitutions import (
EnvironmentVariable,
LaunchConfiguration,
PathJoinSubstitution,
)
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():
Expand All @@ -28,17 +33,28 @@ def generate_launch_description():
description="Add namespace to all launched nodes.",
)

battery_config_path = LaunchConfiguration("battery_config_path")
declare_battery_config_path_arg = DeclareLaunchArgument(
"battery_config_path",
default_value=PathJoinSubstitution(
[FindPackageShare("husarion_ugv_battery"), "config", "battery.yaml"]
),
description="Specify the path to the system monitor configuration file.",
)

battery_driver_node = Node(
package="husarion_ugv_battery",
executable="battery_driver_node",
name="battery_driver",
parameters=[battery_config_path],
namespace=namespace,
remappings=[("/diagnostics", "diagnostics")],
emulate_tty=True,
)

actions = [
declare_namespace_arg,
declare_battery_config_path_arg,
battery_driver_node,
]

Expand Down
2 changes: 1 addition & 1 deletion husarion_ugv_hardware_interfaces/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ endforeach()
include_directories(include)

generate_parameter_library(phidgets_spatial_parameters
config/phidgets_spatial_parameters.yaml)
src/phidgets_spatial_parameters.yaml)

set(ENV{PKG_CONFIG_PATH}
"${CMAKE_INSTALL_PREFIX}/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}")
Expand Down
4 changes: 2 additions & 2 deletions husarion_ugv_lights/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ament_target_dependencies(
std_srvs)

generate_parameter_library(lights_driver_parameters
config/lights_driver_parameters.yaml)
src/lights_driver_parameters.yaml)
target_link_libraries(lights_driver_node_component lights_driver_parameters)

add_library(
Expand All @@ -63,7 +63,7 @@ ament_target_dependencies(
sensor_msgs)

generate_parameter_library(lights_controller_parameters
config/lights_controller_parameters.yaml)
src/lights_controller_parameters.yaml)
target_link_libraries(lights_controller_node_component yaml-cpp
lights_controller_parameters)

Expand Down
4 changes: 2 additions & 2 deletions husarion_ugv_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ament_target_dependencies(
tf2_geometry_msgs)

generate_parameter_library(safety_manager_parameters
config/safety_manager_parameters.yaml)
src/safety_manager_parameters.yaml)
target_link_libraries(safety_manager_node ${plugin_libs}
safety_manager_parameters)

Expand All @@ -104,7 +104,7 @@ ament_target_dependencies(
tf2_geometry_msgs)

generate_parameter_library(lights_manager_parameters
config/lights_manager_parameters.yaml)
src/lights_manager_parameters.yaml)
target_link_libraries(lights_manager_node ${plugin_libs}
lights_manager_parameters)

Expand Down

0 comments on commit efc5411

Please sign in to comment.