Skip to content

Commit 55f6364

Browse files
committed
Introuduce gen param library.
1 parent bb54c12 commit 55f6364

File tree

6 files changed

+227
-74
lines changed

6 files changed

+227
-74
lines changed

ign_ros2_control/CMakeLists.txt

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ find_package(hardware_interface REQUIRED)
2323
find_package(pluginlib REQUIRED)
2424
find_package(rclcpp REQUIRED)
2525
find_package(yaml_cpp_vendor REQUIRED)
26+
find_package(generate_parameter_library REQUIRED)
27+
28+
generate_parameter_library(ign_ros2_control_parameters
29+
src/ign_ros2_control_parameters.yaml
30+
include/ign_ros2_control/validate_system_parameters.hpp
31+
)
2632

2733
if("$ENV{IGNITION_VERSION}" STREQUAL "citadel")
2834
find_package(ignition-gazebo3 REQUIRED)
@@ -82,9 +88,13 @@ target_link_libraries(ign_hardware_plugins
8288
ignition-gazebo${IGN_GAZEBO_VER}::core
8389
)
8490

91+
target_link_libraries(ign_hardware_plugins
92+
ign_ros2_control_parameters
93+
)
94+
8595
## Install
86-
install(TARGETS
87-
ign_hardware_plugins
96+
install(TARGETS ign_hardware_plugins ign_ros2_control_parameters
97+
EXPORT export_ign_ros2_control
8898
ARCHIVE DESTINATION lib
8999
LIBRARY DESTINATION lib
90100
RUNTIME DESTINATION bin
@@ -99,12 +109,24 @@ endif()
99109
ament_export_include_directories(include)
100110
ament_export_libraries(${PROJECT_NAME} ign_hardware_plugins)
101111

112+
ament_export_targets(
113+
export_ign_ros2_control HAS_LIBRARY_TARGET
114+
)
102115
# Install directories
103116
install(TARGETS ${PROJECT_NAME}-system
104117
DESTINATION lib
105118
)
106119

107120
pluginlib_export_plugin_description_file(ign_ros2_control ign_hardware_plugins.xml)
108121

122+
ament_export_dependencies(
123+
ament_index_cpp
124+
controller_manager
125+
hardware_interface
126+
pluginlib
127+
rclcpp
128+
yaml_cpp_vendor
129+
rclcpp_lifecycle
130+
)
109131
# Setup the project
110132
ament_package()

ign_ros2_control/include/ign_ros2_control/ign_system.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include "rclcpp_lifecycle/state.hpp"
2626
#include "rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp"
2727

28+
#include "ign_ros2_control_parameters.hpp"
29+
2830
namespace ign_ros2_control
2931
{
3032
using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn;
@@ -88,6 +90,14 @@ class IgnitionSystem : public IgnitionSystemInterface
8890

8991
/// \brief Private data class
9092
std::unique_ptr<IgnitionSystemPrivate> dataPtr;
93+
94+
rcl_interfaces::msg::SetParametersResult myCallback(const std::vector<rclcpp::Parameter> & parameters);
95+
rclcpp::Node::OnSetParametersCallbackHandle::SharedPtr cb_;
96+
97+
rclcpp::Node::SharedPtr node_;
98+
99+
std::thread spin_thread_;
100+
91101
};
92102

93103
} // namespace ign_ros2_control
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifndef IGN_ROS2_CONTROL__VALIDATE_SYSTEM_PARAMETERS_HPP_
2+
#define IGN_ROS2_CONTROL__VALIDATE_SYSTEM_PARAMETERS_HPP_
3+
4+
#include <string>
5+
6+
#include "parameter_traits/parameter_traits.hpp"
7+
8+
namespace parameter_traits
9+
{
10+
11+
} // namespace parameter_traits
12+
13+
#endif // IGN_ROS2_CONTROL__VALIDATE_SYSTEM_PARAMETERS_HPP_

ign_ros2_control/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<depend>rclcpp_lifecycle</depend>
2323
<depend>hardware_interface</depend>
2424
<depend>controller_manager</depend>
25+
<depend>generate_parameter_library</depend>
2526

2627
<test_depend>ament_lint_auto</test_depend>
2728
<test_depend>ament_lint_common</test_depend>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
ignition_system_interface:
2+
joints: {
3+
type: string_array,
4+
default_value: [],
5+
description: "Names of joints used by the controller",
6+
validation: {
7+
unique<>: null,
8+
}
9+
}
10+
gains:
11+
__map_joints:
12+
p: {
13+
type: double,
14+
default_value: 0.0,
15+
description: "Proportional gain for PID"
16+
}
17+
i: {
18+
type: double,
19+
default_value: 0.0,
20+
description: "Integral gain for PID"
21+
}
22+
d: {
23+
type: double,
24+
default_value: 0.0,
25+
description: "Derivative gain for PID"
26+
}
27+
iMax: {
28+
type: double,
29+
default_value: 0.0,
30+
description: "Integral positive clamp."
31+
}
32+
iMin: {
33+
type: double,
34+
default_value: 0.0,
35+
description: "Integral negative clamp."
36+
}
37+
cmdMax: {
38+
type: double,
39+
default_value: 0.0,
40+
description: "Maximum value for the PID command."
41+
}
42+
cmdMin: {
43+
type: double,
44+
default_value: 0.0,
45+
description: "Maximum value for the PID command."
46+
}
47+
cmdOffset: {
48+
type: double,
49+
default_value: 0.0,
50+
description: "Offset value for the command which is added to the result of the PID controller."
51+
}

0 commit comments

Comments
 (0)