Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*********************************************************************
* Software License Agreement (BSD License)
* Software License Agreement (BSD License)
*
* Copyright (c) 2022, Metro Robots
Expand Down Expand Up @@ -32,12 +33,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/


/* Author: David V. Lu!! */


#include <moveit_setup_controllers/controllers_config.hpp>
#include <moveit_setup_framework/data/srdf_config.hpp>
#include <moveit_setup_framework/data_warehouse.hpp>


namespace moveit_setup
{
namespace controllers
Expand All @@ -52,26 +56,32 @@ bool ControllersConfig::addController(const std::string& name, const std::string
return addController(controller);
}


bool ControllersConfig::addController(const ControllerInfo& new_controller)
{
// Used for holding our search results
ControllerInfo* searched_ros_controller = nullptr;


// Find if there is an existing controller with the same name
searched_ros_controller = findControllerByName(new_controller.name_);

if (searched_ros_controller && searched_ros_controller->type_ == new_controller.type_)

if (searched_ros_controller)
return false;


controllers_.push_back(new_controller);
return true;
}


ControllerInfo* ControllersConfig::findControllerByName(const std::string& controller_name)
{
// Find the Controller we are editing based on the Controller name string
ControllerInfo* searched_ros_controller = nullptr; // used for holding our search results


for (ControllerInfo& ros_control_config : controllers_)
{
if (ros_control_config.name_ == controller_name) // string match
Expand All @@ -81,9 +91,11 @@ ControllerInfo* ControllersConfig::findControllerByName(const std::string& contr
}
}


return searched_ros_controller;
}


bool ControllersConfig::deleteController(const std::string& controller_name)
{
for (std::vector<ControllerInfo>::iterator controller_it = controllers_.begin(); controller_it != controllers_.end();
Expand Down