Flatland
model_plugin.h
1 /*
2  * ______ __ __ __
3  * /\ _ \ __ /\ \/\ \ /\ \__
4  * \ \ \L\ \ __ __ /\_\ \_\ \ \ \____ ___\ \ ,_\ ____
5  * \ \ __ \/\ \/\ \\/\ \ /'_` \ \ '__`\ / __`\ \ \/ /',__\
6  * \ \ \/\ \ \ \_/ |\ \ \/\ \L\ \ \ \L\ \/\ \L\ \ \ \_/\__, `\
7  * \ \_\ \_\ \___/ \ \_\ \___,_\ \_,__/\ \____/\ \__\/\____/
8  * \/_/\/_/\/__/ \/_/\/__,_ /\/___/ \/___/ \/__/\/___/
9  * @copyright Copyright 2017 Avidbots Corp.
10  * @name model_plugin.h
11  * @brief Interface for ModelPlugin pluginlib plugins
12  * @author Joseph Duchesne
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 #ifndef FLATLAND_SERVER_MODEL_PLUGIN_H
48 #define FLATLAND_SERVER_MODEL_PLUGIN_H
49 
50 #include <Box2D/Box2D.h>
51 #include <flatland_server/flatland_plugin.h>
52 #include <flatland_server/model.h>
53 #include <flatland_server/timekeeper.h>
54 #include <ros/ros.h>
55 #include <yaml-cpp/yaml.h>
56 
57 namespace flatland_server {
58 
64 class ModelPlugin : public FlatlandPlugin {
65  private:
66  Model *model_;
67 
68  public:
69  ros::NodeHandle nh_;
70 
74  Model *GetModel();
75 
84  void Initialize(const std::string &type, const std::string &name,
85  Model *model, const YAML::Node &config);
86 
100  bool FilterContact(b2Contact *contact, Entity *&entity,
101  b2Fixture *&this_fixture, b2Fixture *&other_fixture);
102 
108  bool FilterContact(b2Contact *contact);
109 
110  protected:
114  ModelPlugin() = default;
115 };
116 }; // namespace flatland_server
117 #endif // FLATLAND_SERVER_MODEL_PLUGIN_H
ModelPlugin()=default
Model plugin default constructor.
bool FilterContact(b2Contact *contact, Entity *&entity, b2Fixture *&this_fixture, b2Fixture *&other_fixture)
Helper function check if this model is part of the contact, and extracts all the useful information...
Definition: model_plugin.cpp:63
Definition: entity.h:61
Definition: body.h:55
Definition: model.h:67
ros::NodeHandle nh_
ROS node handle.
Definition: model_plugin.h:69
Definition: flatland_plugin.h:57
Model * GetModel()
Get model.
Definition: model_plugin.cpp:51
void Initialize(const std::string &type, const std::string &name, Model *model, const YAML::Node &config)
The method to initialize the ModelPlugin, required since Pluginlib require the class to have a defaul...
Definition: model_plugin.cpp:53
Definition: model_plugin.h:64