Skip to content

Commit

Permalink
Fix memory leak in the ros2_control (#2033)
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor authored Feb 7, 2025
1 parent dab91b1 commit 7406bdc
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 45 deletions.
4 changes: 2 additions & 2 deletions hardware_interface/include/hardware_interface/actuator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ class Actuator final
const std::vector<std::string> & start_interfaces,
const std::vector<std::string> & stop_interfaces);

std::string get_name() const;
const std::string & get_name() const;

std::string get_group_name() const;
const std::string & get_group_name() const;

const rclcpp_lifecycle::State & get_lifecycle_state() const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,13 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod
/**
* \return name.
*/
virtual std::string get_name() const { return info_.name; }
const std::string & get_name() const { return info_.name; }

/// Get name of the actuator hardware group to which it belongs to.
/**
* \return group name.
*/
virtual std::string get_group_name() const { return info_.group; }
const std::string & get_group_name() const { return info_.group; }

/// Get life-cycle state of the actuator hardware.
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ struct InterfaceDescription
*/
std::string interface_name;

std::string get_prefix_name() const { return prefix_name; }
const std::string & get_prefix_name() const { return prefix_name; }

std::string get_interface_name() const { return interface_info.name; }
const std::string & get_interface_name() const { return interface_info.name; }

std::string get_name() const { return interface_name; }
const std::string & get_name() const { return interface_name; }
};

/// This structure stores information about hardware defined in a robot's URDF.
Expand Down
4 changes: 2 additions & 2 deletions hardware_interface/include/hardware_interface/sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class Sensor final

std::vector<StateInterface::ConstSharedPtr> export_state_interfaces();

std::string get_name() const;
const std::string & get_name() const;

std::string get_group_name() const;
const std::string & get_group_name() const;

const rclcpp_lifecycle::State & get_lifecycle_state() const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,13 @@ class SensorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI
/**
* \return name.
*/
virtual std::string get_name() const { return info_.name; }
const std::string & get_name() const { return info_.name; }

/// Get name of the actuator hardware group to which it belongs to.
/**
* \return group name.
*/
virtual std::string get_group_name() const { return info_.group; }
const std::string & get_group_name() const { return info_.group; }

/// Get life-cycle state of the actuator hardware.
/**
Expand Down
4 changes: 2 additions & 2 deletions hardware_interface/include/hardware_interface/system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ class System final
const std::vector<std::string> & start_interfaces,
const std::vector<std::string> & stop_interfaces);

std::string get_name() const;
const std::string & get_name() const;

std::string get_group_name() const;
const std::string & get_group_name() const;

const rclcpp_lifecycle::State & get_lifecycle_state() const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,13 @@ class SystemInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI
/**
* \return name.
*/
virtual std::string get_name() const { return info_.name; }
const std::string & get_name() const { return info_.name; }

/// Get name of the actuator hardware group to which it belongs to.
/**
* \return group name.
*/
virtual std::string get_group_name() const { return info_.group; }
const std::string & get_group_name() const { return info_.group; }

/// Get life-cycle state of the actuator hardware.
/**
Expand Down
4 changes: 2 additions & 2 deletions hardware_interface/src/actuator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ return_type Actuator::perform_command_mode_switch(
return impl_->perform_command_mode_switch(start_interfaces, stop_interfaces);
}

std::string Actuator::get_name() const { return impl_->get_name(); }
const std::string & Actuator::get_name() const { return impl_->get_name(); }

std::string Actuator::get_group_name() const { return impl_->get_group_name(); }
const std::string & Actuator::get_group_name() const { return impl_->get_group_name(); }

const rclcpp_lifecycle::State & Actuator::get_lifecycle_state() const
{
Expand Down
4 changes: 2 additions & 2 deletions hardware_interface/src/sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ std::vector<StateInterface::ConstSharedPtr> Sensor::export_state_interfaces()
// END: for backward compatibility
}

std::string Sensor::get_name() const { return impl_->get_name(); }
const std::string & Sensor::get_name() const { return impl_->get_name(); }

std::string Sensor::get_group_name() const { return impl_->get_group_name(); }
const std::string & Sensor::get_group_name() const { return impl_->get_group_name(); }

const rclcpp_lifecycle::State & Sensor::get_lifecycle_state() const
{
Expand Down
4 changes: 2 additions & 2 deletions hardware_interface/src/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ return_type System::perform_command_mode_switch(
return impl_->perform_command_mode_switch(start_interfaces, stop_interfaces);
}

std::string System::get_name() const { return impl_->get_name(); }
const std::string & System::get_name() const { return impl_->get_name(); }

std::string System::get_group_name() const { return impl_->get_group_name(); }
const std::string & System::get_group_name() const { return impl_->get_group_name(); }

const rclcpp_lifecycle::State & System::get_lifecycle_state() const
{
Expand Down
16 changes: 0 additions & 16 deletions hardware_interface/test/test_component_interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ class DummyActuator : public hardware_interface::ActuatorInterface
return command_interfaces;
}

std::string get_name() const override { return "DummyActuator"; }

hardware_interface::return_type read(
const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/) override
{
Expand Down Expand Up @@ -193,8 +191,6 @@ class DummyActuatorDefault : public hardware_interface::ActuatorInterface
return CallbackReturn::SUCCESS;
}

std::string get_name() const override { return "DummyActuatorDefault"; }

hardware_interface::return_type read(
const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/) override
{
Expand Down Expand Up @@ -276,8 +272,6 @@ class DummySensor : public hardware_interface::SensorInterface
return state_interfaces;
}

std::string get_name() const override { return "DummySensor"; }

hardware_interface::return_type read(
const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/) override
{
Expand Down Expand Up @@ -337,8 +331,6 @@ class DummySensorDefault : public hardware_interface::SensorInterface
return CallbackReturn::SUCCESS;
}

std::string get_name() const override { return "DummySensorDefault"; }

hardware_interface::return_type read(
const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/) override
{
Expand Down Expand Up @@ -397,8 +389,6 @@ class DummySensorJointDefault : public hardware_interface::SensorInterface
return CallbackReturn::SUCCESS;
}

std::string get_name() const override { return "DummySensorJointDefault"; }

hardware_interface::return_type read(
const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/) override
{
Expand Down Expand Up @@ -502,8 +492,6 @@ class DummySystem : public hardware_interface::SystemInterface
return command_interfaces;
}

std::string get_name() const override { return "DummySystem"; }

hardware_interface::return_type read(
const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/) override
{
Expand Down Expand Up @@ -608,8 +596,6 @@ class DummySystemDefault : public hardware_interface::SystemInterface
return CallbackReturn::SUCCESS;
}

std::string get_name() const override { return "DummySystemDefault"; }

hardware_interface::return_type read(
const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/) override
{
Expand Down Expand Up @@ -687,8 +673,6 @@ class DummySystemPreparePerform : public hardware_interface::SystemInterface
return CallbackReturn::SUCCESS;
}

std::string get_name() const override { return "DummySystemPreparePerform"; }

hardware_interface::return_type read(
const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/) override
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface

class DummyActuatorDefault : public hardware_interface::ActuatorInterface
{
std::string get_name() const override { return "DummyActuatorDefault"; }

std::vector<hardware_interface::InterfaceDescription>
export_unlisted_state_interface_descriptions() override
{
Expand Down Expand Up @@ -95,8 +93,6 @@ class DummyActuatorDefault : public hardware_interface::ActuatorInterface

class DummySensorDefault : public hardware_interface::SensorInterface
{
std::string get_name() const override { return "DummySensorDefault"; }

std::vector<hardware_interface::InterfaceDescription>
export_unlisted_state_interface_descriptions() override
{
Expand All @@ -118,8 +114,6 @@ class DummySensorDefault : public hardware_interface::SensorInterface

class DummySystemDefault : public hardware_interface::SystemInterface
{
std::string get_name() const override { return "DummySystemDefault"; }

std::vector<hardware_interface::InterfaceDescription>
export_unlisted_state_interface_descriptions() override
{
Expand Down
2 changes: 0 additions & 2 deletions hardware_interface_testing/test/test_resource_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,6 @@ class ExternalComponent : public hardware_interface::ActuatorInterface
return command_interfaces;
}

std::string get_name() const override { return "ExternalComponent"; }

hardware_interface::return_type read(
const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/) override
{
Expand Down

0 comments on commit 7406bdc

Please sign in to comment.