Gazebo Gazebo

API Reference

3.15.1
gz/sim/ServerConfig.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 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 #ifndef GZ_GAZEBO_SERVERCONFIG_HH_
18 #define GZ_GAZEBO_SERVERCONFIG_HH_
19 
20 #include <chrono>
21 #include <list>
22 #include <memory>
23 #include <optional> // NOLINT(*)
24 #include <string>
25 #include <vector>
26 #include <sdf/Element.hh>
27 #include <gz/sim/config.hh>
28 #include <gz/sim/Export.hh>
29 
30 namespace ignition
31 {
32  namespace gazebo
33  {
34  // Inline bracket to help doxygen filtering.
35  inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
36  // Forward declarations.
37  class ServerConfigPrivate;
38 
43  class IGNITION_GAZEBO_VISIBLE ServerConfig
44  {
45  class PluginInfoPrivate;
52  public: class IGNITION_GAZEBO_VISIBLE PluginInfo
53  {
55  public: PluginInfo();
56 
58  public: ~PluginInfo();
59 
71  public: PluginInfo(const std::string &_entityName,
72  const std::string &_entityType,
73  const std::string &_filename,
74  const std::string &_name,
75  const sdf::ElementPtr &_sdf);
76 
79  public: PluginInfo(const PluginInfo &_info);
80 
84  public: PluginInfo &operator=(const PluginInfo &_info);
85 
90  public: const std::string &EntityName() const;
91 
96  public: void SetEntityName(const std::string &_entityName);
97 
102  public: const std::string &EntityType() const;
103 
108  public: void SetEntityType(const std::string &_entityType);
109 
112  public: const std::string &Filename() const;
113 
118  public: void SetFilename(const std::string &_filename);
119 
123  public: const std::string &Name() const;
124 
128  public: void SetName(const std::string &_name);
129 
132  public: const sdf::ElementPtr &Sdf() const;
133 
136  public: void SetSdf(const sdf::ElementPtr &_sdf);
137 
140  };
141 
143  public: ServerConfig();
144 
147  public: ServerConfig(const ServerConfig &_config);
148 
150  public: ~ServerConfig();
151 
158  public: bool SetSdfFile(const std::string &_file);
159 
163  public: std::string SdfFile() const;
164 
171  public: bool SetSdfString(const std::string &_sdfString);
172 
176  public: std::string SdfString() const;
177 
180  public: void SetUpdateRate(const double &_hz);
181 
185  public: std::optional<double> UpdateRate() const;
186 
189  public: bool UseLevels() const;
190 
193  public: void SetUseLevels(const bool _levels);
194 
199  public: bool UseDistributedSimulation() const;
200 
207  public: void SetNetworkSecondaries(unsigned int _secondaries);
208 
213  public: unsigned int NetworkSecondaries() const;
214 
222  public: void SetNetworkRole(const std::string &_role);
223 
229  public: std::string NetworkRole() const;
230 
233  public: bool UseLogRecord() const;
234 
237  public: void SetUseLogRecord(const bool _record);
238 
241  public: const std::string LogRecordPath() const;
242 
245  public: void SetLogRecordPath(const std::string &_recordPath);
246 
250  public: bool LogIgnoreSdfPath() const;
251 
257  public: void SetLogIgnoreSdfPath(bool _ignore);
258 
261  public: void AddLogRecordTopic(const std::string &_topic);
262 
265  public: void ClearLogRecordTopics();
266 
270  public: const std::vector<std::string> &LogRecordTopics() const;
271 
274  public: const std::string LogPlaybackPath() const;
275 
278  public: void SetLogPlaybackPath(const std::string &_playbackPath);
279 
282  public: bool LogRecordResources() const;
283 
286  public: void SetLogRecordResources(bool _recordResources);
287 
290  public: std::string LogRecordCompressPath() const;
291 
294  public: void SetLogRecordCompressPath(const std::string &_path);
295 
298  public: unsigned int Seed() const;
299 
302  public: void SetSeed(unsigned int _seed);
303 
307  public: std::optional<std::chrono::steady_clock::duration>
308  UpdatePeriod() const;
309 
315  public: const std::string &ResourceCache() const;
316 
322  public: void SetResourceCache(const std::string &_path);
323 
326  public: const std::string &PhysicsEngine() const;
327 
330  public: void SetPhysicsEngine(const std::string &_physicsEngine);
331 
334  public: const std::string &RenderEngineServer() const;
335 
338  public: const std::string &RenderEngineGui() const;
339 
342  public: void SetRenderEngineServer(
343  const std::string &_renderEngineServer);
344 
347  public: void SetRenderEngineGui(const std::string &_renderEngineGui);
348 
352  public: void AddPlugin(const PluginInfo &_info);
353 
356  public: void AddPlugins(const std::list<PluginInfo> &_plugins);
357 
365  public: PluginInfo LogRecordPlugin() const;
366 
370  public: PluginInfo LogPlaybackPlugin() const;
371 
375  public: const std::list<PluginInfo> &Plugins() const;
376 
380  public: ServerConfig &operator=(const ServerConfig &_cfg);
381 
388  Timestamp() const;
389 
391  private: std::unique_ptr<ServerConfigPrivate> dataPtr;
392  };
393 
398  IGNITION_GAZEBO_VISIBLE
399  parsePluginsFromFile(const std::string &_fname);
400 
405  IGNITION_GAZEBO_VISIBLE
406  parsePluginsFromString(const std::string &_str);
407 
424  //
427  //
430  IGNITION_GAZEBO_VISIBLE
431  loadPluginInfo(bool _isPlayback = false);
432  }
433  }
434 }
435 
436 #endif
std::string NetworkRole() const
Get the network role. See SetNetworkRole(const std::string &_role) for more information about distrib...
std::string LogRecordCompressPath() const
Get file path to compress log files to.
bool SetSdfString(const std::string &_sdfString)
Set an SDF string to be used by the server.
void SetLogIgnoreSdfPath(bool _ignore)
Set whether to ignore the path specified in SDF. Path in SDF should be ignored if a record path is sp...
Configuration parameters for a Server. An instance of this object can be used to construct a Server w...
Definition: gz/sim/ServerConfig.hh:43
void SetLogRecordCompressPath(const std::string &_path)
Set file path to compress log files to.
void AddLogRecordTopic(const std::string &_topic)
Add a topic to record.
void ClearLogRecordTopics()
Clear topics to record. This will remove all topics set using AddLogRecordTopic.
void AddPlugins(const std::list< PluginInfo > &_plugins)
Add multiple plugins to the simulation.
void SetEntityType(const std::string &_entityType)
Set the type of the entity which should receive this plugin. The type is used in conjuction with Enti...
std::optional< std::chrono::steady_clock::duration > UpdatePeriod() const
Get the update period duration.
This library is part of the Ignition Robotics project.
STL class.
void SetSdf(const sdf::ElementPtr &_sdf)
Set the plugin XML elements associated with this plugin.
STL class.
const std::string & Filename() const
Get the plugin library filename.
void SetUseLogRecord(const bool _record)
Set whether the server is recording states.
const std::string & PhysicsEngine() const
Physics engine plugin library to load.
std::list< ServerConfig::PluginInfo > loadPluginInfo(bool _isPlayback=false)
Load plugin information, following ordering.
STL class.
void SetUpdateRate(const double &_hz)
Set the update rate in Hertz. Value <=0 are ignored.
const std::vector< std::string > & LogRecordTopics() const
Get the topics to record that were added using AddLogRecordTopic.
void SetUseLevels(const bool _levels)
Get whether the server is using the level system.
const std::string LogRecordPath() const
Get path to place recorded states.
unsigned int Seed() const
The given random seed.
const std::chrono::time_point< std::chrono::system_clock > & Timestamp() const
Get the timestamp of this ServerConfig. This is the system time when this ServerConfig was created....
void SetNetworkSecondaries(unsigned int _secondaries)
Set the number of network secondary servers that the primary server should expect....
ServerConfig & operator=(const ServerConfig &_cfg)
Equal operator.
std::list< ServerConfig::PluginInfo > parsePluginsFromFile(const std::string &_fname)
Parse plugins from XML configuration file.
void SetLogRecordPath(const std::string &_recordPath)
Set path to place recorded states.
Component< std::string, class NameTag > Name
This component holds an entity's name. The component has no concept of scoped names nor does it care ...
Definition: gz/sim/components/Name.hh:35
void SetRenderEngineServer(const std::string &_renderEngineServer)
Set the render engine server plugin library.
std::chrono::steady_clock::time_point Timestamp
void SetPhysicsEngine(const std::string &_physicsEngine)
Set the physics engine plugin library.
void SetFilename(const std::string &_filename)
Set the type of the entity which should receive this plugin. The type is used in conjuction with Enti...
PluginInfo LogPlaybackPlugin() const
Generate PluginInfo for Log playback based on the internal state of this ServerConfig object:
const std::string & ResourceCache() const
Path to where simulation resources, such as models downloaded from fuel.ignitionrobotics....
unsigned int NetworkSecondaries() const
Get the number of secondary servers that a primary server should expect.
bool UseLevels() const
Get whether the server is using the level system.
std::string SdfFile() const
Get the SDF file that has been set. An empty string will be returned if an SDF file has not been set.
const std::string LogPlaybackPath() const
Get path to recorded states to play back.
void SetLogPlaybackPath(const std::string &_playbackPath)
Set path to recorded states to play back.
std::list< ServerConfig::PluginInfo > parsePluginsFromString(const std::string &_str)
Parse plugins from XML configuration string.
void SetLogRecordResources(bool _recordResources)
Set whether meshes and material files are recorded.
PluginInfo LogRecordPlugin() const
Generate PluginInfo for Log recording based on the internal state of this ServerConfig object:
void SetRenderEngineGui(const std::string &_renderEngineGui)
Set the render engine gui plugin library.
const std::string & RenderEngineGui() const
Render engine plugin library to load.
bool SetSdfFile(const std::string &_file)
Set an SDF file to be used with the server.
void SetName(const std::string &_name)
Set the name of the interface within the plugin library to load.
void AddPlugin(const PluginInfo &_info)
Instruct simulation to attach a plugin to a specific entity when simulation starts.
PluginInfo & operator=(const PluginInfo &_info)
Equal operator.
void SetResourceCache(const std::string &_path)
Set the path to where simulation resources, such as models downloaded from fuel.ignitionrobotics....
const std::string & EntityType() const
Get the entity type which should receive this plugin. The type is used in conjuction with EntityName ...
bool LogRecordResources() const
Get whether meshes and material files are recorded.
void SetEntityName(const std::string &_entityName)
Set the name of the entity which should receive this plugin. The name is used in conjuction with _ent...
const std::list< PluginInfo > & Plugins() const
Get all the plugins that should be loaded.
const std::string & RenderEngineServer() const
Render engine plugin library to load.
const std::string & EntityName() const
Get the name of the entity which should receive this plugin. The name is used in conjuction with _ent...
const sdf::ElementPtr & Sdf() const
Plugin XML elements associated with this plugin.
void SetSeed(unsigned int _seed)
Set the random seed.
bool UseLogRecord() const
Get whether the server is recording states.
bool UseDistributedSimulation() const
Get whether the server is using the distributed sim system.
Information about a plugin that should be loaded by the server.
Definition: gz/sim/ServerConfig.hh:52
void SetNetworkRole(const std::string &_role)
Set the network role, which is one of [primary, secondary]. If primary is used, then make sure to als...
std::string SdfString() const
Get the SDF String that has been set. An empty string will be returned if an SDF string has not been ...
std::optional< double > UpdateRate() const
Get the update rate in Hertz.
bool LogIgnoreSdfPath() const
Get whether to ignore the path specified in SDF.
const std::string & Name() const
Name of the interface within the plugin library to load.