Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef tedusar_path_follower_hpp___
00040 #define tedusar_path_follower_hpp___
00041
00042 #include <ros/ros.h>
00043 #include <nav_msgs/Path.h>
00044 #include <geometry_msgs/Twist.h>
00045 #include <nav_msgs/Odometry.h>
00046 #include <sensor_msgs/Imu.h>
00047
00048 #include <tf/transform_listener.h>
00049 #include <visualization_msgs/Marker.h>
00050 #include <tedusar_nav_msgs/ExecutePathAction.h>
00051 #include <actionlib/server/simple_action_server.h>
00052
00053 #define PI 3.14159265
00054
00055 using namespace tedusar_nav_msgs;
00056 using namespace std;
00057 typedef actionlib::SimpleActionServer<ExecutePathAction> ExecutePathActionServer;
00058
00059 namespace tedusar_path_follower
00060 {
00061 class tedusar_path_follower
00062 {
00063 private:
00064
00067 tedusar_path_follower(const tedusar_path_follower &src);
00068
00069 protected:
00070 ros::NodeHandle nh_;
00071 ExecutePathActionServer execute_path_action_server_;
00072 ros::Subscriber path_3d_sub;
00073 ros::Subscriber pose_update_sub;
00074 ros::Subscriber imu_data_sub;
00075 ros::Publisher cmd_vel_pub;
00076 ros::Publisher path_pub;
00077 ros::Publisher local_path_pub;
00078 ros::Publisher marker_pub;
00079
00080 public:
00081 std::string path_topic;
00082 std::string pose_update_topic;
00083 std::string cmd_vel_out;
00084 std::string map_link;
00085 std::string base_link;
00086 std::string imu_topic;
00087 nav_msgs::Odometry odom;
00088 geometry_msgs::Twist cmd;
00089
00090
00091 nav_msgs::Path curr_path;
00092 nav_msgs::Path calc_path;
00093 nav_msgs::Path local_calc_path;
00094
00095
00096 ExecutePathResult action_result;
00097 ExecutePathFeedback feedback;
00098
00099 bool alignment_finished;
00100 bool show_trajectory_planing;
00101 bool move_robot;
00102 bool enable_angle_compensation;
00103 bool enable_ground_compensation;
00104 bool enable_velocity_encrease;
00105
00106 double angle_diff;
00107 double pub_cmd_hz;
00108 double max_lin_speed, min_lin_speed;
00109 double max_rot_speed, min_rot_speed;
00110 double execution_period;
00111 double alignment_angle;
00112 double roll, pitch, yaw;
00113 double update_skip;
00114 double curr_dist;
00115 double rot_dir_opti, rot_vel_dir;
00116 double lin_vel, rot_vel, dist, lin_vel_ref;
00117 double points[50][2];
00118 double max_H, Wid, rad;
00119 double global_goal_tolerance;
00120 double th_po_x, th_po_y, fi_po_x, fi_po_y, se_po_x, se_po_y;
00121 double dirx, diry;
00122 double sideA, sideB, sideC;
00123 double ss, area, tmp_H;
00124 double al_an_diff;
00125 double midX, midY;
00126 double dx, dy;
00127 double distt, pdist;
00128 double mDx, mDy;
00129 double old_pos_x;
00130 double old_pos_y;
00131 double glo_pos_diff_x, glo_pos_diff_y;
00132 double rot_correction_factor;
00133 double imu_roll, imu_pitch, imu_yaw;
00134 double lower_al_angle, upper_al_angle;
00135 double stability_angle;
00136
00137 int co_unchanged, co_points;
00138 int psize, st_point, path_po_lenght;
00139 int err_cont;
00140 int oscilation_rotation;
00141
00142 tf::TransformListener listener;
00143 tf::StampedTransform transform;
00144 tf::Vector3 origin;
00145 tf::Quaternion rotation;
00146 tf::Vector3 axis;
00147 ros::Time now;
00148
00152 tedusar_path_follower(ros::NodeHandle nh);
00153
00157 virtual ~tedusar_path_follower();
00158
00159
00160 void init();
00161
00162 void path_cb(const nav_msgs::Path::ConstPtr& path);
00163 void pose_update(const nav_msgs::Odometry pose);
00164 void imuCallback(const sensor_msgs::ImuConstPtr &imu_msg);
00165 void calculate_cmd();
00166 void calc_local_path();
00167 void calculate_al_rot();
00168 void calc_angel_compensation();
00169 void velocity_increase();
00170 void resetPathFollowing();
00171 void calc_ground_compensation();
00172
00173 void executePathCB(const ExecutePathGoalConstPtr &goal);
00174 void check_robot_stability();
00175 };
00176 }
00177
00178 #endif