Skip to content

Commit 7f0bd68

Browse files
authored
Cleanup deprecations in ros_control (#2258)
1 parent 150b179 commit 7f0bd68

File tree

13 files changed

+16
-336
lines changed

13 files changed

+16
-336
lines changed

controller_interface/include/controller_interface/helpers.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,6 @@ inline bool interface_list_contains_interface_type(
8181
interface_type_list.end();
8282
}
8383

84-
template <typename T>
85-
[[deprecated(
86-
"Use ros2_control::add_item method instead. This method will be removed by the ROS 2 Kilted "
87-
"Kaiju release.")]] void
88-
add_element_to_list(std::vector<T> & list, const T & element)
89-
{
90-
ros2_control::add_item(list, element);
91-
}
92-
9384
} // namespace controller_interface
9485

9586
#endif // CONTROLLER_INTERFACE__HELPERS_HPP_

controller_manager/controller_manager/spawner.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,6 @@ def main(args=None):
9393
action="append",
9494
required=False,
9595
)
96-
parser.add_argument(
97-
"-n",
98-
"--namespace",
99-
help="DEPRECATED Namespace for the controller_manager and the controller(s)",
100-
default=None,
101-
required=False,
102-
)
10396
parser.add_argument(
10497
"--load-only",
10598
help="Only load the controller and leave unconfigured.",
@@ -202,21 +195,7 @@ def main(args=None):
202195

203196
node = Node(spawner_node_name)
204197

205-
if node.get_namespace() != "/" and args.namespace:
206-
raise RuntimeError(
207-
f"Setting namespace through both '--namespace {args.namespace}' arg and the ROS 2 standard way "
208-
f"'--ros-args -r __ns:={node.get_namespace()}' is not allowed!"
209-
)
210-
211-
if args.namespace:
212-
warnings.filterwarnings("always")
213-
warnings.warn(
214-
"The '--namespace' argument is deprecated and will be removed in future releases."
215-
" Use the ROS 2 standard way of setting the node namespacing using --ros-args -r __ns:=<namespace>",
216-
DeprecationWarning,
217-
)
218-
219-
spawner_namespace = args.namespace if args.namespace else node.get_namespace()
198+
spawner_namespace = node.get_namespace()
220199

221200
if not spawner_namespace.startswith("/"):
222201
spawner_namespace = f"/{spawner_namespace}"

controller_manager/doc/userdoc.rst

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ There are two scripts to interact with controller manager from launch files:
168168
.. code-block:: console
169169
170170
$ ros2 run controller_manager spawner -h
171-
usage: spawner [-h] [-c CONTROLLER_MANAGER] [-p PARAM_FILE] [-n NAMESPACE] [--load-only] [--inactive] [-u] [--controller-manager-timeout CONTROLLER_MANAGER_TIMEOUT]
172-
[--switch-timeout SWITCH_TIMEOUT] [--activate-as-group] [--service-call-timeout SERVICE_CALL_TIMEOUT] [--controller-ros-args CONTROLLER_ROS_ARGS]
171+
usage: spawner [-h] [-c CONTROLLER_MANAGER] [-p PARAM_FILE] [--load-only] [--inactive] [-u] [--controller-manager-timeout CONTROLLER_MANAGER_TIMEOUT] [--switch-timeout SWITCH_TIMEOUT] [--service-call-timeout SERVICE_CALL_TIMEOUT] [--activate-as-group]
172+
[--controller-ros-args CONTROLLER_ROS_ARGS]
173173
controller_names [controller_names ...]
174174
175175
positional arguments:
@@ -181,21 +181,18 @@ There are two scripts to interact with controller manager from launch files:
181181
Name of the controller manager ROS node
182182
-p PARAM_FILE, --param-file PARAM_FILE
183183
Controller param file to be loaded into controller node before configure. Pass multiple times to load different files for different controllers or to override the parameters of the same controller.
184-
-n NAMESPACE, --namespace NAMESPACE
185-
DEPRECATED Namespace for the controller_manager and the controller(s)
186184
--load-only Only load the controller and leave unconfigured.
187185
--inactive Load and configure the controller, however do not activate them
188186
-u, --unload-on-kill Wait until this application is interrupted and unload controller
189187
--controller-manager-timeout CONTROLLER_MANAGER_TIMEOUT
190188
Time to wait for the controller manager service to be available
189+
--switch-timeout SWITCH_TIMEOUT
190+
Time to wait for a successful state switch of controllers. Useful when switching cannot be performed immediately, e.g., paused simulations at startup
191191
--service-call-timeout SERVICE_CALL_TIMEOUT
192192
Time to wait for the service response from the controller manager
193-
--switch-timeout SWITCH_TIMEOUT
194-
Time to wait for a successful state switch of controllers. Useful if controllers cannot be switched immediately, e.g., paused
195-
simulations at startup
196193
--activate-as-group Activates all the parsed controllers list together instead of one by one. Useful for activating all chainable controllers altogether
197194
--controller-ros-args CONTROLLER_ROS_ARGS
198-
The --ros-args to be passed to the controller node for remapping topics etc
195+
The --ros-args to be passed to the controller node, e.g., for remapping topics. Pass multiple times for every argument.
199196
200197
201198
The parsed controller config file can follow the same conventions as the typical ROS 2 parameter file format. Now, the spawner can handle config files with wildcard entries and also the controller name in the absolute namespace. See the following examples on the config files:

controller_manager/test/test_spawner_unspawner.cpp

Lines changed: 4 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,97 +1144,6 @@ TEST_F(TestLoadControllerWithNamespacedCM, spawner_test_type_in_params_file)
11441144
cm_->get_parameter(ctrl_2.info.name + ".params_file").as_string_array()[0], test_file_path);
11451145
}
11461146

1147-
TEST_F(
1148-
TestLoadControllerWithNamespacedCM, spawner_test_type_in_params_file_deprecated_namespace_arg)
1149-
{
1150-
const std::string test_file_path =
1151-
std::string(PARAMETERS_FILE_PATH) + std::string("test_controller_spawner_with_type.yaml");
1152-
1153-
ControllerManagerRunner cm_runner(this);
1154-
// Provide controller type via the parsed file
1155-
EXPECT_EQ(
1156-
call_spawner(
1157-
"ns_ctrl_with_parameters_and_type ns_chainable_ctrl_with_parameters_and_type --load-only -c "
1158-
"test_controller_manager --controller-manager-timeout 1.0 -p " +
1159-
test_file_path),
1160-
256)
1161-
<< "Should fail without the namespacing it";
1162-
EXPECT_EQ(
1163-
call_spawner(
1164-
"ns_ctrl_with_parameters_and_type ns_chainable_ctrl_with_parameters_and_type --load-only -c "
1165-
"test_controller_manager --namespace foo_namespace --controller-manager-timeout 1.0 -p " +
1166-
test_file_path + " --ros-args -r __ns:=/random_namespace"),
1167-
256)
1168-
<< "Should fail when parsed namespace through both way with different namespaces";
1169-
EXPECT_EQ(
1170-
call_spawner(
1171-
"ns_ctrl_with_parameters_and_type ns_chainable_ctrl_with_parameters_and_type --load-only -c "
1172-
"test_controller_manager --namespace foo_namespace --controller-manager-timeout 1.0 -p" +
1173-
test_file_path + " --ros-args -r __ns:=/foo_namespace"),
1174-
256)
1175-
<< "Should fail when parsed namespace through both ways even with same namespacing name";
1176-
EXPECT_EQ(
1177-
call_spawner(
1178-
"ns_ctrl_with_parameters_and_type ns_chainable_ctrl_with_parameters_and_type --load-only -c "
1179-
"test_controller_manager --namespace foo_namespace -p " +
1180-
test_file_path),
1181-
0)
1182-
<< "Should work when parsed through the deprecated arg";
1183-
1184-
ASSERT_EQ(cm_->get_loaded_controllers().size(), 2ul);
1185-
1186-
auto ctrl_with_parameters_and_type = cm_->get_loaded_controllers()[0];
1187-
ASSERT_EQ(ctrl_with_parameters_and_type.info.name, "ns_ctrl_with_parameters_and_type");
1188-
ASSERT_EQ(ctrl_with_parameters_and_type.info.type, test_controller::TEST_CONTROLLER_CLASS_NAME);
1189-
ASSERT_EQ(
1190-
ctrl_with_parameters_and_type.c->get_lifecycle_state().id(),
1191-
lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED);
1192-
ASSERT_EQ(
1193-
cm_->get_parameter(ctrl_with_parameters_and_type.info.name + ".params_file")
1194-
.as_string_array()[0],
1195-
test_file_path);
1196-
1197-
auto chain_ctrl_with_parameters_and_type = cm_->get_loaded_controllers()[1];
1198-
ASSERT_EQ(
1199-
chain_ctrl_with_parameters_and_type.info.name, "ns_chainable_ctrl_with_parameters_and_type");
1200-
ASSERT_EQ(
1201-
chain_ctrl_with_parameters_and_type.info.type,
1202-
test_chainable_controller::TEST_CONTROLLER_CLASS_NAME);
1203-
ASSERT_EQ(
1204-
chain_ctrl_with_parameters_and_type.c->get_lifecycle_state().id(),
1205-
lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED);
1206-
ASSERT_EQ(
1207-
cm_->get_parameter(chain_ctrl_with_parameters_and_type.info.name + ".params_file")
1208-
.as_string_array()[0],
1209-
test_file_path);
1210-
1211-
EXPECT_EQ(
1212-
call_spawner(
1213-
"ns_ctrl_with_parameters_and_no_type -c test_controller_manager --namespace foo_namespace "
1214-
"-p " +
1215-
test_file_path),
1216-
256)
1217-
<< "Should fail as no type is defined!";
1218-
// Will still be same as the current call will fail
1219-
ASSERT_EQ(cm_->get_loaded_controllers().size(), 2ul);
1220-
1221-
auto ctrl_1 = cm_->get_loaded_controllers()[0];
1222-
ASSERT_EQ(ctrl_1.info.name, "ns_ctrl_with_parameters_and_type");
1223-
ASSERT_EQ(ctrl_1.info.type, test_controller::TEST_CONTROLLER_CLASS_NAME);
1224-
ASSERT_EQ(
1225-
ctrl_1.c->get_lifecycle_state().id(), lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED);
1226-
ASSERT_EQ(
1227-
cm_->get_parameter(ctrl_1.info.name + ".params_file").as_string_array()[0], test_file_path);
1228-
1229-
auto ctrl_2 = cm_->get_loaded_controllers()[1];
1230-
ASSERT_EQ(ctrl_2.info.name, "ns_chainable_ctrl_with_parameters_and_type");
1231-
ASSERT_EQ(ctrl_2.info.type, test_chainable_controller::TEST_CONTROLLER_CLASS_NAME);
1232-
ASSERT_EQ(
1233-
ctrl_2.c->get_lifecycle_state().id(), lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED);
1234-
ASSERT_EQ(
1235-
cm_->get_parameter(ctrl_2.info.name + ".params_file").as_string_array()[0], test_file_path);
1236-
}
1237-
12381147
TEST_F(TestLoadControllerWithNamespacedCM, spawner_test_with_wildcard_entries_in_params_file)
12391148
{
12401149
const std::string test_file_path =
@@ -1318,16 +1227,14 @@ TEST_F(
13181227
<< "Should fail without the namespacing it";
13191228
EXPECT_EQ(
13201229
call_spawner(
1321-
"ctrl_with_parameters_and_type --load-only -c "
1322-
"test_controller_manager --namespace foo_namespace -p " +
1323-
test_file_path),
1230+
"ctrl_with_parameters_and_type --load-only -c test_controller_manager -p " + test_file_path +
1231+
" --ros-args -r __ns:=/foo_namespace"),
13241232
256)
13251233
<< "Should fail even namespacing it as ctrl_with_parameters_and_type is not a wildcard entry";
13261234
EXPECT_EQ(
13271235
call_spawner(
1328-
"chainable_ctrl_with_parameters_and_type --load-only -c "
1329-
"test_controller_manager --namespace foo_namespace -p " +
1330-
test_file_path),
1236+
"chainable_ctrl_with_parameters_and_type --load-only -c test_controller_manager -p " +
1237+
test_file_path + " --ros-args -r __ns:=/foo_namespace"),
13311238
0)
13321239
<< "Should work as chainable_ctrl_with_parameters_and_type is a wildcard entry";
13331240

controller_manager_msgs/msg/HardwareComponentState.msg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ string name # Name of the hardware component
22
string type # Type of the hardware component
33
bool is_async # If the hardware component is running asynchronously
44
uint16 rw_rate # read/write rate of the hardware component in Hz
5-
string class_type # DEPRECATED
65
string plugin_name # The name of the plugin that is used to load the hardware component
76
lifecycle_msgs/State state # State of the hardware component
87
HardwareInterface[] command_interfaces # Command interfaces of the hardware component

hardware_interface/include/hardware_interface/actuator_interface.hpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,6 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod
112112

113113
virtual ~ActuatorInterface() = default;
114114

115-
/// Initialization of the hardware interface from data parsed from the robot's URDF and also the
116-
/// clock and logger interfaces.
117-
/**
118-
* \param[in] hardware_info structure with data from URDF.
119-
* \param[in] logger Logger for the hardware component.
120-
* \param[in] clock_interface pointer to the clock interface.
121-
* \returns CallbackReturn::SUCCESS if required data are provided and can be parsed.
122-
* \returns CallbackReturn::ERROR if any error happens or data are missing.
123-
*/
124-
[[deprecated("Use init(HardwareInfo, rclcpp::Logger, rclcpp::Clock::SharedPtr) instead.")]]
125-
CallbackReturn init(
126-
const HardwareInfo & hardware_info, rclcpp::Logger logger,
127-
rclcpp::node_interfaces::NodeClockInterface::SharedPtr clock_interface)
128-
{
129-
return this->init(hardware_info, logger, clock_interface->get_clock());
130-
}
131-
132115
/// Initialization of the hardware interface from data parsed from the robot's URDF and also the
133116
/// clock and logger interfaces.
134117
/**

hardware_interface/include/hardware_interface/handle.hpp

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,6 @@ class Handle
134134

135135
const std::string & get_interface_name() const { return interface_name_; }
136136

137-
[[deprecated(
138-
"Replaced by get_name method, which is semantically more correct")]] const std::string &
139-
get_full_name() const
140-
{
141-
return get_name();
142-
}
143-
144137
const std::string & get_prefix_name() const { return prefix_name_; }
145138

146139
[[deprecated(
@@ -216,54 +209,6 @@ class Handle
216209
// END
217210
}
218211

219-
/**
220-
* @brief Get the value of the handle.
221-
* @tparam T The type of the value to be retrieved.
222-
* @param value The value of the handle.
223-
* @return true if the value is accessed successfully, false otherwise.
224-
*
225-
* @note The method is thread-safe and non-blocking.
226-
* @note When different threads access the same handle at same instance, and if they are unable to
227-
* lock the handle to access the value, the handle returns false. If the operation is successful,
228-
* the value is updated and returns true.
229-
*/
230-
template <typename T>
231-
[[deprecated(
232-
"Use std::optional<T> get_optional() instead to retrieve the value. This method will be "
233-
"removed by the ROS 2 Kilted Kaiju release.")]] [[nodiscard]] bool
234-
get_value(T & value) const
235-
{
236-
std::shared_lock<std::shared_mutex> lock(handle_mutex_, std::try_to_lock);
237-
if (!lock.owns_lock())
238-
{
239-
return false;
240-
}
241-
// BEGIN (Handle export change): for backward compatibility
242-
// TODO(Manuel) return value_ if old functionality is removed
243-
if constexpr (std::is_same_v<T, double>)
244-
{
245-
// If the template is of type double, check if the value_ptr_ is not nullptr
246-
THROW_ON_NULLPTR(value_ptr_);
247-
value = *value_ptr_;
248-
}
249-
else
250-
{
251-
try
252-
{
253-
value = std::get<T>(value_);
254-
}
255-
catch (const std::bad_variant_access & err)
256-
{
257-
throw std::runtime_error(
258-
fmt::format(
259-
FMT_COMPILE("Invalid data type : '{}' access for interface : {} expected : '{}'"),
260-
get_type_name<T>(), get_name(), data_type_.to_string()));
261-
}
262-
}
263-
return true;
264-
// END
265-
}
266-
267212
/**
268213
* @brief Set the value of the handle.
269214
* @tparam T The type of the value to be set.

hardware_interface/include/hardware_interface/loaned_command_interface.hpp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ class LoanedCommandInterface
8585

8686
const std::string & get_interface_name() const { return command_interface_.get_interface_name(); }
8787

88-
[[deprecated(
89-
"Replaced by get_name method, which is semantically more correct")]] const std::string
90-
get_full_name() const
91-
{
92-
return command_interface_.get_name();
93-
}
94-
9588
const std::string & get_prefix_name() const { return command_interface_.get_prefix_name(); }
9689

9790
/**
@@ -179,36 +172,6 @@ class LoanedCommandInterface
179172
return std::nullopt;
180173
}
181174

182-
/**
183-
* @brief Get the value of the command interface.
184-
* @tparam T The type of the value to be retrieved.
185-
* @param value The value of the command interface.
186-
* @param max_tries The maximum number of tries to get the value.
187-
* @return true if the value is accessed successfully, false otherwise.
188-
*
189-
* @note The method is thread-safe and non-blocking.
190-
* @note When different threads access the internal handle at same instance, and if they are
191-
* unable to lock the handle to access the value, the handle returns false. If the operation is
192-
* successful, the value is updated and returns true.
193-
* @note The method will try to get the value max_tries times before returning false. The method
194-
* will yield the thread between tries. If the value is updated successfully, the method returns
195-
* true immediately.
196-
*/
197-
template <typename T>
198-
[[deprecated(
199-
"Use std::optional<T> get_optional() instead to retrieve the value. This method will be "
200-
"removed by the ROS 2 Kilted Kaiju release.")]] [[nodiscard]] bool
201-
get_value(T & value, unsigned int max_tries = 10) const
202-
{
203-
const auto opt_value = get_optional<T>(max_tries);
204-
if (opt_value.has_value())
205-
{
206-
value = opt_value.value();
207-
return true;
208-
}
209-
return false;
210-
}
211-
212175
protected:
213176
CommandInterface & command_interface_;
214177
Deleter deleter_;

0 commit comments

Comments
 (0)