simple_exploration_controller.cpp
Go to the documentation of this file.
1 //=================================================================================================
2 // Copyright (c) 2012, Stefan Kohlbrecher, TU Darmstadt
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 met:
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 // * Neither the name of the Simulation, Systems Optimization and Robotics
13 // group, TU Darmstadt nor the names of its contributors may be used to
14 // endorse or promote products derived from this software without
15 // specific prior written permission.
16 
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //=================================================================================================
28 
29 
30 #include <ros/ros.h>
32 #include <hector_nav_msgs/GetRobotTrajectory.h>
33 
35 {
36 public:
38  {
39  ros::NodeHandle nh;
40 
41  exploration_plan_service_client_ = nh.serviceClient<hector_nav_msgs::GetRobotTrajectory>("get_exploration_path");
42 
44 
47 
48  vel_pub_ = nh.advertise<geometry_msgs::Twist>("cmd_vel", 10);
49 
50  }
51 
53  {
54  hector_nav_msgs::GetRobotTrajectory srv_exploration_plan;
55 
56  if (exploration_plan_service_client_.call(srv_exploration_plan)){
57  ROS_INFO("Generated exploration path with %u poses", (unsigned int)srv_exploration_plan.response.trajectory.poses.size());
58  path_follower_.setPlan(srv_exploration_plan.response.trajectory.poses);
59  }else{
60  ROS_WARN("Service call for exploration service failed");
61  }
62  }
63 
65  {
66  geometry_msgs::Twist twist;
68  vel_pub_.publish(twist);
69  }
70 
71 
72 protected:
75 
77 
79 
82 };
83 
84 int main(int argc, char **argv) {
85  ros::init(argc, argv, ROS_PACKAGE_NAME);
86 
88 
89  ros::spin();
90 
91  return 0;
92 }
pose_follower::HectorPathFollower path_follower_
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
bool setPlan(const std::vector< geometry_msgs::PoseStamped > &global_plan)
void timerCmdVelGeneration(const ros::TimerEvent &e)
void publish(const boost::shared_ptr< M > &message) const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
#define ROS_WARN(...)
ROSCPP_DECL void spin(Spinner &spinner)
#define ROS_INFO(...)
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void initialize(tf::TransformListener *tf)
bool computeVelocityCommands(geometry_msgs::Twist &cmd_vel)
void timerPlanExploration(const ros::TimerEvent &e)
int main(int argc, char **argv)


hector_exploration_controller
Author(s):
autogenerated on Mon Jun 10 2019 13:34:51