Skip to content

Commit 3eae727

Browse files
authored
[CM] Remove deprecated spawner args (ros-controls#1639)
1 parent 3bc4e45 commit 3eae727

File tree

4 files changed

+10
-50
lines changed

4 files changed

+10
-50
lines changed

controller_manager/controller_manager/launch_utils.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import warnings
1615
from launch import LaunchDescription
1716
from launch.actions import DeclareLaunchArgument
1817
from launch.substitutions import LaunchConfiguration, PythonExpression
@@ -21,7 +20,7 @@
2120

2221

2322
def generate_load_controller_launch_description(
24-
controller_name, controller_type=None, controller_params_file=None, extra_spawner_args=[]
23+
controller_name, controller_params_file=None, extra_spawner_args=[]
2524
):
2625
"""
2726
Generate launch description for loading a controller using spawner.
@@ -32,13 +31,12 @@ def generate_load_controller_launch_description(
3231
3332
Examples
3433
--------
35-
# Assuming the controller type and controller parameters are known to the controller_manager
34+
# Assuming the controller parameters are known to the controller_manager
3635
generate_load_controller_launch_description('joint_state_broadcaster')
3736
38-
# Passing controller type and controller parameter file to load
37+
# Passing controller parameter file to load the controller (Controller type is retrieved from config file)
3938
generate_load_controller_launch_description(
4039
'joint_state_broadcaster',
41-
controller_type='joint_state_broadcaster/JointStateBroadcaster',
4240
controller_params_file=os.path.join(get_package_share_directory('my_pkg'),
4341
'config', 'controller_params.yaml'),
4442
extra_spawner_args=[--load-only]
@@ -62,15 +60,6 @@ def generate_load_controller_launch_description(
6260
LaunchConfiguration("controller_manager_name"),
6361
]
6462

65-
if controller_type:
66-
warnings.warn(
67-
"The 'controller_type' argument is deprecated and will be removed in future releases."
68-
" Declare the controller type parameter in the param file instead.",
69-
DeprecationWarning,
70-
stacklevel=2,
71-
)
72-
spawner_arguments += ["--controller-type", controller_type]
73-
7463
if controller_params_file:
7564
spawner_arguments += ["--param-file", controller_params_file]
7665

controller_manager/controller_manager/spawner.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def main(args=None):
166166
"-p",
167167
"--param-file",
168168
help="Controller param file to be loaded into controller node before configure",
169+
default=None,
169170
required=False,
170171
)
171172
parser.add_argument(
@@ -183,13 +184,6 @@ def main(args=None):
183184
action="store_true",
184185
required=False,
185186
)
186-
parser.add_argument(
187-
"-t",
188-
"--controller-type",
189-
help="If not provided it should exist in the controller manager namespace (deprecated)",
190-
default=None,
191-
required=False,
192-
)
193187
parser.add_argument(
194188
"-u",
195189
"--unload-on-kill",
@@ -227,14 +221,6 @@ def main(args=None):
227221
param_file = args.param_file
228222
controller_manager_timeout = args.controller_manager_timeout
229223

230-
if args.controller_type:
231-
warnings.filterwarnings("always")
232-
warnings.warn(
233-
"The '--controller-type' argument is deprecated and will be removed in future releases."
234-
" Declare the controller type parameter in the param file instead.",
235-
DeprecationWarning,
236-
)
237-
238224
if param_file and not os.path.isfile(param_file):
239225
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), param_file)
240226

@@ -258,7 +244,6 @@ def main(args=None):
258244

259245
for controller_name in controller_names:
260246
fallback_controllers = args.fallback_controllers
261-
controller_type = args.controller_type
262247
prefixed_controller_name = controller_name
263248
if controller_namespace:
264249
prefixed_controller_name = controller_namespace + "/" + controller_name
@@ -270,10 +255,11 @@ def main(args=None):
270255
+ bcolors.ENDC
271256
)
272257
else:
273-
if not controller_type and param_file:
274-
controller_type = get_parameter_from_param_file(
275-
controller_name, param_file, "type"
276-
)
258+
controller_type = (
259+
None
260+
if param_file is None
261+
else get_parameter_from_param_file(controller_name, param_file, "type")
262+
)
277263
if controller_type:
278264
parameter = Parameter()
279265
parameter.name = prefixed_controller_name + ".type"

controller_manager/test/test_spawner_unspawner.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -244,22 +244,6 @@ TEST_F(TestLoadController, multi_ctrls_test_type_in_param)
244244
}
245245
}
246246

247-
TEST_F(TestLoadController, spawner_test_type_in_arg)
248-
{
249-
// Provide controller type via -t argument
250-
EXPECT_EQ(
251-
call_spawner(
252-
"ctrl_2 -c test_controller_manager -t " +
253-
std::string(test_controller::TEST_CONTROLLER_CLASS_NAME)),
254-
0);
255-
256-
ASSERT_EQ(cm_->get_loaded_controllers().size(), 1ul);
257-
auto ctrl_2 = cm_->get_loaded_controllers()[0];
258-
ASSERT_EQ(ctrl_2.info.name, "ctrl_2");
259-
ASSERT_EQ(ctrl_2.info.type, test_controller::TEST_CONTROLLER_CLASS_NAME);
260-
ASSERT_EQ(ctrl_2.c->get_state().id(), lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE);
261-
}
262-
263247
TEST_F(TestLoadController, spawner_test_type_in_params_file)
264248
{
265249
const std::string test_file_path = ament_index_cpp::get_package_prefix("controller_manager") +

doc/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ controller_manager
6969
7070
The parameters within the ``ros2_control`` tag are not supported any more.
7171
* The support for the ``description`` parameter for loading the URDF was removed (`#1358 <https://github.com/ros-controls/ros2_control/pull/1358>`_).
72+
* The ``--controller-type`` or ``-t`` spawner arg is removed. Now the controller type is defined in the controller configuration file with ``type`` field (`#1639 <https://github.com/ros-controls/ros2_control/pull/1639>`_).
7273

7374
hardware_interface
7475
******************

0 commit comments

Comments
 (0)