Skip to content

Commit

Permalink
[CM] Remove deprecated spawner args (#1639)
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor authored Jul 27, 2024
1 parent 3bc4e45 commit 3eae727
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 50 deletions.
17 changes: 3 additions & 14 deletions controller_manager/controller_manager/launch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import warnings
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration, PythonExpression
Expand All @@ -21,7 +20,7 @@


def generate_load_controller_launch_description(
controller_name, controller_type=None, controller_params_file=None, extra_spawner_args=[]
controller_name, controller_params_file=None, extra_spawner_args=[]
):
"""
Generate launch description for loading a controller using spawner.
Expand All @@ -32,13 +31,12 @@ def generate_load_controller_launch_description(
Examples
--------
# Assuming the controller type and controller parameters are known to the controller_manager
# Assuming the controller parameters are known to the controller_manager
generate_load_controller_launch_description('joint_state_broadcaster')
# Passing controller type and controller parameter file to load
# Passing controller parameter file to load the controller (Controller type is retrieved from config file)
generate_load_controller_launch_description(
'joint_state_broadcaster',
controller_type='joint_state_broadcaster/JointStateBroadcaster',
controller_params_file=os.path.join(get_package_share_directory('my_pkg'),
'config', 'controller_params.yaml'),
extra_spawner_args=[--load-only]
Expand All @@ -62,15 +60,6 @@ def generate_load_controller_launch_description(
LaunchConfiguration("controller_manager_name"),
]

if controller_type:
warnings.warn(
"The 'controller_type' argument is deprecated and will be removed in future releases."
" Declare the controller type parameter in the param file instead.",
DeprecationWarning,
stacklevel=2,
)
spawner_arguments += ["--controller-type", controller_type]

if controller_params_file:
spawner_arguments += ["--param-file", controller_params_file]

Expand Down
26 changes: 6 additions & 20 deletions controller_manager/controller_manager/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def main(args=None):
"-p",
"--param-file",
help="Controller param file to be loaded into controller node before configure",
default=None,
required=False,
)
parser.add_argument(
Expand All @@ -183,13 +184,6 @@ def main(args=None):
action="store_true",
required=False,
)
parser.add_argument(
"-t",
"--controller-type",
help="If not provided it should exist in the controller manager namespace (deprecated)",
default=None,
required=False,
)
parser.add_argument(
"-u",
"--unload-on-kill",
Expand Down Expand Up @@ -227,14 +221,6 @@ def main(args=None):
param_file = args.param_file
controller_manager_timeout = args.controller_manager_timeout

if args.controller_type:
warnings.filterwarnings("always")
warnings.warn(
"The '--controller-type' argument is deprecated and will be removed in future releases."
" Declare the controller type parameter in the param file instead.",
DeprecationWarning,
)

if param_file and not os.path.isfile(param_file):
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), param_file)

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

for controller_name in controller_names:
fallback_controllers = args.fallback_controllers
controller_type = args.controller_type
prefixed_controller_name = controller_name
if controller_namespace:
prefixed_controller_name = controller_namespace + "/" + controller_name
Expand All @@ -270,10 +255,11 @@ def main(args=None):
+ bcolors.ENDC
)
else:
if not controller_type and param_file:
controller_type = get_parameter_from_param_file(
controller_name, param_file, "type"
)
controller_type = (
None
if param_file is None
else get_parameter_from_param_file(controller_name, param_file, "type")
)
if controller_type:
parameter = Parameter()
parameter.name = prefixed_controller_name + ".type"
Expand Down
16 changes: 0 additions & 16 deletions controller_manager/test/test_spawner_unspawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,22 +244,6 @@ TEST_F(TestLoadController, multi_ctrls_test_type_in_param)
}
}

TEST_F(TestLoadController, spawner_test_type_in_arg)
{
// Provide controller type via -t argument
EXPECT_EQ(
call_spawner(
"ctrl_2 -c test_controller_manager -t " +
std::string(test_controller::TEST_CONTROLLER_CLASS_NAME)),
0);

ASSERT_EQ(cm_->get_loaded_controllers().size(), 1ul);
auto ctrl_2 = cm_->get_loaded_controllers()[0];
ASSERT_EQ(ctrl_2.info.name, "ctrl_2");
ASSERT_EQ(ctrl_2.info.type, test_controller::TEST_CONTROLLER_CLASS_NAME);
ASSERT_EQ(ctrl_2.c->get_state().id(), lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE);
}

TEST_F(TestLoadController, spawner_test_type_in_params_file)
{
const std::string test_file_path = ament_index_cpp::get_package_prefix("controller_manager") +
Expand Down
1 change: 1 addition & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ controller_manager
The parameters within the ``ros2_control`` tag are not supported any more.
* The support for the ``description`` parameter for loading the URDF was removed (`#1358 <https://github.com/ros-controls/ros2_control/pull/1358>`_).
* 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>`_).

hardware_interface
******************
Expand Down

0 comments on commit 3eae727

Please sign in to comment.