tedusar_daf_path_follower.hpp
Go to the documentation of this file.
00001 /*********************************************************************
00002  *
00003  *  Software License Agreement (BSD License)
00004  *
00005  *  Copyright (c) 2014, Peter Lepej,
00006  *                      Faculty of Electrical Engineerign anc Computer Scienece,
00007  *                      University of Maribor
00008  *  All rights reserved.
00009  *
00010  *  Redistribution and use in source and binary forms, with or without
00011  *  modification, are permitted provided that the following conditions
00012  *  are met:
00013  *
00014  *   * Redistributions of source code must retain the above copyright
00015  *     notice, this list of conditions and the following disclaimer.
00016  *   * Redistributions in binary form must reproduce the above
00017  *     copyright notice, this list of conditions and the following
00018  *     disclaimer in the documentation and/or other materials provided
00019  *     with the distribution.
00020  *   * Neither the name of Graz University of Technology nor the names of
00021  *     its contributors may be used to endorse or promote products derived
00022  *     from this software without specific prior written permission.
00023  *
00024  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00026  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00027  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00028  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00029  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00030  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00031  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00034  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00035  *  POSSIBILITY OF SUCH DAMAGE.
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         //for visualization
00091         nav_msgs::Path curr_path;
00092         nav_msgs::Path calc_path;
00093         nav_msgs::Path local_calc_path;
00094 
00095         //actions
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(); //always virtual
00158 
00159         //initialization function
00160         void init();
00161         //geometry calculation calback functions
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         //action server
00173         void executePathCB(const ExecutePathGoalConstPtr &goal);
00174         void check_robot_stability();
00175     };
00176 }
00177 
00178 #endif


tedusar_daf_path_follower
Author(s): Peter Lepej , Johannes Maurer
autogenerated on Mon Oct 6 2014 07:51:50