replanner.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, The Regents of the University of California (Regents).
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following
14  * disclaimer in the documentation and/or other materials provided
15  * with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * Please contact the author(s) of this library if you have any questions.
34  * Authors: David Fridovich-Keil ( dfk@eecs.berkeley.edu )
35  */
36 
38 //
39 // Defines the Replanner class, which listens for replanning requests,
40 // makes the appropriate service calls, and re-sends the service response
41 // back on the appropriate topic.
42 //
43 // NOTE! This class exists because the Planner interface is service-based,
44 // rather than pub/sub-based, and the PlannerManager cannot afford to wait for
45 // the service calls to finish (i.e. for the planner to compute) before
46 // sending the next planner reference state.
47 //
49 
50 #ifndef FASTRACK_PLANNING_REPLANNER_H
51 #define FASTRACK_PLANNING_REPLANNER_H
52 
54 #include <fastrack/utils/types.h>
56 
57 #include <fastrack_msgs/ReplanRequest.h>
58 #include <fastrack_msgs/Trajectory.h>
59 #include <fastrack_srvs/Replan.h>
60 #include <fastrack_srvs/ReplanRequest.h>
61 #include <fastrack_srvs/ReplanResponse.h>
62 
63 #include <ros/ros.h>
64 
65 namespace fastrack {
66 namespace planning {
67 
68 using trajectory::Trajectory;
69 
70 class Replanner : private Uncopyable {
71 public:
73  explicit Replanner()
74  : initialized_(false) {}
75 
76  // Initialize this class with all parameters and callbacks.
77  bool Initialize(const ros::NodeHandle& n);
78 
79 private:
80  // Load parameters and register callbacks.
81  bool LoadParameters(const ros::NodeHandle& n);
82  bool RegisterCallbacks(const ros::NodeHandle& n);
83 
84  // Callback for processing replanning requests.
86  const fastrack_msgs::ReplanRequest::ConstPtr& msg);
87 
88  // Publishers/subscribers and related topics.
89  ros::Publisher traj_pub_;
90  ros::Subscriber replan_request_sub_;
91 
92  std::string replan_request_topic_;
93  std::string traj_topic_;
94 
95  // Services.
96  ros::ServiceClient replan_srv_;
97  std::string replan_srv_name_;
98 
99  // Naming and initialization.
100  std::string name_;
102 };
103 
104 } //\namespace planning
105 } //\namespace fastrack
106 
107 #endif
ros::ServiceClient replan_srv_
Definition: replanner.h:96
ros::Publisher traj_pub_
Definition: replanner.h:89
void ReplanRequestCallback(const fastrack_msgs::ReplanRequest::ConstPtr &msg)
Definition: replanner.cpp:56
bool LoadParameters(const ros::NodeHandle &n)
Definition: replanner.cpp:98
bool Initialize(const ros::NodeHandle &n)
Definition: replanner.cpp:78
Definition: box.h:53
std::string replan_request_topic_
Definition: replanner.h:92
bool RegisterCallbacks(const ros::NodeHandle &n)
Definition: replanner.cpp:112
ros::Subscriber replan_request_sub_
Definition: replanner.h:90


fastrack
Author(s): David Fridovich-Keil
autogenerated on Mon Aug 3 2020 21:28:37