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  }
65 
66  std::string getButtonText() const override
67  {
68  return "Auto Add &FollowJointsTrajectory \n Controllers For Each Planning Group";
69  }
70 
71  std::vector<std::string> getAvailableTypes() const override
72  {
73  return { "FollowJointTrajectory", "GripperCommand" };
74  }
75 
76  std::string getDefaultType() const override
77  {
78  return "FollowJointTrajectory";
79  }
80 
82  {
83  public:
84  ActionNamespaceField() : AdditionalControllerField("Action Namespace", "action_ns")
85  {
86  }
87  std::string getDefaultValue(const std::string& controller_type) const override
88  {
89  if (controller_type == "FollowJointTrajectory")
90  {
91  return "follow_joint_trajectory";
92  }
93  else if (controller_type == "GripperCommand")
94  {
95  return "gripper_cmd";
96  }
97  else
98  {
99  return "";
100  }
101  }
102  };
103 
105  {
106  public:
107  DefaultField() : AdditionalControllerField("Default", "default")
108  {
109  }
110  std::string getDefaultValue(const std::string& /*controller_type*/) const override
111  {
112  return "true";
113  }
114  };
115 
117  {
118  FieldPointers fields;
119  fields.push_back(std::make_shared<ActionNamespaceField>());
120  fields.push_back(std::make_shared<DefaultField>());
121  return fields;
122  }
123 };
124 } // namespace controllers
125 } // 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