posvel_gripper_controller.h
Go to the documentation of this file.
00001 #ifndef ROBOTICAN_CONTROLLERS_POSVEL_GRIPPER_CONTROLLER_H
00002 #define ROBOTICAN_CONTROLLERS_POSVEL_GRIPPER_CONTROLLER_H
00003 
00004 #include <pluginlib/class_list_macros.h>
00005 #include <control_msgs/GripperCommandAction.h>
00006 #include <controller_interface/controller.h>
00007 #include <realtime_tools/realtime_buffer.h>
00008 #include <realtime_tools/realtime_server_goal_handle.h>
00009 #include <hardware_interface/posvel_command_interface.h>
00010 #include <ros/node_handle.h>
00011 
00012 #include <actionlib/server/action_server.h>
00013 
00014 
00015 namespace gripper_controllers{
00016 struct Commands
00017 {
00018     double gap; // Last commanded position
00019     double max_effort; // Max allowed effort
00020 };
00021 class PosVelGripperController: public controller_interface::Controller<hardware_interface::PosVelJointInterface>
00022 {
00023 private:
00024 
00025     typedef actionlib::ActionServer<control_msgs::GripperCommandAction>                         ActionServer;
00026     typedef boost::shared_ptr<ActionServer>                                                     ActionServerPtr;
00027 typedef ActionServer::GoalHandle                                                            GoalHandle;
00028     typedef realtime_tools::RealtimeServerGoalHandle<control_msgs::GripperCommandAction>        RealtimeGoalHandle;
00029 typedef boost::shared_ptr<RealtimeGoalHandle>                                               RealtimeGoalHandlePtr;
00030 
00031   hardware_interface::PosVelJointHandle leftjoint;
00032   hardware_interface::PosVelJointHandle rightjoint;
00033 
00034   ActionServerPtr    action_server_;
00035   RealtimeGoalHandlePtr                        rt_active_goal_;     
00036   Commands command_struct_,command_struct_rt_; // pre-allocated memory that is re-used to set the realtime buffer
00037  realtime_tools::RealtimeBuffer<Commands> command_;
00038 control_msgs::GripperCommandResultPtr        pre_alloc_result_;
00039  ros::Time last_movement_time_;
00040  ros::Timer         goal_handle_timer_;
00041  ros::Duration action_monitor_period_;
00042 ros::NodeHandle    controller_nh_;
00043 double stall_timeout_, stall_velocity_threshold_;                 
00044 double default_max_effort_;                                       
00045 double goal_tolerance_;
00046 double _lastGap;
00047 
00048 double joints_vel_;
00049 
00050 public:
00051 
00052    bool init(hardware_interface::PosVelJointInterface* hw, ros::NodeHandle& root_nh, ros::NodeHandle& controller_nh);
00053    void starting(const ros::Time& time);
00054    void update(const ros::Time& time, const ros::Duration& period);
00055    void stopping();
00056 
00057  void goalCB(GoalHandle gh);
00058  void cancelCB(GoalHandle gh);
00059  void preemptActiveGoal();
00060  void setHoldPosition();
00061  double gap2Pos(double gap);
00062  double pos2Gap(double pos);
00063  void checkForSuccess(const ros::Time &time, double error_position, double current_position, double current_velocity,
00064                       double current_effort,double max_effort);
00065 
00066 };
00067 
00068 PLUGINLIB_EXPORT_CLASS(gripper_controllers::PosVelGripperController, controller_interface::ControllerBase);
00069 
00070 }
00071 #endif


robotican_controllers
Author(s):
autogenerated on Fri Oct 27 2017 03:02:40