Flatland
service_manager.h
1 /*
2  * ______ __ __ __
3  * /\ _ \ __ /\ \/\ \ /\ \__
4  * \ \ \L\ \ __ __ /\_\ \_\ \ \ \____ ___\ \ ,_\ ____
5  * \ \ __ \/\ \/\ \\/\ \ /'_` \ \ '__`\ / __`\ \ \/ /',__\
6  * \ \ \/\ \ \ \_/ |\ \ \/\ \L\ \ \ \L\ \/\ \L\ \ \ \_/\__, `\
7  * \ \_\ \_\ \___/ \ \_\ \___,_\ \_,__/\ \____/\ \__\/\____/
8  * \/_/\/_/\/__/ \/_/\/__,_ /\/___/ \/___/ \/__/\/___/
9  * @copyright Copyright 2017 Avidbots Corp.
10  * @name model_spawner.h
11  * @brief Definition for model spawner
12  * @author Chunshang Li
13  *
14  * Software License Agreement (BSD License)
15  *
16  * Copyright (c) 2017, Avidbots Corp.
17  * All rights reserved.
18  *
19  * Redistribution and use in source and binary forms, with or without
20  * modification, are permitted provided that the following conditions
21  * are met:
22  *
23  * * Redistributions of source code must retain the above copyright
24  * notice, this list of conditions and the following disclaimer.
25  * * Redistributions in binary form must reproduce the above
26  * copyright notice, this list of conditions and the following
27  * disclaimer in the documentation and/or other materials provided
28  * with the distribution.
29  * * Neither the name of the Avidbots Corp. nor the names of its
30  * contributors may be used to endorse or promote products derived
31  * from this software without specific prior written permission.
32  *
33  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
34  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
35  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
36  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
37  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
38  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
39  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
40  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
41  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
43  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
44  * POSSIBILITY OF SUCH DAMAGE.
45  */
46 
47 #include <flatland_msgs/DeleteModel.h>
48 #include <flatland_msgs/MoveModel.h>
49 #include <flatland_msgs/SpawnModel.h>
50 #include <flatland_server/simulation_manager.h>
51 #include <flatland_server/world.h>
52 #include <ros/ros.h>
53 #include <std_srvs/Empty.h>
54 
55 #ifndef FLATLAND_PLUGIN_SERVICE_MANAGER_H
56 #define FLATLAND_PLUGIN_SERVICE_MANAGER_H
57 
58 namespace flatland_server {
59 
60 class SimulationManager;
61 
67  public:
70 
71  ros::ServiceServer spawn_model_service_;
72  ros::ServiceServer delete_model_service_;
73  ros::ServiceServer move_model_service_;
74  ros::ServiceServer pause_service_;
75  ros::ServiceServer resume_service_;
76  ros::ServiceServer toggle_pause_service_;
77 
84  ServiceManager(SimulationManager *sim_man, World *world);
85 
91  bool SpawnModel(flatland_msgs::SpawnModel::Request &request,
92  flatland_msgs::SpawnModel::Response &response);
93 
99  bool DeleteModel(flatland_msgs::DeleteModel::Request &request,
100  flatland_msgs::DeleteModel::Response &response);
101 
107  bool MoveModel(flatland_msgs::MoveModel::Request &request,
108  flatland_msgs::MoveModel::Response &response);
109 
113  bool Pause(std_srvs::Empty::Request &request,
114  std_srvs::Empty::Response &response);
115 
119  bool Resume(std_srvs::Empty::Request &request,
120  std_srvs::Empty::Response &response);
121 
125  bool TogglePause(std_srvs::Empty::Request &request,
126  std_srvs::Empty::Response &response);
127 };
128 };
129 #endif
bool Pause(std_srvs::Empty::Request &request, std_srvs::Empty::Response &response)
Callback for the pause service.
Definition: service_manager.cpp:150
bool TogglePause(std_srvs::Empty::Request &request, std_srvs::Empty::Response &response)
Callback for the pause toggle service.
Definition: service_manager.cpp:162
bool DeleteModel(flatland_msgs::DeleteModel::Request &request, flatland_msgs::DeleteModel::Response &response)
Callback for the delete model service.
Definition: service_manager.cpp:113
bool SpawnModel(flatland_msgs::SpawnModel::Request &request, flatland_msgs::SpawnModel::Response &response)
Callback for the spawn model service.
Definition: service_manager.cpp:88
bool Resume(std_srvs::Empty::Request &request, std_srvs::Empty::Response &response)
Callback for the resume service.
Definition: service_manager.cpp:156
ros::ServiceServer spawn_model_service_
service for spawning models
Definition: service_manager.h:71
Definition: body.h:55
ros::ServiceServer move_model_service_
service for moving models
Definition: service_manager.h:73
ros::ServiceServer resume_service_
service for resuming the simulation
Definition: service_manager.h:75
Definition: service_manager.h:66
World * world_
aaa handle to the simulation world
Definition: service_manager.h:68
Definition: world.h:69
ros::ServiceServer pause_service_
service for pausing the simulation
Definition: service_manager.h:74
ServiceManager(SimulationManager *sim_man, World *world)
Service manager constructor.
Definition: service_manager.cpp:53
SimulationManager * sim_man_
a handle to the simulation manager
Definition: service_manager.h:69
bool MoveModel(flatland_msgs::MoveModel::Request &request, flatland_msgs::MoveModel::Response &response)
Callback for the move model service.
Definition: service_manager.cpp:131
ros::ServiceServer toggle_pause_service_
Definition: service_manager.h:76
Definition: simulation_manager.h:58
ros::ServiceServer delete_model_service_
service for deleting models
Definition: service_manager.h:72