Ignition Gazebo

API Reference

5.0.0
Server.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 IGNITION_GAZEBO_SERVER_HH_
18 #define IGNITION_GAZEBO_SERVER_HH_
19 
20 #include <cstdint>
21 #include <memory>
22 #include <optional>
23 #include <string>
24 #include <ignition/gazebo/config.hh>
26 #include <ignition/gazebo/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  // Forware declarations
37  class ServerPrivate;
38 
108  class IGNITION_GAZEBO_VISIBLE Server
109  {
114  public: explicit Server(const ServerConfig &_config = ServerConfig());
115 
117  public: ~Server();
118 
125  public: void SetUpdatePeriod(
126  const std::chrono::steady_clock::duration &_updatePeriod,
127  const unsigned int _worldIndex = 0);
128 
144  public: bool Run(const bool _blocking = false,
145  const uint64_t _iterations = 0,
146  const bool _paused = true);
147 
155  public: bool RunOnce(const bool _paused = true);
156 
162  public: bool Running() const;
163 
172  public: std::optional<bool> Running(const unsigned int _worldIndex) const;
173 
181  public: bool SetPaused(const bool _paused,
182  const unsigned int _worldIndex = 0) const;
183 
190  public: std::optional<bool> Paused(
191  const unsigned int _worldIndex = 0) const;
192 
197  public: std::optional<uint64_t> IterationCount(
198  const unsigned int _worldIndex = 0) const;
199 
203  public: std::optional<size_t> EntityCount(
204  const unsigned int _worldIndex = 0) const;
205 
209  public: std::optional<size_t> SystemCount(
210  const unsigned int _worldIndex = 0) const;
211 
218  public: std::optional<bool> AddSystem(
219  const SystemPluginPtr &_system,
220  const unsigned int _worldIndex = 0);
221 
230  public: std::optional<Entity> EntityByName(const std::string &_name,
231  const unsigned int _worldIndex = 0) const;
232 
239  public: bool HasEntity(const std::string &_name,
240  const unsigned int _worldIndex = 0) const;
241 
255  public: bool RequestRemoveEntity(const std::string &_name,
256  bool _recursive = true,
257  const unsigned int _worldIndex = 0);
258 
270  public: bool RequestRemoveEntity(const Entity _entity,
271  bool _recursive = true,
272  const unsigned int _worldIndex = 0);
273 
275  private: std::unique_ptr<ServerPrivate> dataPtr;
276  };
277  }
278  }
279 }
280 
281 #endif
The server instantiates and controls simulation.
Definition: Server.hh:108
Configuration parameters for a Server. An instance of this object can be used to construct a Server w...
Definition: ServerConfig.hh:43
STL class.
This library is part of the Ignition Robotics project.
uint64_t Entity
An Entity identifies a single object in simulation such as a model, link, or light. At its core, an Entity is just an identifier.
Definition: Entity.hh:59