ros_plugin_demo
Demonstration of the ROS PlugInLib
 All Data Structures Namespaces Files Functions Variables Pages
path_planner.hpp
Go to the documentation of this file.
1 
5 #ifndef ROS_PLUGIN_DEMO_PATHPLANNER_H_
6 #define ROS_PLUGIN_DEMO_PATHPLANNER_H_
7 
8 #include "ros/ros.h"
9 #include "geometry_msgs/PoseStamped.h"
10 #include "nav_msgs/Path.h"
11 #include "geometry_msgs/Pose2D.h"
12 #include <tf/transform_broadcaster.h>
13 
17 namespace plugin_demo_interface_namespace
18 {
24  {
25  ros::Subscriber getTargetSub;
26  ros::Subscriber getStartSub;
27  ros::Publisher pathPub;
28  ros::Timer sendPathTimer;
30  tf::Transform start_tf;
31  tf::Transform target_tf;
32  tf::TransformBroadcaster tf_br;
37  void getTargetCallback(const geometry_msgs::PoseStamped event);
38 
42  void sendPathCallback(const ros::TimerEvent& event);
43 
47  void getStarttCallback(const geometry_msgs::Pose2D event);
48 
51  void sendPath();
52 
53  protected:
54  bool init;
56  geometry_msgs::PoseStamped start;
57  geometry_msgs::PoseStamped target;
58  nav_msgs::Path current_path;
62  PathPlanner();
63 
69  virtual int onInit(ros::NodeHandle roshandle);
70 
74  virtual int getPath() = 0;
75 
82  void setPose2d(geometry_msgs::PoseStamped *pose3d, double x, double y, double theta);
83 
84  public:
88  void initialize(ros::NodeHandle roshandle);
89 
94  double getYawFromQuat(geometry_msgs::Quaternion quat);
95 
100  void tfFrameFromPoseStamped(geometry_msgs::PoseStamped *pose, tf::Transform *tf_tf);
101 
107  int setPoints(geometry_msgs::Pose2D *start, geometry_msgs::Pose2D *target);
108 
114  int getPoints(geometry_msgs::Pose2D *start, geometry_msgs::Pose2D *target);
115 
116  virtual ~PathPlanner() {}
117  };
118 };
119 #endif //ROS_PLUGIN_DEMO_PATHPLANNER_H_
ros::Timer sendPathTimer
periodic calling of the path publisher
void sendPathCallback(const ros::TimerEvent &event)
call sendPath()
void initialize(ros::NodeHandle roshandle)
Initalize the global variables.
int setPoints(geometry_msgs::Pose2D *start, geometry_msgs::Pose2D *target)
replace the current start and target poses and call getPath()
void getTargetCallback(const geometry_msgs::PoseStamped event)
receives a new target pose and call getPath().
ros::Publisher pathPub
send the path calculated by the plugIn
void getStarttCallback(const geometry_msgs::Pose2D event)
receives a new start pose and call getPath().
virtual int onInit(ros::NodeHandle roshandle)
In this function the plugIn can do some initialisation depending on a ROS NodeHandle.
double getYawFromQuat(geometry_msgs::Quaternion quat)
convert a quaternion into yaw
tf::TransformBroadcaster tf_br
send tf-transforms
void sendPath()
publish current_path and the start_tf and target_tf frames
void tfFrameFromPoseStamped(geometry_msgs::PoseStamped *pose, tf::Transform *tf_tf)
build a tf-frame for a given pose
int getPoints(geometry_msgs::Pose2D *start, geometry_msgs::Pose2D *target)
returns the current start and target poses
ros::Subscriber getStartSub
listen for a new start pose
tf::Transform start_tf
the start tf-frame
geometry_msgs::PoseStamped target
last pose of the path
ros::Subscriber getTargetSub
listen for a new target pose
virtual ~PathPlanner()
Intentionally left empty.
nav_msgs::Path current_path
contain the path
tf::Transform target_tf
the target tf-frame
virtual int getPath()=0
calculate current_path from start and target inside a plugIn.
void setPose2d(geometry_msgs::PoseStamped *pose3d, double x, double y, double theta)
convert a given 2D-Pose into 3D-Stamped-Pose.
geometry_msgs::PoseStamped start
starting pose of the path