chain_manager.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014-2015 Fetch Robotics Inc.
3  * Copyright (C) 2013-2014 Unbounded Robotics Inc.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 // Author: Michael Ferguson
19 
20 #ifndef ROBOT_CALIBRATION_CAPTURE_CHAIN_MANAGER_H
21 #define ROBOT_CALIBRATION_CAPTURE_CHAIN_MANAGER_H
22 
23 #include <ros/ros.h>
24 #include <boost/thread/mutex.hpp>
25 #include <sensor_msgs/JointState.h>
27 #include <control_msgs/FollowJointTrajectoryAction.h>
28 #include <moveit_msgs/MoveGroupAction.h>
29 
30 namespace robot_calibration
31 {
32 
38 {
43 
44  // This controls a single chain
46  {
47  ChainController(const std::string& name,
48  const std::string& topic,
49  const std::string& planning_group) :
50  client(topic, true),
52  chain_planning_group(planning_group)
53  {
54  }
55 
56  bool shouldPlan()
57  {
58  return (chain_planning_group != "");
59  }
60 
62  std::string chain_name;
63  std::string chain_planning_group;
64  std::vector<std::string> joint_names;
65  };
66 
67 public:
73  ChainManager(ros::NodeHandle& nh, double wait_time = 15.0);
74 
80  bool moveToState(const sensor_msgs::JointState& state);
81 
85  bool waitToSettle();
86 
90  bool getState(sensor_msgs::JointState* state);
91 
95  std::vector<std::string> getChains();
96 
100  std::vector<std::string> getChainJointNames(const std::string& chain_name);
101 
102  // Mainly for testing
103  std::string getPlanningGroupName(const std::string& chain_name);
104 
105 private:
106  void stateCallback(const sensor_msgs::JointStateConstPtr& msg);
107 
108  trajectory_msgs::JointTrajectoryPoint makePoint(const sensor_msgs::JointState& state,
109  const std::vector<std::string>& joints);
110 
111  // Subscriber for joint_states topic, storage of message
113  boost::mutex state_mutex_;
114  sensor_msgs::JointState state_;
116 
117  // Mechanisms for passing commands to controllers
118  double duration_;
119  std::vector<boost::shared_ptr<ChainController> > controllers_;
121  double velocity_factor_; // scaling factor to slow down move_group plans
122 };
123 
124 } // namespace robot_calibration
125 
126 #endif // ROBOT_CALIBRATION_CAPTURE_CHAIN_MANAGER_H
robot_calibration::ChainManager::moveToState
bool moveToState(const sensor_msgs::JointState &state)
Send commands to all managed joints. The ChainManager automatically figures out which controller to s...
Definition: chain_manager.cpp:157
robot_calibration::ChainManager::ChainController::ChainController
ChainController(const std::string &name, const std::string &topic, const std::string &planning_group)
Definition: chain_manager.h:47
boost::shared_ptr< MoveGroupClient >
robot_calibration::ChainManager::ChainManager
ChainManager(ros::NodeHandle &nh, double wait_time=15.0)
Constructor, sets up chains from ros parameters.
Definition: chain_manager.cpp:25
robot_calibration::ChainManager::velocity_factor_
double velocity_factor_
Definition: chain_manager.h:121
robot_calibration::ChainManager::getState
bool getState(sensor_msgs::JointState *state)
Get the current JointState message.
Definition: chain_manager.cpp:125
robot_calibration::ChainManager::duration_
double duration_
Definition: chain_manager.h:118
ros.h
robot_calibration::ChainManager::ChainController::chain_name
std::string chain_name
Definition: chain_manager.h:62
robot_calibration::ChainManager::subscriber_
ros::Subscriber subscriber_
Definition: chain_manager.h:112
robot_calibration::ChainManager::state_is_valid_
bool state_is_valid_
Definition: chain_manager.h:115
robot_calibration::ChainManager::waitToSettle
bool waitToSettle()
Wait for joints to settle.
Definition: chain_manager.cpp:234
robot_calibration::ChainManager::getChainJointNames
std::vector< std::string > getChainJointNames(const std::string &chain_name)
Get the joint names associated with a chain. Mainly for testing.
Definition: chain_manager.cpp:308
robot_calibration::ChainManager::ChainController::client
TrajectoryClient client
Definition: chain_manager.h:61
actionlib::SimpleActionClient< control_msgs::FollowJointTrajectoryAction >
robot_calibration::ChainManager::ChainController::chain_planning_group
std::string chain_planning_group
Definition: chain_manager.h:63
robot_calibration::ChainManager::stateCallback
void stateCallback(const sensor_msgs::JointStateConstPtr &msg)
Definition: chain_manager.cpp:86
name
std::string name
simple_action_client.h
robot_calibration::ChainManager::getPlanningGroupName
std::string getPlanningGroupName(const std::string &chain_name)
Definition: chain_manager.cpp:320
robot_calibration::ChainManager::ChainController::joint_names
std::vector< std::string > joint_names
Definition: chain_manager.h:64
robot_calibration::ChainManager::TrajectoryClient
actionlib::SimpleActionClient< control_msgs::FollowJointTrajectoryAction > TrajectoryClient
Definition: chain_manager.h:39
robot_calibration::ChainManager::MoveGroupClient
actionlib::SimpleActionClient< moveit_msgs::MoveGroupAction > MoveGroupClient
Definition: chain_manager.h:40
robot_calibration::ChainManager
Manages moving joints to a new pose, determining when they are settled, and returning current joint_s...
Definition: chain_manager.h:37
robot_calibration::ChainManager::MoveGroupClientPtr
boost::shared_ptr< MoveGroupClient > MoveGroupClientPtr
Definition: chain_manager.h:41
robot_calibration::ChainManager::state_mutex_
boost::mutex state_mutex_
Definition: chain_manager.h:113
robot_calibration::ChainManager::makePoint
trajectory_msgs::JointTrajectoryPoint makePoint(const sensor_msgs::JointState &state, const std::vector< std::string > &joints)
Definition: chain_manager.cpp:133
robot_calibration::ChainManager::MoveGroupResultPtr
boost::shared_ptr< const moveit_msgs::MoveGroupResult > MoveGroupResultPtr
Definition: chain_manager.h:42
robot_calibration
Calibration code lives under this namespace.
Definition: base_calibration.h:28
robot_calibration::ChainManager::controllers_
std::vector< boost::shared_ptr< ChainController > > controllers_
Definition: chain_manager.h:119
robot_calibration::ChainManager::ChainController::shouldPlan
bool shouldPlan()
Definition: chain_manager.h:56
robot_calibration::ChainManager::state_
sensor_msgs::JointState state_
Definition: chain_manager.h:114
robot_calibration::ChainManager::getChains
std::vector< std::string > getChains()
Get the names of chains. Mainly for testing.
Definition: chain_manager.cpp:298
ros::NodeHandle
ros::Subscriber
robot_calibration::ChainManager::ChainController
Definition: chain_manager.h:45
robot_calibration::ChainManager::move_group_
MoveGroupClientPtr move_group_
Definition: chain_manager.h:120


robot_calibration
Author(s): Michael Ferguson
autogenerated on Fri Sep 1 2023 02:52:01