gripper_action_controller.h
Go to the documentation of this file.
1 // Copyright (C) 2014, SRI International
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright notice,
7 // this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name of SRI International nor the names of its
12 // contributors may be used to endorse or promote products derived from
13 // this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 // POSSIBILITY OF SUCH DAMAGE.
27 
29 
30 #pragma once
31 
32 
33 // C++ standard
34 #include <cassert>
35 #include <stdexcept>
36 #include <string>
37 #include <memory>
38 
39 // ROS
40 #include <ros/node_handle.h>
41 
42 // ROS messages
43 #include <control_msgs/GripperCommandAction.h>
44 
45 // actionlib
47 
48 // ros_controls
54 
55 // Project
57 
59 {
60 
67 template <class HardwareInterface>
69 {
70 public:
71 
75  struct Commands
76  {
77  double position_; // Last commanded position
78  double max_effort_; // Max allowed effort
79  };
80 
82 
85  bool init(HardwareInterface* hw, ros::NodeHandle& root_nh, ros::NodeHandle& controller_nh);
86  /*\}*/
87 
91  void starting(const ros::Time& time);
92 
94  void stopping(const ros::Time& time);
95 
96  void update(const ros::Time& time, const ros::Duration& period);
97  /*\}*/
98 
100  Commands command_struct_, command_struct_rt_; // pre-allocated memory that is re-used to set the realtime buffer
101 
102 private:
103 
105  typedef std::shared_ptr<ActionServer> ActionServerPtr;
109 
111 
113 
114  bool verbose_;
115  std::string name_;
117  std::string joint_name_;
118 
120 
122  control_msgs::GripperCommandResultPtr pre_alloc_result_;
123 
125 
126  // ROS API
129 
131 
132  void goalCB(GoalHandle gh);
133  void cancelCB(GoalHandle gh);
134  void preemptActiveGoal();
135  void setHoldPosition(const ros::Time& time);
136 
139 
146  void checkForSuccess(const ros::Time& time, double error_position, double current_position, double current_velocity);
147 
148 };
149 
150 } // namespace
151 
demangle_symbol.h
realtime_tools::RealtimeBuffer
gripper_action_controller::GripperActionController::RealtimeGoalHandlePtr
boost::shared_ptr< RealtimeGoalHandle > RealtimeGoalHandlePtr
Definition: gripper_action_controller.h:108
gripper_action_controller::GripperActionController::ActionServer
actionlib::ActionServer< control_msgs::GripperCommandAction > ActionServer
Definition: gripper_action_controller.h:104
gripper_action_controller::GripperActionController::command_struct_rt_
Commands command_struct_rt_
Definition: gripper_action_controller.h:100
gripper_action_controller::GripperActionController::GripperActionController
GripperActionController()
Definition: gripper_action_controller_impl.h:129
realtime_server_goal_handle.h
node_handle.h
gripper_action_controller
Definition: gripper_action_controller.h:58
gripper_action_controller::GripperActionController::starting
void starting(const ros::Time &time)
Holds the current position.
Definition: gripper_action_controller_impl.h:93
gripper_action_controller::GripperActionController::pre_alloc_result_
control_msgs::GripperCommandResultPtr pre_alloc_result_
Definition: gripper_action_controller.h:122
gripper_action_controller::GripperActionController::stopping
void stopping(const ros::Time &time)
Cancels the active action goal, if any.
Definition: gripper_action_controller_impl.h:106
boost::shared_ptr< RealtimeGoalHandle >
actionlib::ServerGoalHandle
actionlib::ActionServer
gripper_action_controller::GripperActionController::Commands::position_
double position_
Definition: gripper_action_controller.h:77
gripper_action_controller::GripperActionController::cancelCB
void cancelCB(GoalHandle gh)
Definition: gripper_action_controller_impl.h:286
realtime_buffer.h
gripper_action_controller::GripperActionController::command_struct_
Commands command_struct_
Definition: gripper_action_controller.h:100
gripper_action_controller::GripperActionController::hw_iface_adapter_
HwIfaceAdapter hw_iface_adapter_
Adapts desired goal state to HW interface.
Definition: gripper_action_controller.h:119
gripper_action_controller::GripperActionController::rt_active_goal_
RealtimeGoalHandlePtr rt_active_goal_
Currently active action goal, if any.
Definition: gripper_action_controller.h:121
gripper_action_controller::GripperActionController::action_monitor_period_
ros::Duration action_monitor_period_
Definition: gripper_action_controller.h:124
controller_interface::Controller
gripper_action_controller::GripperActionController::action_server_
ActionServerPtr action_server_
Definition: gripper_action_controller.h:128
gripper_action_controller::GripperActionController::verbose_
bool verbose_
Hard coded verbose flag to help in debugging.
Definition: gripper_action_controller.h:114
gripper_action_controller::GripperActionController::RealtimeGoalHandle
realtime_tools::RealtimeServerGoalHandle< control_msgs::GripperCommandAction > RealtimeGoalHandle
Definition: gripper_action_controller.h:107
gripper_action_controller_impl.h
gripper_action_controller::GripperActionController::checkForSuccess
void checkForSuccess(const ros::Time &time, double error_position, double current_position, double current_velocity)
Check for success and publish appropriate result and feedback.
Definition: gripper_action_controller_impl.h:316
gripper_action_controller::GripperActionController::setHoldPosition
void setHoldPosition(const ros::Time &time)
Definition: gripper_action_controller_impl.h:307
controller.h
joint_command_interface.h
gripper_action_controller::GripperActionController::controller_nh_
ros::NodeHandle controller_nh_
Definition: gripper_action_controller.h:127
gripper_action_controller::GripperActionController::preemptActiveGoal
void preemptActiveGoal()
Definition: gripper_action_controller_impl.h:113
gripper_action_controller::GripperActionController::name_
std::string name_
Controller name.
Definition: gripper_action_controller.h:115
gripper_action_controller::GripperActionController::goal_tolerance_
double goal_tolerance_
Definition: gripper_action_controller.h:142
gripper_action_controller::GripperActionController::Commands::max_effort_
double max_effort_
Definition: gripper_action_controller.h:78
gripper_action_controller::GripperActionController::update_hold_position_
bool update_hold_position_
Definition: gripper_action_controller.h:112
gripper_action_controller::GripperActionController::default_max_effort_
double default_max_effort_
Max allowed effort.
Definition: gripper_action_controller.h:141
action_server.h
gripper_action_controller::GripperActionController::joint_
hardware_interface::JointHandle joint_
Handles to controlled joints.
Definition: gripper_action_controller.h:116
realtime_tools::RealtimeServerGoalHandle
hardware_interface::JointHandle
ros::Time
HardwareInterfaceAdapter
Helper class to simplify integrating the GripperActionController with different hardware interfaces.
Definition: hardware_interface_adapter.h:53
gripper_action_controller::GripperActionController::GoalHandle
ActionServer::GoalHandle GoalHandle
Definition: gripper_action_controller.h:106
gripper_action_controller::GripperActionController::init
bool init(HardwareInterface *hw, ros::NodeHandle &root_nh, ros::NodeHandle &controller_nh)
Definition: gripper_action_controller_impl.h:134
gripper_action_controller::GripperActionController
Controller for executing a gripper command action for simple single-dof grippers.
Definition: gripper_action_controller.h:68
gripper_action_controller::GripperActionController::command_
realtime_tools::RealtimeBuffer< Commands > command_
Definition: gripper_action_controller.h:99
gripper_action_controller::GripperActionController::goal_handle_timer_
ros::Timer goal_handle_timer_
Definition: gripper_action_controller.h:130
gripper_action_controller::GripperActionController::stall_timeout_
double stall_timeout_
Definition: gripper_action_controller.h:140
gripper_action_controller::GripperActionController::Commands
Store position and max effort in struct to allow easier realtime buffer usage.
Definition: gripper_action_controller.h:75
gripper_action_controller::GripperActionController::last_movement_time_
ros::Time last_movement_time_
Store stall time.
Definition: gripper_action_controller.h:137
gripper_action_controller::GripperActionController::HwIfaceAdapter
HardwareInterfaceAdapter< HardwareInterface > HwIfaceAdapter
Definition: gripper_action_controller.h:110
hardware_interface_adapter.h
gripper_action_controller::GripperActionController::update
void update(const ros::Time &time, const ros::Duration &period)
Definition: gripper_action_controller_impl.h:225
gripper_action_controller::GripperActionController::stall_velocity_threshold_
double stall_velocity_threshold_
Stall related parameters.
Definition: gripper_action_controller.h:140
ros::Duration
gripper_action_controller::GripperActionController::ActionServerPtr
std::shared_ptr< ActionServer > ActionServerPtr
Definition: gripper_action_controller.h:105
ros::Timer
gripper_action_controller::GripperActionController::computed_command_
double computed_command_
Computed command.
Definition: gripper_action_controller.h:138
gripper_action_controller::GripperActionController::goalCB
void goalCB(GoalHandle gh)
Definition: gripper_action_controller_impl.h:245
gripper_action_controller::GripperActionController::joint_name_
std::string joint_name_
Controlled joint names.
Definition: gripper_action_controller.h:117
ros::NodeHandle


gripper_action_controller
Author(s): Sachin Chitta
autogenerated on Fri May 24 2024 02:41:17