moveit2
The MoveIt Motion Planning Framework for ROS 2.
moveit_controllers.hpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2021, PickNik Robotics
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of PickNik Robotics nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: David V. Lu!! */
36 
37 #pragma once
38 
41 
42 namespace moveit_setup
43 {
44 namespace controllers
45 {
47 {
48 public:
49  std::string getName() const override
50  {
51  return "MoveIt Controllers";
52  }
53 
54  void onInit() override
55  {
56  config_data_->registerType("moveit_controllers", "moveit_setup::controllers::MoveItControllersConfig");
57  srdf_config_ = config_data_->get<SRDFConfig>("srdf");
58  controllers_config_ = config_data_->get<MoveItControllersConfig>("moveit_controllers");
59  }
60 
61  std::string getInstructions() const override
62  {
63  return "Configure controllers to be used in executing trajectories with MoveIt (hardware or simulation)."
64  "hardware";
65  }
66 
67  std::string getButtonText() const override
68  {
69  return "Auto Add &FollowJointsTrajectory \n Controllers For Each Planning Group";
70  }
71 
72  std::vector<std::string> getAvailableTypes() const override
73  {
74  return { "FollowJointTrajectory", "GripperCommand" };
75  }
76 
77  std::string getDefaultType() const override
78  {
79  return "FollowJointTrajectory";
80  }
81 
83  {
84  public:
85  ActionNamespaceField() : AdditionalControllerField("Action Namespace", "action_ns")
86  {
87  }
88  std::string getDefaultValue(const std::string& controller_type) const override
89  {
90  if (controller_type == "FollowJointTrajectory")
91  {
92  return "follow_joint_trajectory";
93  }
94  else if (controller_type == "GripperCommand")
95  {
96  return "gripper_cmd";
97  }
98  else
99  {
100  return "";
101  }
102  }
103  };
104 
106  {
107  public:
108  DefaultField() : AdditionalControllerField("Default", "default")
109  {
110  }
111  std::string getDefaultValue(const std::string& /*controller_type*/) const override
112  {
113  return "true";
114  }
115  };
116 
118  {
119  FieldPointers fields;
120  fields.push_back(std::make_shared<ActionNamespaceField>());
121  fields.push_back(std::make_shared<DefaultField>());
122  return fields;
123  }
124 };
125 } // namespace controllers
126 } // namespace moveit_setup
DataWarehousePtr config_data_
Definition: setup_step.hpp:97
Structure for containing information about types of additional parameters.
Definition: controllers.hpp:50
std::shared_ptr< SRDFConfig > srdf_config_
std::shared_ptr< ControllersConfig > controllers_config_
std::string getDefaultValue(const std::string &controller_type) const override
Overridable method for changing the default value based on the controller_type.
std::string getDefaultValue(const std::string &) const override
Overridable method for changing the default value based on the controller_type.
std::string getName() const override
Returns the name of the setup step.
void onInit() override
Overridable initialization method.
FieldPointers getAdditionalControllerFields() const override
Define the types of controller fields for the specific types of controllers.
std::vector< std::string > getAvailableTypes() const override
std::vector< std::shared_ptr< AdditionalControllerField > > FieldPointers
Convenience alias.
Definition: controllers.hpp:77