placard_plugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 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 VRX_GAZEBO_PLACARD_PLUGIN_HH_
19 #define VRX_GAZEBO_PLACARD_PLUGIN_HH_
20 
21 #include <ros/ros.h>
22 #include <std_msgs/ColorRGBA.h>
23 #include <std_msgs/Empty.h>
24 #include <dock_placard.pb.h>
25 #include <array>
26 #include <cstdint>
27 #include <map>
28 #include <mutex>
29 #include <string>
30 #include <vector>
31 #include <gazebo/gazebo.hh>
32 #include <sdf/sdf.hh>
33 
34 namespace gazebo
35 {
36  typedef const boost::shared_ptr<
37  const dock_placard_msgs::msgs::DockPlacard>
39 }
40 
74 class PlacardPlugin : public gazebo::VisualPlugin
75 {
76  // Documentation inherited.
77  public: PlacardPlugin();
78 
79  public: void Load(gazebo::rendering::VisualPtr _parent,
80  sdf::ElementPtr _sdf);
81 
88  private: static std_msgs::ColorRGBA CreateColor(const double _r,
89  const double _g,
90  const double _b,
91  const double _a);
92 
94  private: void InitializeAllPatterns();
95 
98  private: bool ParseSDF(sdf::ElementPtr _sdf);
99 
101  private: void Update();
102 
105  private: void ChangeSymbol(const std_msgs::Empty::ConstPtr &_msg);
106 
109  private: void ChangeSymbolTo(gazebo::ConstDockPlacardPtr &_msg);
110 
113  private: static std::map<std::string, std_msgs::ColorRGBA> kColors;
114 
117  private: static std::vector<std::string> kShapes;
118 
120  private: std::string color;
121 
123  private: std::string shape;
124 
126  private: std::vector<std::array<std::string, 2u>> allPatterns;
127 
129  private: size_t allPatternsIdx = 0u;
130 
132  private: std::vector<std::string> visualNames;
133 
135  private: std::vector<gazebo::rendering::VisualPtr> visuals;
136 
138  private: bool shuffleEnabled = true;
139 
142 
144  private: ros::NodeHandle nh;
145 
147  private: std::string ns;
148 
150  private: std::string rosShuffleTopic;
151 
153  private: gazebo::transport::NodePtr gzNode;
154 
156  private: std::string symbolSubTopic;
157 
159  private: gazebo::transport::SubscriberPtr symbolSub;
160 
162  private: gazebo::rendering::ScenePtr scene;
163 
165  private: gazebo::event::ConnectionPtr updateConnection;
166 
168  private: gazebo::common::Time nextUpdateTime;
169 
171  private: std::mutex mutex;
172 };
173 
174 #endif
static std::vector< std::string > kShapes
List of the shape options (circle, cross, triangle) with their string name for logging.
ros::NodeHandle nh
ROS Node handle.
gazebo::rendering::ScenePtr scene
Pointer to the scene node.
gazebo::event::ConnectionPtr updateConnection
Connects to rendering update event.
std::mutex mutex
Locks state and pattern member variables.
ros::Subscriber changeSymbolSub
Service to generate and display a new symbol.
std::string rosShuffleTopic
ROS topic.
gazebo::transport::NodePtr gzNode
gazebo Node
gazebo::common::Time nextUpdateTime
Next time where the plugin should be updated.
std::string color
The current color.
Controls the shape and color of a symbol.
std::vector< std::array< std::string, 2u > > allPatterns
All color/symbol sequences.
std::vector< std::string > visualNames
Collection of visual names.
const boost::shared_ptr< const dock_placard_msgs::msgs::DockPlacard > ConstDockPlacardPtr
static std::map< std::string, std_msgs::ColorRGBA > kColors
List of the color options (red, green, blue, and no color) with their string name for logging...
std::string ns
ROS namespace.
std::string symbolSubTopic
gazebo symbol sub topic
std::vector< gazebo::rendering::VisualPtr > visuals
Pointer to the visual elements to modify.
std::string shape
The current shape.
gazebo::transport::SubscriberPtr symbolSub
symbol subscriber


vrx_gazebo
Author(s): Brian Bingham , Carlos Aguero
autogenerated on Thu May 7 2020 03:54:56