ros2_control - rolling
Loading...
Searching...
No Matches
gz_ros2_control_plugin_utils.hpp
1// Copyright 2026 Open Source Robotics Foundation, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef GZ_ROS2_CONTROL_PLUGIN_UTILS_HPP_
16#define GZ_ROS2_CONTROL_PLUGIN_UTILS_HPP_
17
18#include <map>
19#include <optional>
20#include <string>
21#include <vector>
22
23#include <gz/sim/Entity.hh>
24#include <gz/sim/EntityComponentManager.hh>
25#include <sdf/Element.hh>
26
27#include <rclcpp/duration.hpp>
28#include <rclcpp/logger.hpp>
29
30// Internal helpers of GazeboSimROS2ControlPlugin. Not installed, only shared with the tests.
31namespace gz_ros2_control::detail
32{
35{
37 std::vector<std::string> parameter_files;
38
40 std::string controller_manager_name{"controller_manager"};
41
45
47 bool hold_joints{true};
48
51
53 std::string ns{"/"};
54
56 std::vector<std::string> remappings;
57};
58
63std::optional<PluginConfig> ParsePluginConfig(
64 const sdf::ElementConstPtr & sdf, std::string & error);
65
67std::string NormalizeNamespace(const std::string & ns);
68
70std::vector<std::string> BuildRosArguments(const PluginConfig & config);
71
77std::map<std::string, gz::sim::Entity> GetEnabledJoints(
78 const gz::sim::Entity & model,
79 const gz::sim::EntityComponentManager & ecm,
80 const rclcpp::Logger & logger);
81
83enum class PeriodMismatch
84{
85 kNone,
86 kControlFaster,
87 kControlSlower,
88};
89
91PeriodMismatch CheckPeriodMismatch(
92 const rclcpp::Duration & control_period,
93 const rclcpp::Duration & gazebo_period);
94
98bool ShouldUpdate(
99 const rclcpp::Duration & sim_period,
100 const rclcpp::Duration & control_period);
101} // namespace gz_ros2_control::detail
102
103#endif // GZ_ROS2_CONTROL_PLUGIN_UTILS_HPP_
Plugin settings read from the <plugin> SDF element.
Definition gz_ros2_control_plugin_utils.hpp:35
std::string controller_manager_name
Value of <controller_manager_name>
Definition gz_ros2_control_plugin_utils.hpp:40
double position_proportional_gain
Value of <position_proportional_gain>
Definition gz_ros2_control_plugin_utils.hpp:50
bool hold_joints
Value of <hold_joints>
Definition gz_ros2_control_plugin_utils.hpp:47
std::string ns
Value of <ros><namespace>, normalized with NormalizeNamespace.
Definition gz_ros2_control_plugin_utils.hpp:53
std::vector< std::string > remappings
Values of all the <ros><remapping> elements, in order.
Definition gz_ros2_control_plugin_utils.hpp:56
std::vector< std::string > parameter_files
Values of all the <parameters> elements, in order.
Definition gz_ros2_control_plugin_utils.hpp:37
double hardware_init_timeout
Value of <hardware_init_timeout>, seconds to wait for the hardware to be initialized,...
Definition gz_ros2_control_plugin_utils.hpp:44