VisualUtils.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 João Borrego
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 
28 // Gazebo
29 #include <gazebo/common/Events.hh>
30 #include "gazebo/common/Plugin.hh"
31 #include "gazebo/common/SystemPaths.hh"
32 #include <gazebo/msgs/msgs.hh>
33 #include "gazebo/rendering/RenderEngine.hh"
34 #include <gazebo/rendering/Visual.hh>
35 #include <gazebo/transport/Node.hh>
36 
37 // Boost - for convenient string split
38 #include <boost/algorithm/string/classification.hpp>
39 #include <boost/algorithm/string/split.hpp>
40 // Mutex
41 #include <mutex>
42 // Shuffle vector
43 #include <algorithm>
44 #include <random>
45 #include <chrono>
46 
47 // Custom messages
48 #include "visual_utils_request.pb.h"
49 #include "visual_utils_response.pb.h"
50 
51 namespace VisualUtils {
52 
54 #define REQUEST_TOPIC "~/gap/visual_utils"
55 #define RESPONSE_TOPIC "~/gap/visual_utils/response"
57 
59 #define UPDATE gap::msgs::VisualUtilsRequest::UPDATE
60 #define DEFAULT_POSE gap::msgs::VisualUtilsRequest::DEFAULT_POSE
62 #define MATERIAL gap::msgs::VisualUtilsRequest::MATERIAL_PREFIX
64 
66 #define UPDATED gap::msgs::VisualUtilsResponse::UPDATED
67 
68 // Default parameters
69 
71 #define DEFAULT_NAME "default"
72 
73 }
74 
75 namespace gazebo{
76 
78  typedef const boost::shared_ptr<const gap::msgs::VisualUtilsRequest>
81  typedef const boost::shared_ptr<const gap::msgs::VisualUtilsResponse>
83 
84  // Forward declaration of private data class
85  class VisualUtilsPrivate;
86 
105  class VisualUtils : public VisualPlugin {
106 
108  public: VisualUtils();
109 
111  public: virtual ~VisualUtils();
112 
116  public: virtual void Load(
117  rendering::VisualPtr _visual,
118  sdf::ElementPtr _sdf);
119 
121  public: void Update();
122 
125  public: void onRequest(VisualUtilsRequestPtr & _msg);
126 
128  private: std::unique_ptr<VisualUtilsPrivate> dataPtr;
129 
131  private: void loadResources();
132 
135  private: void randomMaterialName(std::string & name);
136  };
137 }
std::unique_ptr< VisualUtilsPrivate > dataPtr
Private data pointer.
Definition: VisualUtils.hh:128
Definition: CameraUtils.cc:30
const boost::shared_ptr< const gap::msgs::VisualUtilsResponse > VisualUtilsResponsePtr
Pointer to VisualUtils request message.
Definition: scene_example.hh:155
const boost::shared_ptr< const gap::msgs::VisualUtilsRequest > VisualUtilsRequestPtr
Shared pointer declaration for request message type.
Definition: VisualUtils.hh:79
Definition: VisualUtils.hh:51
Class for private visual utils plugin data.
Definition: VisualUtils.cc:33