navigating_jockey.h
Go to the documentation of this file.
00001 /* 
00002  * Base class for navigating jockeys
00003  */
00004 
00005 #ifndef _LAMA_JOCKEYS_NAVIGATING_JOCKEY_H_
00006 #define _LAMA_JOCKEYS_NAVIGATING_JOCKEY_H_
00007 
00008 #include <string>
00009 #include <cmath>
00010 
00011 #include <ros/ros.h>
00012 #include <actionlib/server/simple_action_server.h>
00013 #include <geometry_msgs/Point.h>
00014 #include <geometry_msgs/Pose.h>
00015 #include <geometry_msgs/Twist.h>
00016 
00017 #include <lama_jockeys/jockey.h>
00018 #include <lama_jockeys/NavigateAction.h>
00019 #include <lama_jockeys/NavigateGoal.h>
00020 #include <lama_jockeys/NavigateFeedback.h>
00021 
00022 namespace lama_jockeys
00023 {
00024 
00025 typedef actionlib::SimpleActionServer<lama_jockeys::NavigateAction> NavigateServer;
00026 
00027 class NavigatingJockey : public Jockey
00028 {
00029   public:
00030 
00031     double get_max_goal_distance() {return max_goal_distance_;}
00032     void set_max_goal_distance(double d) {max_goal_distance_ = (d > 0) ? d : 0;}
00033 
00034     double get_max_goal_dtheta() {return max_goal_dtheta_;}
00035     void set_max_goal_dtheta(double d) {max_goal_dtheta_ =  (d > 0) ? d : 0;}
00036 
00037     double get_kp_v() {return kp_v_;}
00038     void set_kp_v(double val) {kp_v_ = (val > 0) ? val : 0;}
00039 
00040     double get_kp_w() {return kp_w_;}
00041     void set_kp_w(double val) {kp_w_ = (val > 0) ? val : 0;}
00042 
00043     double get_min_velocity() {return min_velocity_;}
00044     void set_min_velocity(double val) {min_velocity_ = val;}
00045 
00046     double get_reach_distance() {return reach_distance_;}
00047     void set_reach_distance(double d) {reach_distance_ = (d > 0) ? d : 0;}
00048 
00049   protected:
00050 
00051     NavigatingJockey(const std::string& name);
00052 
00053     // A daugther class must implement functions corresponding to actions
00054     // TRAVERSE, and STOP.
00055     virtual void onTraverse() = 0;
00056     virtual void onStop() = 0;
00057     virtual void onInterrupt();
00058     virtual void onContinue();
00059 
00060     void initAction();
00061 
00062     virtual geometry_msgs::Twist goToGoal(const geometry_msgs::Point& goal);
00063 
00064     void setGoalReached() {goal_reached_ = true;}
00065     void unsetGoalReached() {goal_reached_ = false;}
00066     bool isGoalReached() {return goal_reached_;}
00067 
00068     // NodeHandle instance must be created before this line. Otherwise strange
00069     // error may occur (this is done in Jockey).
00070     NavigateServer server_;
00071     lama_jockeys::NavigateResult result_;
00072     lama_jockeys::NavigateFeedback feedback_;
00073 
00074     // In case of INTERRUPT and CONTINUE, the edge and descritptor attributes
00075     // of current goal are irrelevant.
00076     // This information needs to be saved for use after a CONTINUE action.
00077     lama_jockeys::NavigateGoal goal_;
00078 
00079   private:
00080 
00081     void goalCallback(const lama_jockeys::NavigateGoalConstPtr& goal);
00082     void preemptCallback();
00083 
00084     // Change the visibility to avoid double calls.
00085     using Jockey::interrupt;
00086     using Jockey::resume;
00087 
00088     bool goal_reached_;
00089     double max_goal_distance_;  
00090     double max_goal_dtheta_;  
00091     double kp_v_;  
00092     double kp_w_;  
00093     double min_velocity_;  
00094     double reach_distance_;  
00095 };
00096 
00097 } // namespace lama_jockeys
00098 
00099 #endif // _LAMA_JOCKEYS_NAVIGATING_JOCKEY_H_


jockeys
Author(s): Gaël Ecorchard , Karel Košnar
autogenerated on Sat Jun 8 2019 19:03:15