ArrangePlugin.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2014 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16*/
17
18#ifndef GAZEBO_PLUGINS_ARRANGEPLUGIN_HH_
19#define GAZEBO_PLUGINS_ARRANGEPLUGIN_HH_
20
21#include <map>
22#include <memory>
23#include <string>
24
25#include <sdf/sdf.hh>
26#include <ignition/math/Pose3.hh>
27#include <ignition/transport/Node.hh>
28
30#include <gazebo/transport/transport.hh>
32#include <gazebo/util/system.hh>
33#include <gazebo/msgs/msgs.hh>
34
35namespace gazebo
36{
37 class GZ_PLUGIN_VISIBLE ArrangePlugin : public WorldPlugin
38 {
40 public: ArrangePlugin();
41
43 public: ~ArrangePlugin();
44
48 public: virtual void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf);
49
51 public: virtual void Init();
52
54 public: virtual void Reset();
55
59 public: bool SetArrangement(const std::string &_arrangement);
60
62 public: void ArrangementCallback(ConstGzStringPtr &_msg);
63
66
68 protected: sdf::ElementPtr sdf;
69
71 protected: class Object
72 {
75
77 public: ignition::math::Pose3d pose;
78 };
79 typedef std::shared_ptr<Object> ObjectPtr;
80
82 typedef std::map<std::string, ObjectPtr> Object_M;
83
85 protected: Object_M objects;
86
88 typedef std::map<std::string, ignition::math::Pose3d> Pose_M;
89
91 typedef std::map<std::string, Pose_M> Arrangement_M;
92
95
97 protected: std::string initialArrangementName;
98
100 protected: std::string currentArrangementName;
101
103 protected: std::string eventTopicName;
104
107
110
111 // Place ignition::transport objects at the end of this file to
112 // guarantee they are destructed first.
113
115 protected: ignition::transport::Node nodeIgn;
116 };
117}
118#endif
default namespace for gazebo
Class to store info about each object.
Definition ArrangePlugin.hh:72
ignition::math::Pose3d pose
Initial object pose.
Definition ArrangePlugin.hh:77
physics::ModelPtr model
Model pointer.
Definition ArrangePlugin.hh:74
Definition ArrangePlugin.hh:38
ArrangePlugin()
Constructor.
physics::WorldPtr world
World pointer.
Definition ArrangePlugin.hh:65
std::map< std::string, Pose_M > Arrangement_M
Map of strings to Pose_M (arrangement map).
Definition ArrangePlugin.hh:91
virtual void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf)
Load the plugin.
Arrangement_M arrangements
Information about arrangements.
Definition ArrangePlugin.hh:94
std::map< std::string, ObjectPtr > Object_M
Map of strings to model pointers.
Definition ArrangePlugin.hh:82
~ArrangePlugin()
Destructor.
virtual void Init()
Initialize the plugin.
std::shared_ptr< Object > ObjectPtr
Definition ArrangePlugin.hh:79
virtual void Reset()
Reset the plugin.
transport::SubscriberPtr sub
Subscriber for listening to changing arrangements.
Definition ArrangePlugin.hh:109
bool SetArrangement(const std::string &_arrangement)
Set up the arrangement with name given by input parameter.
transport::NodePtr node
Node for Gazebo transport.
Definition ArrangePlugin.hh:106
ignition::transport::Node nodeIgn
Ignition node for Gazebo transport.
Definition ArrangePlugin.hh:115
std::string eventTopicName
Topic to listen on for changing arrangments.
Definition ArrangePlugin.hh:103
sdf::ElementPtr sdf
SDF pointer.
Definition ArrangePlugin.hh:68
Object_M objects
Collection of models.
Definition ArrangePlugin.hh:85
std::string currentArrangementName
Current arrangement name.
Definition ArrangePlugin.hh:100
void ArrangementCallback(ConstGzStringPtr &_msg)
Callback function which receives a requested arrangement name.
std::string initialArrangementName
Initial arrangement name.
Definition ArrangePlugin.hh:97
std::map< std::string, ignition::math::Pose3d > Pose_M
Map of strings to model poses.
Definition ArrangePlugin.hh:88
A plugin with access to physics::World.
Definition Plugin.hh:279
boost::shared_ptr< World > WorldPtr
Definition PhysicsTypes.hh:89
boost::shared_ptr< Model > ModelPtr
Definition PhysicsTypes.hh:93
boost::shared_ptr< Subscriber > SubscriberPtr
Definition TransportTypes.hh:53
boost::shared_ptr< Node > NodePtr
Definition TransportTypes.hh:57
Forward declarations for the common classes.
Definition Animation.hh:27