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
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef COB_COLLISION_VELOCITY_FILTER_H
00051 #define COB_COLLISION_VELOCITY_FILTER_H
00052
00053
00054
00055
00056
00057
00058
00059
00060 #include <ros/ros.h>
00061 #include <XmlRpc.h>
00062
00063 #include <pthread.h>
00064
00065
00066 #include <geometry_msgs/Twist.h>
00067 #include <geometry_msgs/PolygonStamped.h>
00068 #include <geometry_msgs/Polygon.h>
00069 #include <nav_msgs/GridCells.h>
00070
00071 #include <boost/tokenizer.hpp>
00072 #include <boost/foreach.hpp>
00073 #include <boost/algorithm/string.hpp>
00074
00075
00076 #include "cob_footprint_observer/GetFootprint.h"
00077
00078
00079 #include <dynamic_reconfigure/server.h>
00080 #include <cob_collision_velocity_filter/CollisionVelocityFilterConfig.h>
00081
00082
00083 #include "velocity_limited_marker.h"
00084
00090 class CollisionVelocityFilter
00091 {
00092 public:
00093
00097 CollisionVelocityFilter();
00098
00099
00103 ~CollisionVelocityFilter();
00104
00110 void joystickVelocityCB(const geometry_msgs::Twist::ConstPtr &twist);
00111
00116 void obstaclesCB(const nav_msgs::GridCells::ConstPtr &obstacles);
00117
00118
00122 void getFootprintServiceCB(const ros::TimerEvent&);
00123
00129 void dynamicReconfigureCB(const cob_collision_velocity_filter::CollisionVelocityFilterConfig &config,
00130 const uint32_t level);
00131
00132
00134 ros::NodeHandle nh_;
00135
00137 ros::Timer get_footprint_timer_;
00138
00140 ros::Publisher topic_pub_command_;
00141 ros::Publisher topic_pub_relevant_obstacles_;
00142
00144 ros::Subscriber joystick_velocity_sub_, obstacles_sub_;
00145
00147 ros::ServiceClient srv_client_get_footprint_;
00148
00150 dynamic_reconfigure::Server<cob_collision_velocity_filter::CollisionVelocityFilterConfig> dyn_server_;
00151 dynamic_reconfigure::Server<cob_collision_velocity_filter::CollisionVelocityFilterConfig>::CallbackType dynCB_;
00152
00153 private:
00154
00155
00160 void performControllerStep();
00161
00166 void obstacleHandler();
00167
00168
00169
00170
00176 std::vector<geometry_msgs::Point> loadRobotFootprint(ros::NodeHandle node);
00177
00178
00182 double sign(double x);
00183
00189 double getDistance2d(geometry_msgs::Point a, geometry_msgs::Point b);
00190
00197 bool obstacleValid(double x_obstacle, double y_obstacle);
00198
00202 void stopMovement();
00203
00204 pthread_mutex_t m_mutex;
00205
00206
00207 std::string global_frame_, robot_frame_;
00208
00209
00210 geometry_msgs::Vector3 robot_twist_linear_, robot_twist_angular_;
00211 double v_max_, vtheta_max_;
00212 double ax_max_, ay_max_, atheta_max_;
00213
00214
00215 std::vector<geometry_msgs::Point> robot_footprint_;
00216 double footprint_left_, footprint_right_, footprint_front_, footprint_rear_;
00217 double footprint_left_initial_, footprint_right_initial_, footprint_front_initial_, footprint_rear_initial_;
00218 bool costmap_received_;
00219 nav_msgs::GridCells last_costmap_received_, relevant_obstacles_;
00220 double influence_radius_, stop_threshold_, obstacle_damping_dist_, use_circumscribed_threshold_;
00221 double closest_obstacle_dist_, closest_obstacle_angle_;
00222
00223
00224 double last_time_;
00225 double kp_, kv_;
00226 double vx_last_, vy_last_, vtheta_last_;
00227 double virt_mass_;
00228
00229
00230 cob_collision_velocity_filter::VelocityLimitedMarker velocity_limited_marker_;
00231
00232 };
00233
00234 #endif
00235