test_moveit_controller_manager.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2012, Willow Garage, Inc.
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 Willow Garage 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: Ioan Sucan */
36 
37 #pragma once
38 
40 
42 {
44 {
45 public:
47  {
48  }
49 
50  bool sendTrajectory(const moveit_msgs::RobotTrajectory& /*trajectory*/) override
51  {
52  return true;
53  }
54 
55  bool cancelExecution() override
56  {
57  return true;
58  }
59 
60  bool waitForExecution(const ros::Duration& timeout = ros::Duration(0)) override
61  {
62  (void)timeout;
63  return false;
64  }
65 
67  {
69  }
70 };
71 
73 {
74 public:
75  static const int ACTIVE = 1;
76  static const int DEFAULT = 2;
77 
79  {
80  controllers_["right_arm"] = DEFAULT;
81  controllers_["left_arm"] = ACTIVE + DEFAULT;
82  controllers_["arms"] = 0;
83  controllers_["base"] = DEFAULT;
84  controllers_["head"] = 0;
85  controllers_["left_arm_head"] = 0;
86 
87  controller_joints_["right_arm"].push_back("rj1");
88  controller_joints_["right_arm"].push_back("rj2");
89 
90  controller_joints_["left_arm"].push_back("lj1");
91  controller_joints_["left_arm"].push_back("lj2");
92  controller_joints_["left_arm"].push_back("lj3");
93 
94  controller_joints_["arms"].insert(controller_joints_["arms"].end(), controller_joints_["left_arm"].begin(),
95  controller_joints_["left_arm"].end());
96  controller_joints_["arms"].insert(controller_joints_["arms"].end(), controller_joints_["right_arm"].begin(),
97  controller_joints_["right_arm"].end());
98 
99  controller_joints_["base"].push_back("basej");
100  controller_joints_["head"].push_back("headj");
101 
102  controller_joints_["left_arm_head"].insert(controller_joints_["left_arm_head"].end(),
103  controller_joints_["left_arm"].begin(),
104  controller_joints_["left_arm"].end());
105  controller_joints_["left_arm_head"].insert(controller_joints_["left_arm_head"].end(),
106  controller_joints_["head"].begin(), controller_joints_["head"].end());
107  }
108 
109  moveit_controller_manager::MoveItControllerHandlePtr getControllerHandle(const std::string& name) override
110  {
111  return moveit_controller_manager::MoveItControllerHandlePtr(new TestMoveItControllerHandle(name));
112  }
113 
114  void getControllersList(std::vector<std::string>& names) override
115  {
116  names.clear();
117  for (std::map<std::string, int>::const_iterator it = controllers_.begin(); it != controllers_.end(); ++it)
118  names.push_back(it->first);
119  }
120 
121  void getActiveControllers(std::vector<std::string>& names) override
122  {
123  names.clear();
124  for (std::map<std::string, int>::const_iterator it = controllers_.begin(); it != controllers_.end(); ++it)
125  if (it->second & ACTIVE)
126  names.push_back(it->first);
127  }
128 
129  void getControllerJoints(const std::string& name, std::vector<std::string>& joints) override
130  {
131  joints = controller_joints_[name];
132  }
133 
135  getControllerState(const std::string& name) override
136  {
138  state.active_ = controllers_[name] & ACTIVE;
139  state.default_ = false;
140  return state;
141  }
142 
143  bool switchControllers(const std::vector<std::string>& activate, const std::vector<std::string>& deactivate) override
144  {
145  for (const std::string& controller : deactivate)
146  {
147  controllers_[controller] &= ~ACTIVE;
148  std::cout << "Deactivated controller " << controller << std::endl;
149  }
150  for (const std::string& controller : activate)
151  {
152  controllers_[controller] |= ACTIVE;
153  std::cout << "Activated controller " << controller << std::endl;
154  }
155  return true;
156  }
157 
158 protected:
159  std::map<std::string, int> controllers_;
160  std::map<std::string, std::vector<std::string> > controller_joints_;
161 };
162 } // namespace test_moveit_controller_manager
test_moveit_controller_manager::TestMoveItControllerHandle::TestMoveItControllerHandle
TestMoveItControllerHandle(const std::string &name)
Definition: test_moveit_controller_manager.h:110
test_moveit_controller_manager::TestMoveItControllerManager::getControllerHandle
moveit_controller_manager::MoveItControllerHandlePtr getControllerHandle(const std::string &name) override
Definition: test_moveit_controller_manager.h:141
moveit_controller_manager::MoveItControllerHandle::MoveItControllerHandle
MoveItControllerHandle(const std::string &name)
test_moveit_controller_manager::TestMoveItControllerManager::getControllerJoints
void getControllerJoints(const std::string &name, std::vector< std::string > &joints) override
Definition: test_moveit_controller_manager.h:161
test_moveit_controller_manager::TestMoveItControllerHandle
Definition: test_moveit_controller_manager.h:75
test_moveit_controller_manager::TestMoveItControllerManager::DEFAULT
static const int DEFAULT
Definition: test_moveit_controller_manager.h:108
test_moveit_controller_manager::TestMoveItControllerHandle::cancelExecution
bool cancelExecution() override
Definition: test_moveit_controller_manager.h:119
moveit_controller_manager::MoveItControllerManager::ControllerState::active_
bool active_
test_moveit_controller_manager::TestMoveItControllerManager::getActiveControllers
void getActiveControllers(std::vector< std::string > &names) override
Definition: test_moveit_controller_manager.h:153
test_moveit_controller_manager::TestMoveItControllerManager
Definition: test_moveit_controller_manager.h:104
controller_manager.h
test_moveit_controller_manager::TestMoveItControllerManager::controllers_
std::map< std::string, int > controllers_
Definition: test_moveit_controller_manager.h:191
name
std::string name
moveit_controller_manager::ExecutionStatus::SUCCEEDED
SUCCEEDED
test_moveit_controller_manager::TestMoveItControllerManager::controller_joints_
std::map< std::string, std::vector< std::string > > controller_joints_
Definition: test_moveit_controller_manager.h:192
test_moveit_controller_manager::TestMoveItControllerManager::ACTIVE
static const int ACTIVE
Definition: test_moveit_controller_manager.h:107
moveit_controller_manager::MoveItControllerManager
test_moveit_controller_manager::TestMoveItControllerHandle::waitForExecution
bool waitForExecution(const ros::Duration &timeout=ros::Duration(0)) override
Definition: test_moveit_controller_manager.h:124
test_moveit_controller_manager::TestMoveItControllerManager::getControllerState
moveit_controller_manager::MoveItControllerManager::ControllerState getControllerState(const std::string &name) override
Definition: test_moveit_controller_manager.h:167
test_moveit_controller_manager::TestMoveItControllerManager::TestMoveItControllerManager
TestMoveItControllerManager()
Definition: test_moveit_controller_manager.h:110
test_moveit_controller_manager::TestMoveItControllerManager::getControllersList
void getControllersList(std::vector< std::string > &names) override
Definition: test_moveit_controller_manager.h:146
test_moveit_controller_manager
Definition: test_moveit_controller_manager.h:41
test_moveit_controller_manager::TestMoveItControllerHandle::sendTrajectory
bool sendTrajectory(const moveit_msgs::RobotTrajectory &) override
Definition: test_moveit_controller_manager.h:114
test_moveit_controller_manager::TestMoveItControllerManager::switchControllers
bool switchControllers(const std::vector< std::string > &activate, const std::vector< std::string > &deactivate) override
Definition: test_moveit_controller_manager.h:175
ros::Duration
moveit_controller_manager::ExecutionStatus
test_moveit_controller_manager::TestMoveItControllerHandle::getLastExecutionStatus
moveit_controller_manager::ExecutionStatus getLastExecutionStatus() override
Definition: test_moveit_controller_manager.h:130
moveit_controller_manager::MoveItControllerManager::ControllerState::default_
bool default_
moveit_controller_manager::MoveItControllerHandle


planning
Author(s): Ioan Sucan , Sachin Chitta
autogenerated on Thu Nov 21 2024 03:24:18