diff --git a/CHANGELOG.md b/CHANGELOG.md index c0af29f1..4a809b22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Release Versions: - fix(controllers): safety check for predicate publisher access (#238) - fix: remove ABI breaking assignment methods from C++ components and controllers (#240) +- fix(controllers): revert ABI breaking change for control type (#240) ## 5.4.0 diff --git a/source/modulo_controllers/include/modulo_controllers/RobotControllerInterface.hpp b/source/modulo_controllers/include/modulo_controllers/RobotControllerInterface.hpp index 61799c33..f9aa0f18 100644 --- a/source/modulo_controllers/include/modulo_controllers/RobotControllerInterface.hpp +++ b/source/modulo_controllers/include/modulo_controllers/RobotControllerInterface.hpp @@ -133,7 +133,6 @@ class RobotControllerInterface : public ControllerInterface { std::vector joints_;///< The joint names provided by a parameter std::string control_type_; ///< The high-level interface type (position, velocity, acceleration or effort) - bool control_type_fixed_; ///< If true, the control type cannot be changed after bool robot_model_required_;///< If true, check that a robot model is available on configure bool load_geometries_; ///< If true, load geometries from the URDF into the robot model diff --git a/source/modulo_controllers/src/RobotControllerInterface.cpp b/source/modulo_controllers/src/RobotControllerInterface.cpp index cda655ca..5addcc94 100644 --- a/source/modulo_controllers/src/RobotControllerInterface.cpp +++ b/source/modulo_controllers/src/RobotControllerInterface.cpp @@ -21,7 +21,6 @@ RobotControllerInterface::RobotControllerInterface( bool robot_model_required, const std::string& control_type, bool load_geometries) : ControllerInterface(true), control_type_(control_type), - control_type_fixed_(false), robot_model_required_(robot_model_required), load_geometries_(load_geometries), new_joint_command_ready_(false), @@ -145,7 +144,6 @@ rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn RobotC for (const auto& joint : joints_) { add_command_interface(joint, control_type_); } - control_type_fixed_ = true; } auto ft_sensor_name = get_parameter("ft_sensor_name"); @@ -387,7 +385,9 @@ std::string RobotControllerInterface::get_control_type() const { } void RobotControllerInterface::set_control_type(const std::string& control_type) { - if (control_type_fixed_) { + // FIXME: this is a quick solution to prevent adding a new private attribute to the class. + // The joint_state is initialized shortly before the interfaces are added so it can be used as a proxy. + if (joint_state_.get_name() == hardware_name_) { throw std::runtime_error("Control type is fixed and cannot be changed anymore"); } if (!control_type.empty() && interface_map.count(control_type) == 0) {